Implement schedule for quest bundles

This commit is contained in:
Phillip Thelen
2024-01-31 18:06:50 +01:00
committed by Sabe Jones
parent b3521be629
commit f223b5dd2a
4 changed files with 151 additions and 63 deletions

View File

@@ -265,14 +265,18 @@ shops.getQuestShopCategories = function getQuestShopCategories (user, language)
* ]
*
*/
const scheduledMatchers = assembleScheduledMatchers(new Date());
const bundleCategory = {
identifier: 'bundle',
text: i18n.t('questBundles', language),
};
const bundleMatchers = scheduledMatchers.filter(matcher => matcher.type === 'bundles').map(matcher => matcher.matcher);
console.log(bundleMatchers);
bundleCategory.items = sortBy(values(content.bundles)
.filter(bundle => bundle.type === 'quests' && bundle.canBuy())
.filter(bundle => bundle.type === 'quests'
&& bundleMatchers.map(matcher => matcher(bundle.key)).every(matcher => matcher === true))
.map(bundle => getItemInfo(user, 'bundles', bundle, officialPinnedItems, language)));
if (bundleCategory.items.length > 0) {
@@ -289,7 +293,7 @@ shops.getQuestShopCategories = function getQuestShopCategories (user, language)
.filter(quest => quest.canBuy(user) && quest.category === type);
if (type === 'pet' || type === 'hatchingPotion') {
const matchers = assembleScheduledMatchers(new Date())
const matchers = scheduledMatchers
.filter(matcher => matcher.type === `${type}Quests`).map(matcher => matcher.matcher);
filteredQuests = filteredQuests.filter(quest => matchers.map(matcher => matcher(quest.key))
.every(matcher => matcher === true));