mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 13:47:33 +01:00
fix purchasing wacky potions (#15276)
This commit is contained in:
@@ -233,6 +233,17 @@ describe('shared.ops.purchase', () => {
|
|||||||
expect(user.items.hatchingPotions[key]).to.eql(1);
|
expect(user.items.hatchingPotions[key]).to.eql(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('purchases event hatching potion', async () => {
|
||||||
|
clock.restore();
|
||||||
|
clock = sandbox.useFakeTimers(moment('2022-04-10').valueOf());
|
||||||
|
const type = 'hatchingPotions';
|
||||||
|
const key = 'Veggie';
|
||||||
|
|
||||||
|
await purchase(user, { params: { type, key } });
|
||||||
|
|
||||||
|
expect(user.items.hatchingPotions[key]).to.eql(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('purchases hatching potion if user completed quest', async () => {
|
it('purchases hatching potion if user completed quest', async () => {
|
||||||
const type = 'hatchingPotions';
|
const type = 'hatchingPotions';
|
||||||
const key = 'Bronze';
|
const key = 'Bronze';
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export default async function purchase (user, req = {}, analytics) {
|
|||||||
|
|
||||||
const { price, item } = getItemAndPrice(user, type, key, req);
|
const { price, item } = getItemAndPrice(user, type, key, req);
|
||||||
|
|
||||||
if (type === 'hatchingPotions' && item.premium === true && item.questPotion !== true) {
|
if (type === 'hatchingPotions' && (item.premium === true || item.wacky === true) && item.questPotion !== true) {
|
||||||
const matchers = getScheduleMatchingGroup('premiumHatchingPotions');
|
const matchers = getScheduleMatchingGroup('premiumHatchingPotions');
|
||||||
if (!matchers.match(item.key)) {
|
if (!matchers.match(item.key)) {
|
||||||
throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
|
throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
|
||||||
|
|||||||
Reference in New Issue
Block a user