mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Implement schedule for quest bundles
This commit is contained in:
committed by
Sabe Jones
parent
b3521be629
commit
f223b5dd2a
@@ -46,17 +46,23 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'ghost_stag',
|
||||
'trex_undead',
|
||||
'harpy',
|
||||
'sabretooth',
|
||||
'dolphin',
|
||||
'nudibranch',
|
||||
'seaserpent',
|
||||
'gryphon',
|
||||
'yarn',
|
||||
'axolotl',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'ruby',
|
||||
'silver',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'winterQuests',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -80,17 +86,22 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'nudibranch',
|
||||
'seaserpent',
|
||||
'gryphon',
|
||||
'yarn',
|
||||
'axolotl',
|
||||
'rooster',
|
||||
'slime',
|
||||
'peacock',
|
||||
'bunny',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'silver',
|
||||
'pinkMarble',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'cuddleBuddies',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -114,16 +125,21 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'rooster',
|
||||
'slime',
|
||||
'peacock',
|
||||
'bunny',
|
||||
'frog',
|
||||
'spider',
|
||||
'cow',
|
||||
'pterodactyl',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'pinkMarble',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'birdBuddies',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -147,15 +163,22 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'frog',
|
||||
'spider',
|
||||
'cow',
|
||||
'pterodactyl',
|
||||
'snake',
|
||||
'monkey',
|
||||
'falcon',
|
||||
'aligator',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'mossyStone',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'hugabug',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -179,16 +202,21 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'snake',
|
||||
'monkey',
|
||||
'falcon',
|
||||
'aligator',
|
||||
'octopus',
|
||||
'horse',
|
||||
'kraken',
|
||||
'sloth',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'mossyStone',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'splashyPals',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -212,15 +240,28 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'octopus',
|
||||
'horse',
|
||||
'kraken',
|
||||
'sloth',
|
||||
'trex',
|
||||
'unicorn',
|
||||
'veolociraptor',
|
||||
'hippo',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'turquiose',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'rockingReptiles',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'delightfulDinos',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -244,16 +285,28 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'trex',
|
||||
'unicorn',
|
||||
'veolociraptor',
|
||||
'hippo',
|
||||
'whale',
|
||||
'seahorse',
|
||||
'armadillo',
|
||||
'guineapig',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'turquiose',
|
||||
'fluorite',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'winterQuests',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'aquaticAmigos',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -277,16 +330,22 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'whale',
|
||||
'seahorse',
|
||||
'armadillo',
|
||||
'guineapig',
|
||||
'turtle',
|
||||
'penguin',
|
||||
'butterfly',
|
||||
'cheetah',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'fluorite',
|
||||
'blackPearl',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'featheredFriends',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -310,16 +369,22 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'turtle',
|
||||
'penguin',
|
||||
'butterfly',
|
||||
'cheetah',
|
||||
'squirrel',
|
||||
'triceratops',
|
||||
'treeling',
|
||||
'beetle',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'blackPearl',
|
||||
'bronze',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'farmFriends',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -343,16 +408,22 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'squirrel',
|
||||
'triceratops',
|
||||
'treeling',
|
||||
'beetle',
|
||||
'snail',
|
||||
'rock',
|
||||
'ferret',
|
||||
'hedgehog',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'bronze',
|
||||
'onyx',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'witchyFamiliars',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -376,16 +447,23 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'snail',
|
||||
'rock',
|
||||
'ferret',
|
||||
'hedgehog',
|
||||
'sheep',
|
||||
'kangaroo',
|
||||
'owl',
|
||||
'rat',
|
||||
'badger',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'onyx',
|
||||
'amber',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'bundles',
|
||||
matcher: inListMatcher([
|
||||
'forestFriends',
|
||||
]),
|
||||
},
|
||||
],
|
||||
@@ -409,17 +487,17 @@ export const MONTHLY_SCHEDULE = {
|
||||
{
|
||||
type: 'petQuests',
|
||||
matcher: inListMatcher([
|
||||
'sheep',
|
||||
'kangaroo',
|
||||
'owl',
|
||||
'rat',
|
||||
'badger',
|
||||
'ghost_stag',
|
||||
'trex_undead',
|
||||
'harpy',
|
||||
'sabretooth',
|
||||
'dolphin',
|
||||
]),
|
||||
},
|
||||
{
|
||||
type: 'hatchingPotionQuests',
|
||||
matcher: inListMatcher([
|
||||
'amber',
|
||||
'ruby',
|
||||
]),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -53,6 +53,7 @@ export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // esli
|
||||
}
|
||||
|
||||
const matchers = assembleScheduledMatchers(new Date()).filter(matcher => matcher.type === `${item.category}Quests`).map(matcher => matcher.matcher);
|
||||
console.log(item, matchers);
|
||||
if (matchers.length && !matchers.some(matcher => matcher(item.key))) {
|
||||
throw new NotAuthorized(this.i18n('notAvailable', { key: item.key }));
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import { removeItemByPath } from '../pinnedGearUtils';
|
||||
import getItemInfo from '../../libs/getItemInfo';
|
||||
import updateUserBalance from '../updateUserBalance';
|
||||
import { assembleScheduledMatchers } from '../../content/constants/schedule';
|
||||
|
||||
function getItemAndPrice (user, type, key, req) {
|
||||
let item;
|
||||
@@ -54,6 +55,10 @@ async function purchaseItem (user, item, price, type, key) {
|
||||
if (user.markModified) user.markModified('items.gear.owned');
|
||||
} else if (type === 'bundles') {
|
||||
const subType = item.type;
|
||||
const matchers = assembleScheduledMatchers(new Date()).filter(matcher => matcher.type === 'bundles').map(matcher => matcher.matcher);
|
||||
if (matchers.length && !matchers.some(matcher => matcher(item.key))) {
|
||||
throw new NotAuthorized(i18n.t('notAvailable', { key: item.key }));
|
||||
}
|
||||
forEach(item.bundleKeys, bundledKey => {
|
||||
if (!user.items[subType][bundledKey] || user.items[subType][bundledKey] < 0) {
|
||||
user.items[subType][bundledKey] = 0;
|
||||
|
||||
Reference in New Issue
Block a user