diff --git a/website/common/script/content/constants/schedule.js b/website/common/script/content/constants/schedule.js index 7f9a13904d..c7bf10fa69 100644 --- a/website/common/script/content/constants/schedule.js +++ b/website/common/script/content/constants/schedule.js @@ -67,6 +67,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Aurora', + 'Moonglow', + 'IcySnow', + ]), + }, ], }, 1: { @@ -106,6 +114,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'PolkaDot', + 'Cupid', + 'RoseGold', + ]), + }, ], }, 2: { @@ -144,6 +160,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Birch', + 'StainedGlass', + 'Porcelain', + ]), + }, ], }, 3: { @@ -183,6 +207,13 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Shimmer', + 'Glass', + ]), + }, ], }, 4: { @@ -221,6 +252,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Floral', + 'Fairy', + 'RoseQuartz', + ]), + }, ], }, 5: { @@ -266,6 +305,13 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Rainbow', + 'Sunshine', + ]), + }, ], }, 6: { @@ -311,6 +357,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Celestial', + 'SandCastle', + 'Watery', + ]), + }, ], }, 7: { @@ -350,6 +404,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Aquatic', + 'StarryNight', + 'Sunset', + ]), + }, ], }, 8: { @@ -389,6 +451,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Glow', + 'AutumnLeaf', + 'Shadow', + ]), + }, ], }, 9: { @@ -428,6 +498,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Vampire', + 'Ghost', + 'Spooky', + ]), + }, ], }, 10: { @@ -468,6 +546,14 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Ember', + 'Frost', + 'Thunderstorm', + ]), + }, ], }, 11: { @@ -502,6 +588,13 @@ export const MONTHLY_SCHEDULE = { }, ], [FOURTH_RELEASE_DAY]: [ + { + type: 'premiumHatchingPotions', + matcher: inListMatcher([ + 'Peppermint', + 'Holly', + ]), + }, ], }, }; diff --git a/website/common/script/libs/shops.js b/website/common/script/libs/shops.js index ab75ed6a71..aea59c3894 100644 --- a/website/common/script/libs/shops.js +++ b/website/common/script/libs/shops.js @@ -71,8 +71,10 @@ shops.getMarketCategories = function getMarket (user, language) { text: i18n.t('magicHatchingPotions', language), notes: i18n.t('premiumPotionNoDropExplanation', language), }; + const matchers = assembleScheduledMatchers(new Date()).filter(matcher => matcher.type === 'premiumHatchingPotions').map(matcher => matcher.matcher); premiumHatchingPotionsCategory.items = sortBy(values(content.hatchingPotions) - .filter(hp => hp.limited && hp.canBuy(user)) + .filter(hp => hp.limited + && matchers.map(matcher => matcher(hp.key)).every(matcher => matcher === true)) .map(premiumHatchingPotion => getItemInfo(user, 'premiumHatchingPotion', premiumHatchingPotion, officialPinnedItems, language)), 'key'); if (premiumHatchingPotionsCategory.items.length > 0) { categories.push(premiumHatchingPotionsCategory); diff --git a/website/common/script/ops/buy/purchase.js b/website/common/script/ops/buy/purchase.js index 3788eb778b..c1989e33f6 100644 --- a/website/common/script/ops/buy/purchase.js +++ b/website/common/script/ops/buy/purchase.js @@ -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)); }