Implement new content schedule for magic hatching potions

This commit is contained in:
Phillip Thelen
2024-01-31 18:29:58 +01:00
committed by Sabe Jones
parent f223b5dd2a
commit 129cb7627c
3 changed files with 102 additions and 2 deletions

View File

@@ -101,7 +101,12 @@ export default async function purchase (user, req = {}, analytics) {
const { price, item } = getItemAndPrice(user, type, key, req);
if (!item.canBuy(user)) {
if (item.type === 'hatchingPotion' && item.premium === true) {
const matchers = assembleScheduledMatchers(new Date()).filter(matcher => matcher.type === 'premiumHatchingPotions').map(matcher => matcher.matcher);
if (matchers.length && !matchers.some(matcher => matcher(item.key))) {
throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
}
} else if (!item.canBuy(user)) {
throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
}