From b3521be62979ac8a5d82e40c8042c92736671123 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Wed, 31 Jan 2024 17:53:46 +0100 Subject: [PATCH] Implement new content schedule for potion and pet quests --- .../script/content/constants/schedule.js | 173 +++++++++++++++++- website/common/script/libs/shops.js | 14 +- website/common/script/ops/buy/buyQuestGem.js | 6 + 3 files changed, 189 insertions(+), 4 deletions(-) diff --git a/website/common/script/content/constants/schedule.js b/website/common/script/content/constants/schedule.js index fcb0bc04a4..3cf37c411b 100644 --- a/website/common/script/content/constants/schedule.js +++ b/website/common/script/content/constants/schedule.js @@ -47,12 +47,18 @@ export const MONTHLY_SCHEDULE = { type: 'petQuests', matcher: inListMatcher([ 'ghost_stag', - 'trex', + 'trex_undead', 'harpy', 'sabretooth', 'dolphin', ]), }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'ruby', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -71,6 +77,22 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'nudibranch', + 'seaserpent', + 'gryphon', + 'yarn', + 'axolotl', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'silver', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -89,6 +111,21 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'rooster', + 'slime', + 'peacock', + 'bunny', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'pinkMarble', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -107,6 +144,20 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'frog', + 'spider', + 'cow', + 'pterodactyl', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -125,6 +176,21 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'snake', + 'monkey', + 'falcon', + 'aligator', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'mossyStone', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -143,6 +209,20 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'octopus', + 'horse', + 'kraken', + 'sloth', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -161,6 +241,21 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'trex', + 'unicorn', + 'veolociraptor', + 'hippo', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'turquiose', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -179,6 +274,21 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'whale', + 'seahorse', + 'armadillo', + 'guineapig', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'fluorite', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -197,6 +307,21 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'turtle', + 'penguin', + 'butterfly', + 'cheetah', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'blackPearl', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -215,6 +340,21 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'squirrel', + 'triceratops', + 'treeling', + 'beetle', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'bronze', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -233,6 +373,21 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'snail', + 'rock', + 'ferret', + 'hedgehog', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'onyx', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], @@ -251,6 +406,22 @@ export const MONTHLY_SCHEDULE = { }, ], [THIRD_RELEASE_DAY]: [ + { + type: 'petQuests', + matcher: inListMatcher([ + 'sheep', + 'kangaroo', + 'owl', + 'rat', + 'badger', + ]), + }, + { + type: 'hatchingPotionQuests', + matcher: inListMatcher([ + 'amber', + ]), + }, ], [FOURTH_RELEASE_DAY]: [ ], diff --git a/website/common/script/libs/shops.js b/website/common/script/libs/shops.js index 44d0035a6f..b1b0574dbb 100644 --- a/website/common/script/libs/shops.js +++ b/website/common/script/libs/shops.js @@ -285,9 +285,17 @@ shops.getQuestShopCategories = function getQuestShopCategories (user, language) text: i18n.t(`${type}Quests`, language), }; - category.items = content.questsByLevel - .filter(quest => quest.canBuy(user) && quest.category === type) - .map(quest => getItemInfo(user, 'quests', quest, officialPinnedItems, language)); + let filteredQuests = content.questsByLevel + .filter(quest => quest.canBuy(user) && quest.category === type); + + 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); }); diff --git a/website/common/script/ops/buy/buyQuestGem.js b/website/common/script/ops/buy/buyQuestGem.js index 20ddb8e3b5..9e5521f907 100644 --- a/website/common/script/ops/buy/buyQuestGem.js +++ b/website/common/script/ops/buy/buyQuestGem.js @@ -8,6 +8,7 @@ import content from '../../content/index'; import { errorMessage } from '../../libs/errorMessage'; import { AbstractGemItemOperation } from './abstractBuyOperation'; +import { assembleScheduledMatchers } from '../../content/constants/schedule'; export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // eslint-disable-line import/prefer-default-export, max-len 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); }