add cards to event content cycle

This commit is contained in:
Phillip Thelen
2024-02-21 15:31:45 +01:00
committed by Sabe Jones
parent 249394b4ad
commit 6e96085f99
5 changed files with 42 additions and 5 deletions

View File

@@ -152,6 +152,7 @@ import _map from 'lodash/map';
import _throttle from 'lodash/throttle'; import _throttle from 'lodash/throttle';
import getItemInfo from '@/../../common/script/libs/getItemInfo'; import getItemInfo from '@/../../common/script/libs/getItemInfo';
import shops from '@/../../common/script/libs/shops'; import shops from '@/../../common/script/libs/shops';
import { getScheduleMatchingGroup } from '@/../../common/script/content/constants/schedule';
import { mapState } from '@/libs/store'; import { mapState } from '@/libs/store';
import KeysToKennel from './keysToKennel'; import KeysToKennel from './keysToKennel';
@@ -218,6 +219,7 @@ export default {
hideLocked: false, hideLocked: false,
hidePinned: false, hidePinned: false,
cardMatcher: getScheduleMatchingGroup('cards'),
}; };
}, },
computed: { computed: {
@@ -241,7 +243,8 @@ export default {
categories.push({ categories.push({
identifier: 'cards', identifier: 'cards',
text: this.$t('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), ...getItemInfo(this.user, 'card', value),
showCount: false, showCount: false,
})), })),

View File

@@ -1,4 +1,6 @@
/* eslint-disable key-spacing */ /* eslint-disable key-spacing */
import filter from 'lodash/filter';
import moment from 'moment';
// gem block: number of gems // gem block: number of gems
const gemsPromo = { const gemsPromo = {
@@ -14,12 +16,28 @@ export const REPEATING_EVENTS = {
end: '1970-01-04T23:59-05:00', end: '1970-01-04T23:59-05:00',
season: 'nye', season: 'nye',
npcImageSuffix: '_nye', npcImageSuffix: '_nye',
content: [
{
type: 'cards',
items: [
'nye',
],
},
],
}, },
valentines: { valentines: {
start: '1970-02-13T08:00-05:00', start: '1970-02-13T08:00-05:00',
end: '1970-02-17T23:59-05:00', end: '1970-02-17T23:59-05:00',
season: 'valentines', season: 'valentines',
npcImageSuffix: '_valentines', npcImageSuffix: '_valentines',
content: [
{
type: 'cards',
items: [
'valentine',
],
},
],
}, },
birthday: { birthday: {
start: '1970-01-30T08:00-05:00', 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 = { export const EVENTS = {
noEvent: { noEvent: {
start: '2024-05-01T00:00-04:00', start: '2024-05-01T00:00-04:00',

View File

@@ -1,5 +1,6 @@
import moment from 'moment'; import moment from 'moment';
import SEASONAL_SETS from './seasonalSets'; import SEASONAL_SETS from './seasonalSets';
import { getRepeatingEvents } from './events';
function backgroundMatcher (month1, month2, oddYear) { function backgroundMatcher (month1, month2, oddYear) {
return function call (key) { return function call (key) {
@@ -749,6 +750,9 @@ function getGalaIndex (date) {
if (todayDay >= GALA_SWITCHOVER_DAY) { if (todayDay >= GALA_SWITCHOVER_DAY) {
galaMonth += 1; galaMonth += 1;
} }
if (galaMonth >= 12) {
return 0;
}
return parseInt((galaCount / 12) * galaMonth, 10); return parseInt((galaCount / 12) * galaMonth, 10);
} }
@@ -769,6 +773,11 @@ export function assembleScheduledMatchers (date) {
} }
items.push(...GALA_SCHEDULE[getGalaIndex(date)].filters); items.push(...GALA_SCHEDULE[getGalaIndex(date)].filters);
for (const event in getRepeatingEvents(date)) {
if (event.content) {
items.push(...event.content);
}
}
return items; return items;
} }

View File

@@ -129,7 +129,6 @@ api.cardTypes = {
nye: { nye: {
key: 'nye', key: 'nye',
messageOptions: 5, messageOptions: 5,
yearRound: moment().isBetween(EVENTS.nye2023.start, EVENTS.nye2023.end),
}, },
thankyou: { thankyou: {
key: 'thankyou', key: 'thankyou',
@@ -139,7 +138,6 @@ api.cardTypes = {
valentine: { valentine: {
key: 'valentine', key: 'valentine',
messageOptions: 4, messageOptions: 4,
yearRound: moment().isBetween(EVENTS.valentine2024.start, EVENTS.valentine2024.end),
}, },
birthday: { birthday: {
key: 'birthday', key: 'birthday',

View File

@@ -58,7 +58,5 @@ export function getCurrentEventList () {
}); });
currentEventList.push(getCurrentGalaEvent()); currentEventList.push(getCurrentGalaEvent());
console.log(currentEventList);
return currentEventList; return currentEventList;
} }