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

@@ -67,6 +67,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Aurora',
'Moonglow',
'IcySnow',
]),
},
], ],
}, },
1: { 1: {
@@ -106,6 +114,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'PolkaDot',
'Cupid',
'RoseGold',
]),
},
], ],
}, },
2: { 2: {
@@ -144,6 +160,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Birch',
'StainedGlass',
'Porcelain',
]),
},
], ],
}, },
3: { 3: {
@@ -183,6 +207,13 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Shimmer',
'Glass',
]),
},
], ],
}, },
4: { 4: {
@@ -221,6 +252,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Floral',
'Fairy',
'RoseQuartz',
]),
},
], ],
}, },
5: { 5: {
@@ -266,6 +305,13 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Rainbow',
'Sunshine',
]),
},
], ],
}, },
6: { 6: {
@@ -311,6 +357,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Celestial',
'SandCastle',
'Watery',
]),
},
], ],
}, },
7: { 7: {
@@ -350,6 +404,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Aquatic',
'StarryNight',
'Sunset',
]),
},
], ],
}, },
8: { 8: {
@@ -389,6 +451,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Glow',
'AutumnLeaf',
'Shadow',
]),
},
], ],
}, },
9: { 9: {
@@ -428,6 +498,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Vampire',
'Ghost',
'Spooky',
]),
},
], ],
}, },
10: { 10: {
@@ -468,6 +546,14 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Ember',
'Frost',
'Thunderstorm',
]),
},
], ],
}, },
11: { 11: {
@@ -502,6 +588,13 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
matcher: inListMatcher([
'Peppermint',
'Holly',
]),
},
], ],
}, },
}; };

View File

@@ -71,8 +71,10 @@ shops.getMarketCategories = function getMarket (user, language) {
text: i18n.t('magicHatchingPotions', language), text: i18n.t('magicHatchingPotions', language),
notes: i18n.t('premiumPotionNoDropExplanation', 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) 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'); .map(premiumHatchingPotion => getItemInfo(user, 'premiumHatchingPotion', premiumHatchingPotion, officialPinnedItems, language)), 'key');
if (premiumHatchingPotionsCategory.items.length > 0) { if (premiumHatchingPotionsCategory.items.length > 0) {
categories.push(premiumHatchingPotionsCategory); categories.push(premiumHatchingPotionsCategory);

View File

@@ -101,7 +101,12 @@ 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 (!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)); throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
} }