Implement new content schedule for potion and pet quests

This commit is contained in:
Phillip Thelen
2024-01-31 17:53:46 +01:00
committed by Sabe Jones
parent 17db6a1772
commit b3521be629
3 changed files with 189 additions and 4 deletions

View File

@@ -47,12 +47,18 @@ export const MONTHLY_SCHEDULE = {
type: 'petQuests', type: 'petQuests',
matcher: inListMatcher([ matcher: inListMatcher([
'ghost_stag', 'ghost_stag',
'trex', 'trex_undead',
'harpy', 'harpy',
'sabretooth', 'sabretooth',
'dolphin', 'dolphin',
]), ]),
}, },
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'ruby',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -71,6 +77,22 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'nudibranch',
'seaserpent',
'gryphon',
'yarn',
'axolotl',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'silver',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -89,6 +111,21 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'rooster',
'slime',
'peacock',
'bunny',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'pinkMarble',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -107,6 +144,20 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'frog',
'spider',
'cow',
'pterodactyl',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -125,6 +176,21 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'snake',
'monkey',
'falcon',
'aligator',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'mossyStone',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -143,6 +209,20 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'octopus',
'horse',
'kraken',
'sloth',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -161,6 +241,21 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'trex',
'unicorn',
'veolociraptor',
'hippo',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'turquiose',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -179,6 +274,21 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'whale',
'seahorse',
'armadillo',
'guineapig',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'fluorite',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -197,6 +307,21 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'turtle',
'penguin',
'butterfly',
'cheetah',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'blackPearl',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -215,6 +340,21 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'squirrel',
'triceratops',
'treeling',
'beetle',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'bronze',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -233,6 +373,21 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'snail',
'rock',
'ferret',
'hedgehog',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'onyx',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],
@@ -251,6 +406,22 @@ export const MONTHLY_SCHEDULE = {
}, },
], ],
[THIRD_RELEASE_DAY]: [ [THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
matcher: inListMatcher([
'sheep',
'kangaroo',
'owl',
'rat',
'badger',
]),
},
{
type: 'hatchingPotionQuests',
matcher: inListMatcher([
'amber',
]),
},
], ],
[FOURTH_RELEASE_DAY]: [ [FOURTH_RELEASE_DAY]: [
], ],

View File

@@ -285,9 +285,17 @@ shops.getQuestShopCategories = function getQuestShopCategories (user, language)
text: i18n.t(`${type}Quests`, language), text: i18n.t(`${type}Quests`, language),
}; };
category.items = content.questsByLevel let filteredQuests = content.questsByLevel
.filter(quest => quest.canBuy(user) && quest.category === type) .filter(quest => quest.canBuy(user) && quest.category === type);
.map(quest => getItemInfo(user, 'quests', quest, officialPinnedItems, language));
if (type === 'pet' || type === 'hatchingPotion') {
const matchers = assembleScheduledMatchers(new Date())
.filter(matcher => matcher.type === `${type}Quests`).map(matcher => matcher.matcher);
filteredQuests = filteredQuests.filter(quest => matchers.map(matcher => matcher(quest.key))
.every(matcher => matcher === true));
}
category.items = filteredQuests.map(quest => getItemInfo(user, 'quests', quest, officialPinnedItems, language));
categories.push(category); categories.push(category);
}); });

View File

@@ -8,6 +8,7 @@ import content from '../../content/index';
import { errorMessage } from '../../libs/errorMessage'; import { errorMessage } from '../../libs/errorMessage';
import { AbstractGemItemOperation } from './abstractBuyOperation'; import { AbstractGemItemOperation } from './abstractBuyOperation';
import { assembleScheduledMatchers } from '../../content/constants/schedule';
export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // eslint-disable-line import/prefer-default-export, max-len export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // eslint-disable-line import/prefer-default-export, max-len
multiplePurchaseAllowed () { // eslint-disable-line class-methods-use-this multiplePurchaseAllowed () { // eslint-disable-line class-methods-use-this
@@ -51,6 +52,11 @@ export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // esli
} }
} }
const matchers = assembleScheduledMatchers(new Date()).filter(matcher => matcher.type === `${item.category}Quests`).map(matcher => matcher.matcher);
if (matchers.length && !matchers.some(matcher => matcher(item.key))) {
throw new NotAuthorized(this.i18n('notAvailable', { key: item.key }));
}
super.canUserPurchase(user, item); super.canUserPurchase(user, item);
} }