mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
add cards to event content cycle
This commit is contained in:
committed by
Sabe Jones
parent
249394b4ad
commit
6e96085f99
@@ -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,
|
||||
})),
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -58,7 +58,5 @@ export function getCurrentEventList () {
|
||||
});
|
||||
|
||||
currentEventList.push(getCurrentGalaEvent());
|
||||
|
||||
console.log(currentEventList);
|
||||
return currentEventList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user