habitica/website/common/script/content/constants/schedule.js

956 lines
19 KiB
JavaScript
Raw Normal View History

import moment from 'moment';
import nconf from 'nconf';
2024-01-31 21:52:44 +00:00
import SEASONAL_SETS from './seasonalSets';
2024-02-21 14:31:45 +00:00
import { getRepeatingEvents } from './events';
function isAfterNewSchedule (year, month) {
if (year >= 2025) {
return true;
} if (year === 2024) {
return month >= 6;
}
return false;
}
function backgroundMatcher (month1, month2, oddYear) {
return function call (key, date) {
const keyLength = key.length;
const month = parseInt(key.substring(keyLength - 6, keyLength - 4), 10);
const year = parseInt(key.substring(keyLength - 4, keyLength), 10);
if (isAfterNewSchedule(year, month)) {
return month === month1 && date.getFullYear() >= year && (date.getMonth() + 1) >= month;
}
return (month === month1 || month === month2) && year % 2 === (oddYear ? 1 : 0);
};
}
function timeTravelersMatcher (month1, month2) {
return function call (item, date) {
const month = parseInt(item.substring(4, 6), 10);
const year = parseInt(item.substring(0, 4), 10);
if (date.getFullYear() === year && (date.getMonth() + 1) >= month) {
return false;
}
return month === month1 || month === month2;
};
}
function inListMatcher (list) {
return function call (item) {
return list.indexOf(item) !== -1;
};
}
2024-04-23 15:50:45 +00:00
export const ALWAYS_AVAILABLE_CUSTOMIZATIONS = [
2024-02-01 14:06:32 +00:00
'animalSkins',
'rainbowSkins',
'rainbowHairColors',
'specialShirts',
'facialHair',
'baseHair1',
'baseHair2',
'baseHair3',
];
function customizationMatcher (list) {
return function call (item) {
if (ALWAYS_AVAILABLE_CUSTOMIZATIONS.indexOf(item) !== -1) {
return true;
}
return list.indexOf(item) !== -1;
};
}
export const FIRST_RELEASE_DAY = 1;
export const SECOND_RELEASE_DAY = 7;
export const THIRD_RELEASE_DAY = 14;
export const FOURTH_RELEASE_DAY = 21;
export const MONTHLY_SCHEDULE = {
2024-04-26 10:18:26 +00:00
// January
0: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(1, 7),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(1, 7, false),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'nudibranch',
'seaserpent',
'gryphon',
'yarn',
'axolotl',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-01-31 17:06:50 +00:00
'silver',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'winterQuests',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Aurora',
2024-04-08 16:18:44 +00:00
'Cupid',
'IcySnow',
],
},
],
},
2024-04-26 10:18:26 +00:00
// February
1: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(2, 8),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(2, 8, false),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'rooster',
'slime',
'peacock',
'bunny',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-01-31 17:06:50 +00:00
'pinkMarble',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'cuddleBuddies',
2024-04-22 09:47:34 +00:00
'mythicalMarvels',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'PolkaDot',
2024-04-08 16:18:44 +00:00
'Celestial',
'RoseGold',
],
},
],
},
2024-04-26 10:18:26 +00:00
// March
2: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(3, 9),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(3, 9, false),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'frog',
'spider',
'cow',
'pterodactyl',
],
},
{
type: 'hatchingPotionQuests',
items: [
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'birdBuddies',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'StainedGlass',
'Porcelain',
],
},
],
},
2024-04-26 10:18:26 +00:00
// April
3: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(4, 10),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(4, 10, false),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'snake',
'monkey',
'falcon',
'alligator',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-04-24 14:31:09 +00:00
'stone',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'hugabug',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Shimmer',
'Glass',
],
},
],
},
2024-04-26 10:18:26 +00:00
// May
4: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(5, 11),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(5, 11, false),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'octopus',
'horse',
'kraken',
'sloth',
],
},
{
type: 'hatchingPotionQuests',
items: [
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'splashyPals',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Floral',
'Fairy',
'RoseQuartz',
],
},
],
},
2024-04-26 10:18:26 +00:00
// June
5: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(6, 12),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(6, 12, false),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'trex',
'unicorn',
2024-04-24 14:31:09 +00:00
'velociraptor',
2024-01-31 17:06:50 +00:00
'hippo',
2024-05-08 00:36:39 +00:00
'giraffe',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-04-24 14:31:09 +00:00
'turquoise',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'delightfulDinos',
2024-04-22 09:47:34 +00:00
'sandySidekicks',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Rainbow',
'Sunshine',
2024-05-13 12:49:39 +00:00
'Koi',
],
},
],
},
2024-04-26 10:18:26 +00:00
// July
6: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(7, 1),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(7, 1, true),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'whale',
2024-04-22 09:47:34 +00:00
'dilatory_derby',
2024-01-31 17:06:50 +00:00
'armadillo',
'guineapig',
Squashed commit of the following: commit 28193f86fb7ed6647fb5e1c6469f71a9bb980c38 Author: Phillip Thelen <phillip@habitica.com> Date: Fri Jun 21 11:12:18 2024 +0200 Fix serving memoized content commit 877fe482252db78b69050b13274da147ede23769 Author: Phillip Thelen <phillip@habitica.com> Date: Thu Jun 20 12:23:24 2024 +0200 correctly memoize conent api commit e0f6f79c5b49d2b6eae7e5c02dd90ac7ad6ea397 Author: Phillip Thelen <phillip@habitica.com> Date: Thu Jun 20 10:11:27 2024 +0200 don’t build multiple times on heroku commit f62254d68e2859990a6e80cd5b64d3385a6dea60 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 19:40:20 2024 +0200 fix client command commit d054e6fc1650fbe6df14b62025f0470a15e91883 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 19:36:57 2024 +0200 correct build call commit 7231f699c1e9cc4fc873428863cff0c14a4b6b3f Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 19:32:32 2024 +0200 try setting up with heroku buildpack commit 1dae0793fde402e15c9e2eba2b21df999933282f Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:50:32 2024 +0200 call gulp build:prod commit f18fbe86b61fa282baf38196313fe07837b173cc Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:40:53 2024 +0200 build client commit 61a61724cae017aaaf912c037796bd2e5064ec87 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:33:18 2024 +0200 testing commit 93cf30eb184a74f85751750ab6e5033db3d2fafa Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:20:25 2024 +0200 integration fix commit cff08adcd0290907281e5db873b9087d7de83e26 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:13:20 2024 +0200 specify dev docker file commit 4da2ed4a1f8d017ad3b6ac4e869746e7beaea419 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:10:07 2024 +0200 initialize stub commit 11c5b26c594254083fa260a1d0920242d67e23b7 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:08:45 2024 +0200 test heroku file commit ac85bb2e2da846b069826a621e975a710038313d Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:03:15 2024 +0200 fix stub reference commit 74dfb2710ff1b246d788d729149062f6f0b77787 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 18:01:27 2024 +0200 test fixes commit 8dbd3c3db15aac5c3defd294b6c6613cf80136da Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 17:37:04 2024 +0200 fix canOwn test commit 74b3b348ff6901e889ef88fd7531d6800d12ab1a Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 17:32:31 2024 +0200 fix buy test commit 3386d61fdee32e79a6a53939f22e26d3942eaa7f Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 17:30:37 2024 +0200 fix debug tests commit 19da14531ca64a18dd68cefe1ada3f2ed1066622 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 17:05:25 2024 +0200 add chameleon to featured quests commit 254dd80f2479086637c7cafa9522cf6155b3868f Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 17:05:14 2024 +0200 fix import commit 0bc3f16b4b03f88cc5c78fad5aa8d38cfdb9324b Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 16:33:22 2024 +0200 add new content to new release file commit 5184973bd50fb1f4bf17ab054aa7a5836086a5e1 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 16:33:11 2024 +0200 fix release date tests commit b6accca5cae1bbb33c450e4462095113cfebe480 Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 16:33:06 2024 +0200 fix armoire tests commit fec68e621147e31c6ba5370ce0126d7e9b86461c Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 19 16:02:03 2024 +0200 fix tests commit fc63c906ddf4956fbe40543b66cb65cf570de36b Author: Phillip Thelen <phillip@habitica.com> Date: Mon Jun 10 14:44:21 2024 +0200 Improve test coverage commit 3333f8f0f59d0a69fcd715ee3f690518f7a710b5 Author: Phillip Thelen <phillip@habitica.com> Date: Mon Jun 10 14:24:59 2024 +0200 allow hatching potions to have a release date commit 89a3ac3ddebf8e949f584c39092e0cc961cde04a Author: Phillip Thelen <phillip@habitica.com> Date: Mon Jun 10 14:11:38 2024 +0200 allow eggs to have a release date # Conflicts: # test/content/armoire.test.js commit 16551ec83fdcb3e6bb31e4665588c83aa5af42ba Merge: f5f4974a73 2645bf6023 Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Jun 18 15:03:12 2024 -0400 Merge branch '2024-07-content-prebuild' into subs-private commit 2645bf60239a838d5a506f69ca7c8ce38042bf25 Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Jun 18 15:02:47 2024 -0400 update habitica images commit f5f4974a733fc3ebad1dd5da77bb44b48e91b7cc Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Jun 18 14:58:13 2024 -0400 update habitica-images commit 162e337d14a372f523fbf9903bdddd23142e0d79 Merge: f2506c3231 21a7d36b7b Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Jun 18 13:46:03 2024 -0400 Merge branch '2024-07-content-prebuild' into subs-private commit 21a7d36b7ba1d86e30b60e25d778b01062ed11ba Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Jun 18 13:45:09 2024 -0400 update sprites commit f2506c32316df6836ee19489320b289f4dc97a35 Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Jun 18 13:24:21 2024 -0400 updated sprites css commit d47641e25a6dfb9b62f1c10d810e80eb0990ea20 Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Jun 18 12:46:59 2024 -0400 typo fix commit fb8479ad1e887b7f94dd6eec47980d4da593bee9 Author: CuriousMagpie <eilatan@gmail.com> Date: Mon Jun 17 13:44:36 2024 -0400 finish July prebuild commit 3810cf3ef3c492bda8d343596bf1a17f9fc1e36e Author: CuriousMagpie <eilatan@gmail.com> Date: Fri Jun 14 10:42:47 2024 -0400 add chameleon quest commit d05da3722ce1d86a840d6f73b4ef78309c84a2f6 Author: CuriousMagpie <eilatan@gmail.com> Date: Thu Jun 13 17:12:43 2024 -0400 add June background notes commit b8a3440ef2fd0bf26e1305e749bcefab2c446d84 Author: CuriousMagpie <eilatan@gmail.com> Date: Thu Jun 13 16:40:04 2024 -0400 fix mystery item and background description commit 44d63032d81ac58aded8c4c856df7fe5d89f5ef4 Author: CuriousMagpie <eilatan@gmail.com> Date: Thu Jun 13 15:38:23 2024 -0400 add subscriber gear, enchanted armoire, and background commit 9d7da91ec60d84b7ec8f1792f2601bcc863c5a31 Author: CuriousMagpie <eilatan@gmail.com> Date: Thu Jun 13 14:44:59 2024 -0400 add sprites
2024-06-28 14:49:08 +00:00
'chameleon',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-01-31 17:06:50 +00:00
'fluorite',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'aquaticAmigos',
2024-04-22 09:47:34 +00:00
'jungleBuddies',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
2024-04-08 16:18:44 +00:00
'Moonglow',
'Watery',
],
},
],
},
2024-04-26 10:18:26 +00:00
// August
7: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(8, 2),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(8, 2, true),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'turtle',
'penguin',
'butterfly',
'cheetah',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-01-31 17:06:50 +00:00
'blackPearl',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'featheredFriends',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Aquatic',
'StarryNight',
'Sunset',
],
},
],
},
2024-04-26 10:18:26 +00:00
// September
8: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(9, 3),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(9, 3, true),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'squirrel',
'triceratops',
'treeling',
'beetle',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-01-31 17:06:50 +00:00
'bronze',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'farmFriends',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Glow',
'AutumnLeaf',
'Shadow',
],
},
],
},
2024-04-26 10:18:26 +00:00
// October
9: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(10, 4),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(10, 4, true),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'snail',
'rock',
'ferret',
'hedgehog',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-01-31 17:06:50 +00:00
'onyx',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'witchyFamiliars',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Vampire',
'Ghost',
'Spooky',
],
},
],
},
2024-04-26 10:18:26 +00:00
// November
10: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(11, 5),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(11, 5, true),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'sheep',
'kangaroo',
'owl',
'rat',
'badger',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-01-31 17:06:50 +00:00
'amber',
],
2024-01-31 17:06:50 +00:00
},
{
type: 'bundles',
items: [
2024-01-31 17:06:50 +00:00
'forestFriends',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Ember',
'Frost',
'Thunderstorm',
],
},
],
},
2024-04-26 10:18:26 +00:00
// December
11: {
[FIRST_RELEASE_DAY]: [
{
type: 'timeTravelers',
matcher: timeTravelersMatcher(12, 6),
},
],
[SECOND_RELEASE_DAY]: [
{
type: 'backgrounds',
matcher: backgroundMatcher(12, 6, true),
},
],
[THIRD_RELEASE_DAY]: [
{
type: 'petQuests',
items: [
2024-01-31 17:06:50 +00:00
'ghost_stag',
'trex_undead',
'harpy',
'sabretooth',
'dolphin',
],
},
{
type: 'hatchingPotionQuests',
items: [
2024-01-31 17:06:50 +00:00
'ruby',
],
},
2024-04-22 09:47:34 +00:00
{
type: 'bundles',
items: [
'rockingReptiles',
],
},
],
[FOURTH_RELEASE_DAY]: [
{
type: 'premiumHatchingPotions',
items: [
'Peppermint',
'Holly',
],
},
],
},
};
export const GALA_SWITCHOVER_DAY = 21;
2024-02-01 14:06:32 +00:00
export const GALA_KEYS = [
'winter',
'spring',
'summer',
'fall',
];
export const GALA_SCHEDULE = {
2024-04-26 10:18:26 +00:00
// Winter
2024-02-15 15:14:42 +00:00
0: {
startMonth: 11,
2024-04-26 11:03:34 +00:00
endMonth: 2,
matchers: [
2024-02-15 15:14:42 +00:00
{
type: 'seasonalGear',
items: SEASONAL_SETS.winter,
},
{
type: 'seasonalSpells',
items: [
'snowball',
],
},
{
type: 'seasonalQuests',
items: [
'evilsanta',
'evilsanta2',
],
},
{
type: 'customizations',
matcher: customizationMatcher([
'winteryHairColors',
'winterySkins',
]),
},
],
},
2024-04-26 10:18:26 +00:00
// Spring
2024-02-15 15:14:42 +00:00
1: {
startMonth: 2,
2024-04-26 11:03:34 +00:00
endMonth: 5,
matchers: [
2024-02-15 15:14:42 +00:00
{
type: 'seasonalGear',
items: SEASONAL_SETS.spring,
},
{
type: 'seasonalSpells',
items: [
'shinySeed',
],
},
{
type: 'seasonalQuests',
items: [
'egg',
],
},
2024-02-15 15:14:42 +00:00
{
type: 'customizations',
matcher: customizationMatcher([
'shimmerHairColors',
'pastelSkins',
]),
},
],
},
2024-04-26 10:18:26 +00:00
// Summer
2024-02-15 15:14:42 +00:00
2: {
startMonth: 5,
2024-04-26 11:03:34 +00:00
endMonth: 8,
matchers: [
2024-02-15 15:14:42 +00:00
{
type: 'seasonalGear',
items: SEASONAL_SETS.summer,
},
{
type: 'seasonalSpells',
items: [
'seafoam',
],
},
{
type: 'seasonalQuests',
items: [
],
},
2024-02-15 15:14:42 +00:00
{
type: 'customizations',
matcher: customizationMatcher([
2024-05-08 00:36:39 +00:00
'summerHairColors',
2024-02-15 15:14:42 +00:00
'splashySkins',
]),
},
],
},
2024-04-26 10:18:26 +00:00
// Fall
2024-02-15 15:14:42 +00:00
3: {
startMonth: 8,
2024-04-26 11:03:34 +00:00
endMonth: 11,
matchers: [
2024-02-15 15:14:42 +00:00
{
type: 'seasonalGear',
items: SEASONAL_SETS.fall,
},
{
type: 'seasonalSpells',
items: [
'spookySparkles',
],
},
{
type: 'seasonalQuests',
items: [
],
},
2024-02-15 15:14:42 +00:00
{
type: 'customizations',
matcher: customizationMatcher([
'hauntedHairColors',
'supernaturalSkins',
]),
},
],
},
};
const SWITCHOVER_TIME = nconf.get('CONTENT_SWITCHOVER_TIME_OFFSET') || process.env.CONTENT_SWITCHOVER_TIME_OFFSET || 0;
export const TYPE_SCHEDULE = {
timeTravelers: FIRST_RELEASE_DAY,
backgrounds: SECOND_RELEASE_DAY,
petQuests: THIRD_RELEASE_DAY,
hatchingPotionQuests: THIRD_RELEASE_DAY,
bundles: THIRD_RELEASE_DAY,
premiumHatchingPotions: FOURTH_RELEASE_DAY,
seasonalGear: GALA_SWITCHOVER_DAY,
seasonalSpells: GALA_SWITCHOVER_DAY,
seasonalQuests: GALA_SWITCHOVER_DAY,
customizations: GALA_SWITCHOVER_DAY,
};
2024-02-15 14:07:19 +00:00
function getDay (date) {
if (date === undefined) {
return 0;
}
const checkDate = new Date(date.getTime());
checkDate.setHours(checkDate.getHours() - SWITCHOVER_TIME);
return checkDate.getDate();
2024-02-15 14:07:19 +00:00
}
function getMonth (date) {
if (date === undefined) {
return 0;
}
return date instanceof moment ? date.month() : date.getMonth();
}
2024-02-01 14:06:32 +00:00
function getGalaIndex (date) {
const month = getMonth(date);
const todayDay = getDay(date);
2024-02-01 14:06:32 +00:00
let galaMonth = month;
const galaCount = Object.keys(GALA_SCHEDULE).length;
if (todayDay >= GALA_SWITCHOVER_DAY) {
galaMonth += 1;
}
2024-02-21 14:31:45 +00:00
if (galaMonth >= 12) {
return 0;
}
2024-02-01 14:06:32 +00:00
return parseInt((galaCount / 12) * galaMonth, 10);
}
export function assembleScheduledMatchers (date) {
const items = [];
const month = getMonth(date);
const todayDay = getDay(date);
const previousMonth = month === 0 ? 11 : month - 1;
for (const [day, value] of Object.entries(MONTHLY_SCHEDULE[previousMonth])) {
if (day > todayDay) {
items.push(...value);
}
}
for (const [day, value] of Object.entries(MONTHLY_SCHEDULE[month])) {
if (day <= todayDay) {
items.push(...value);
}
}
2024-04-26 11:03:34 +00:00
const gala = GALA_SCHEDULE[getGalaIndex(date)];
const galaMatchers = gala.matchers;
galaMatchers.forEach(matcher => {
matcher.endMonth = gala.endMonth;
});
items.push(...galaMatchers);
2024-05-08 15:42:40 +00:00
getRepeatingEvents(date).forEach(event => {
2024-02-21 14:31:45 +00:00
if (event.content) {
items.push(...event.content);
}
2024-05-08 15:42:40 +00:00
});
return items;
}
2024-01-31 21:52:44 +00:00
let cachedScheduleMatchers = null;
2024-04-02 17:14:53 +00:00
let cacheDate = null;
2024-01-31 21:52:44 +00:00
function makeMatcherClass (date) {
2024-03-06 11:02:38 +00:00
return {
matchers: [],
end: new Date(),
2024-03-06 11:02:38 +00:00
items: [],
matchingDate: date,
2024-03-06 11:02:38 +00:00
match (key) {
if (this.matchers.length === 0) {
if (this.items.length > 0) {
return inListMatcher(this.items)(key, this.matchingDate);
2024-03-06 11:02:38 +00:00
}
} else {
if (this.items.length > 0 && !inListMatcher(this.items)(key, this.matchingDate)) {
2024-03-06 11:02:38 +00:00
return false;
}
return this.matchers.every(m => m(key, this.matchingDate));
2024-03-06 11:02:38 +00:00
}
return false;
},
};
}
2024-04-26 11:15:30 +00:00
function makeEndDate (checkedDate, matcher) {
let end = moment.utc(checkedDate);
2024-04-26 11:03:34 +00:00
end.date(TYPE_SCHEDULE[matcher.type]);
end.hour(SWITCHOVER_TIME);
2024-05-07 13:17:22 +00:00
end.minute(0);
end.second(0);
2024-04-26 11:03:34 +00:00
if (matcher.endMonth !== undefined) {
end.month(matcher.endMonth);
2024-05-07 13:17:22 +00:00
} else if (end.date() <= checkedDate.getDate()) {
2024-04-26 11:03:34 +00:00
end = moment(end).add(1, 'months');
}
return end.toDate();
}
2024-05-07 13:17:22 +00:00
export function clearCachedMatchers () {
cacheDate = null;
cachedScheduleMatchers = null;
}
export function getAllScheduleMatchingGroups (date) {
2024-02-15 15:14:42 +00:00
const checkedDate = date || new Date();
2024-02-15 14:07:19 +00:00
if (cacheDate !== null && (getDay(checkedDate) !== getDay(cacheDate)
|| getMonth(checkedDate) !== getMonth(cacheDate))) {
// Clear cached matchers, since they are old
2024-05-07 13:17:22 +00:00
clearCachedMatchers();
2024-02-15 14:07:19 +00:00
}
2024-01-31 21:52:44 +00:00
if (!cachedScheduleMatchers) {
// No matchers exist, make new ones
2024-02-15 14:07:19 +00:00
cacheDate = new Date();
2024-04-02 17:14:53 +00:00
cachedScheduleMatchers = {};
2024-02-15 14:07:19 +00:00
assembleScheduledMatchers(checkedDate).forEach(matcher => {
2024-04-02 17:14:53 +00:00
if (!cachedScheduleMatchers[matcher.type]) {
2024-05-03 09:12:00 +00:00
cachedScheduleMatchers[matcher.type] = makeMatcherClass(checkedDate);
2024-01-31 21:52:44 +00:00
}
2024-04-26 11:03:34 +00:00
cachedScheduleMatchers[matcher.type].end = makeEndDate(checkedDate, matcher);
if (matcher.matcher instanceof Function) {
cachedScheduleMatchers[matcher.type].matchers.push(matcher.matcher);
} else if (matcher.items instanceof Array) {
cachedScheduleMatchers[matcher.type].items.push(...matcher.items);
}
2024-01-31 21:52:44 +00:00
});
}
2024-04-26 10:04:18 +00:00
return cachedScheduleMatchers;
}
export function getScheduleMatchingGroup (type, date) {
const matchingGroups = getAllScheduleMatchingGroups(date);
if (!matchingGroups[type]) {
// No matchers exist for this type
return {
items: [],
match () {
return true;
},
};
}
return matchingGroups[type];
2024-01-31 21:52:44 +00:00
}
2024-02-01 14:06:32 +00:00
export function getCurrentGalaKey (date) {
return GALA_KEYS[getGalaIndex(date || new Date())];
}
2024-02-15 15:14:42 +00:00
export function getCurrentGalaEvent (date) {
const checkedDate = date || new Date();
const index = getGalaIndex(checkedDate);
const key = GALA_KEYS[index];
const gala = GALA_SCHEDULE[index];
const today = new Date();
return {
event: key,
npcImageSuffix: `_${key}`,
season: key,
2024-05-06 09:53:12 +00:00
gear: true,
2024-02-15 15:14:42 +00:00
start: `${today.getFullYear()}.${gala.startMonth + 1}.${GALA_SWITCHOVER_DAY}`,
end: `${today.getFullYear()}.${gala.endMonth + 1}.${GALA_SWITCHOVER_DAY}`,
};
}