diff --git a/website/client/src/components/shops/market/index.vue b/website/client/src/components/shops/market/index.vue index 7235ec8d4e..dae59eca2b 100644 --- a/website/client/src/components/shops/market/index.vue +++ b/website/client/src/components/shops/market/index.vue @@ -152,6 +152,7 @@ import _map from 'lodash/map'; import _throttle from 'lodash/throttle'; import getItemInfo from '@/../../common/script/libs/getItemInfo'; import shops from '@/../../common/script/libs/shops'; +import { getScheduleMatchingGroup } from '@/../../common/script/content/constants/schedule'; import { mapState } from '@/libs/store'; import KeysToKennel from './keysToKennel'; @@ -218,6 +219,7 @@ export default { hideLocked: false, hidePinned: false, + cardMatcher: getScheduleMatchingGroup('cards'), }; }, computed: { @@ -241,7 +243,8 @@ export default { categories.push({ identifier: 'cards', text: this.$t('cards'), - items: _map(_filter(this.content.cardTypes, value => value.yearRound), value => ({ + items: _map(_filter(this.content.cardTypes, value => value.yearRound + || this.cardMatcher.items.indexOf(value.key) !== -1), value => ({ ...getItemInfo(this.user, 'card', value), showCount: false, })), diff --git a/website/common/script/content/constants/events.js b/website/common/script/content/constants/events.js index 7dc5eb00e0..a5cba04539 100644 --- a/website/common/script/content/constants/events.js +++ b/website/common/script/content/constants/events.js @@ -1,4 +1,6 @@ /* eslint-disable key-spacing */ +import filter from 'lodash/filter'; +import moment from 'moment'; // gem block: number of gems const gemsPromo = { @@ -14,12 +16,28 @@ export const REPEATING_EVENTS = { end: '1970-01-04T23:59-05:00', season: 'nye', npcImageSuffix: '_nye', + content: [ + { + type: 'cards', + items: [ + 'nye', + ], + }, + ], }, valentines: { start: '1970-02-13T08:00-05:00', end: '1970-02-17T23:59-05:00', season: 'valentines', npcImageSuffix: '_valentines', + content: [ + { + type: 'cards', + items: [ + 'valentine', + ], + }, + ], }, birthday: { start: '1970-01-30T08:00-05:00', @@ -35,6 +53,17 @@ export const REPEATING_EVENTS = { }, }; +export function getRepeatingEvents (date) { + const momentDate = date instanceof moment ? date : moment(date); + return filter(Object.keys(REPEATING_EVENTS), eventKey => { + const eventData = REPEATING_EVENTS[eventKey]; + const startDate = eventData.start.replace('1970', momentDate.year()); + const endDate = eventData.end.replace('1970', momentDate.year()); + + return momentDate.isBetween(startDate, endDate); + }); +} + export const EVENTS = { noEvent: { start: '2024-05-01T00:00-04:00', diff --git a/website/common/script/content/constants/schedule.js b/website/common/script/content/constants/schedule.js index 8d47cedceb..fb90846f6f 100644 --- a/website/common/script/content/constants/schedule.js +++ b/website/common/script/content/constants/schedule.js @@ -1,5 +1,6 @@ import moment from 'moment'; import SEASONAL_SETS from './seasonalSets'; +import { getRepeatingEvents } from './events'; function backgroundMatcher (month1, month2, oddYear) { return function call (key) { @@ -749,6 +750,9 @@ function getGalaIndex (date) { if (todayDay >= GALA_SWITCHOVER_DAY) { galaMonth += 1; } + if (galaMonth >= 12) { + return 0; + } return parseInt((galaCount / 12) * galaMonth, 10); } @@ -769,6 +773,11 @@ export function assembleScheduledMatchers (date) { } items.push(...GALA_SCHEDULE[getGalaIndex(date)].filters); + for (const event in getRepeatingEvents(date)) { + if (event.content) { + items.push(...event.content); + } + } return items; } diff --git a/website/common/script/content/index.js b/website/common/script/content/index.js index 2d1793ab7f..559caf82d7 100644 --- a/website/common/script/content/index.js +++ b/website/common/script/content/index.js @@ -129,7 +129,6 @@ api.cardTypes = { nye: { key: 'nye', messageOptions: 5, - yearRound: moment().isBetween(EVENTS.nye2023.start, EVENTS.nye2023.end), }, thankyou: { key: 'thankyou', @@ -139,7 +138,6 @@ api.cardTypes = { valentine: { key: 'valentine', messageOptions: 4, - yearRound: moment().isBetween(EVENTS.valentine2024.start, EVENTS.valentine2024.end), }, birthday: { key: 'birthday', diff --git a/website/server/libs/worldState.js b/website/server/libs/worldState.js index 525bd07578..93901ada92 100644 --- a/website/server/libs/worldState.js +++ b/website/server/libs/worldState.js @@ -58,7 +58,5 @@ export function getCurrentEventList () { }); currentEventList.push(getCurrentGalaEvent()); - - console.log(currentEventList); return currentEventList; }