diff --git a/website/client/src/components/appFooter.vue b/website/client/src/components/appFooter.vue index d0918e96d6..c652857fde 100644 --- a/website/client/src/components/appFooter.vue +++ b/website/client/src/components/appFooter.vue @@ -812,6 +812,7 @@ import heart from '@/assets/svg/heart.svg'; import { mapState } from '@/libs/store'; import buyGemsModal from './payments/buyGemsModal.vue'; import reportBug from '@/mixins/reportBug.js'; +import { worldStateMixin } from '@/mixins/worldState'; const IS_PRODUCTION = process.env.NODE_ENV === 'production'; // eslint-disable-line no-process-env const ENABLE_TIME_TRAVEL = process.env.ENABLE_TIME_TRAVEL === 'true'; // eslint-disable-line no-process-env @@ -819,7 +820,10 @@ export default { components: { buyGemsModal, }, - mixins: [reportBug], + mixins: [ + reportBug, + worldStateMixin, + ], data () { return { icons: Object.freeze({ @@ -903,6 +907,7 @@ export default { Vue.config.clock.setSystemTime(moment().add(amount, 'days').toDate()); } this.lastTimeJump = response.data.data.time; + this.triggerGetWorldState(true); }, addExp () { // @TODO: Name these variables better diff --git a/website/client/src/components/shops/timeTravelers/index.vue b/website/client/src/components/shops/timeTravelers/index.vue index 58b90322d7..ef6646860c 100644 --- a/website/client/src/components/shops/timeTravelers/index.vue +++ b/website/client/src/components/shops/timeTravelers/index.vue @@ -424,6 +424,7 @@ export default { this.$root.$emit('buyModal::hidden', this.selectedItemToBuy.key); } }); + console.log('setting current event'); this.currentEvent = _find(this.currentEventList, event => Boolean(['winter', 'spring', 'summer', 'fall'].includes(event.season))); }, beforeDestroy () { diff --git a/website/client/src/mixins/seasonalNPC.js b/website/client/src/mixins/seasonalNPC.js index e6640e3b83..830f78ab94 100644 --- a/website/client/src/mixins/seasonalNPC.js +++ b/website/client/src/mixins/seasonalNPC.js @@ -8,6 +8,7 @@ export default { }, methods: { npcClass (name) { + console.log('npcClass', name, this.currentEvent); if (!this.currentEvent || !this.currentEvent.season) return `npc_${name}`; return `npc_${name} npc_${name}_${this.currentEvent.season}`; }, diff --git a/website/client/src/store/actions/worldState.js b/website/client/src/store/actions/worldState.js index 367b9299a8..5192fe97d6 100644 --- a/website/client/src/store/actions/worldState.js +++ b/website/client/src/store/actions/worldState.js @@ -6,6 +6,7 @@ export async function getWorldState (store, options = {}) { path: 'worldState', url: '/api/v4/world-state', deserialize (response) { + console.log(response.data.data); return response.data.data; }, forceLoad: options.forceLoad, diff --git a/website/common/script/content/constants/events.js b/website/common/script/content/constants/events.js index a328cc5ae9..7dc5eb00e0 100644 --- a/website/common/script/content/constants/events.js +++ b/website/common/script/content/constants/events.js @@ -8,6 +8,33 @@ const gemsPromo = { '84gems': 125, }; +export const REPEATING_EVENTS = { + nye: { + start: '1970-12-28T08:00-05:00', + end: '1970-01-04T23:59-05:00', + season: 'nye', + npcImageSuffix: '_nye', + }, + valentines: { + start: '1970-02-13T08:00-05:00', + end: '1970-02-17T23:59-05:00', + season: 'valentines', + npcImageSuffix: '_valentines', + }, + birthday: { + start: '1970-01-30T08:00-05:00', + end: '1970-02-08T23:59-05:00', + season: 'birthday', + npcImageSuffix: '_birthday', + }, + harvestFeast: { + start: '1970-11-22T08:00-05:00', + end: '1970-11-27T20:00-05:00', + season: 'thanksgiving', + npcImageSuffix: '_thanksgiving', + }, +}; + export const EVENTS = { noEvent: { start: '2024-05-01T00:00-04:00', diff --git a/website/common/script/content/constants/index.js b/website/common/script/content/constants/index.js index 624285ec06..18a3ba03fb 100644 --- a/website/common/script/content/constants/index.js +++ b/website/common/script/content/constants/index.js @@ -24,7 +24,7 @@ export const USER_CAN_OWN_QUEST_CATEGORIES = [ 'pet', ]; -export { EVENTS } from './events'; +export { EVENTS, REPEATING_EVENTS } from './events'; export { default as SEASONAL_SETS } from './seasonalSets'; export { default as ANIMAL_COLOR_ACHIEVEMENTS } from './animalColorAchievements'; export { default as ANIMAL_SET_ACHIEVEMENTS } from './animalSetAchievements'; diff --git a/website/common/script/content/constants/schedule.js b/website/common/script/content/constants/schedule.js index d7e93cbe3a..8d47cedceb 100644 --- a/website/common/script/content/constants/schedule.js +++ b/website/common/script/content/constants/schedule.js @@ -627,88 +627,104 @@ export const GALA_KEYS = [ 'fall', ]; export const GALA_SCHEDULE = { - 0: [ - { - type: 'seasonalGear', - items: SEASONAL_SETS.winter, - }, - { - type: 'seasonalSpells', - items: [ - 'snowball', - ], - }, - { - type: 'seasonalQuests', - items: [ - 'evilsanta', - 'evilsanta2', - ], - }, - { - type: 'customizations', - matcher: customizationMatcher([ - 'winteryHairColors', - 'winterySkins', - ]), - }, - ], - 1: [ - { - type: 'seasonalGear', - items: SEASONAL_SETS.spring, - }, - { - type: 'seasonalSpells', - items: [ - 'shinySeed', - ], - }, - { - type: 'customizations', - matcher: customizationMatcher([ - 'shimmerHairColors', - 'pastelSkins', - ]), - }, - ], - 2: [ - { - type: 'seasonalGear', - items: SEASONAL_SETS.summer, - }, - { - type: 'seasonalSpells', - items: [ - 'seafoam', - ], - }, - { - type: 'customizations', - matcher: customizationMatcher([ - 'splashySkins', - ]), - }, - ], - 3: [ - { - type: 'seasonalGear', - items: SEASONAL_SETS.fall, - }, - { - type: 'seasonalSpells', - items: [ - 'spookySparkles', - ], - }, - { - type: 'customizations', - matcher: customizationMatcher([ - 'hauntedHairColors', - 'supernaturalSkins', - ]), - }, - ], + 0: { + startMonth: 11, + endMonth: 1, + filters: [ + { + type: 'seasonalGear', + items: SEASONAL_SETS.winter, + }, + { + type: 'seasonalSpells', + items: [ + 'snowball', + ], + }, + { + type: 'seasonalQuests', + items: [ + 'evilsanta', + 'evilsanta2', + ], + }, + { + type: 'customizations', + matcher: customizationMatcher([ + 'winteryHairColors', + 'winterySkins', + ]), + }, + ], + }, + 1: { + startMonth: 2, + endMonth: 4, + filters: [ + { + type: 'seasonalGear', + items: SEASONAL_SETS.spring, + }, + { + type: 'seasonalSpells', + items: [ + 'shinySeed', + ], + }, + { + type: 'customizations', + matcher: customizationMatcher([ + 'shimmerHairColors', + 'pastelSkins', + ]), + }, + ], + }, + 2: { + startMonth: 5, + endMonth: 7, + filters: [ + { + type: 'seasonalGear', + items: SEASONAL_SETS.summer, + }, + { + type: 'seasonalSpells', + items: [ + 'seafoam', + ], + }, + { + type: 'customizations', + matcher: customizationMatcher([ + 'splashySkins', + ]), + }, + ], + }, + 3: { + startMonth: 8, + endMonth: 10, + filters: [ + { + type: 'seasonalGear', + items: SEASONAL_SETS.fall, + }, + { + type: 'seasonalSpells', + items: [ + 'spookySparkles', + ], + }, + { + type: 'customizations', + matcher: customizationMatcher([ + 'hauntedHairColors', + 'supernaturalSkins', + ]), + }, + ], + }, }; function getDay (date) { @@ -752,17 +768,14 @@ export function assembleScheduledMatchers (date) { } } - items.push(...GALA_SCHEDULE[getGalaIndex(date)]); + items.push(...GALA_SCHEDULE[getGalaIndex(date)].filters); return items; } let cachedScheduleMatchers = null; export function getScheduleMatchingGroup (type, date) { - let checkedDate = date; - if (checkedDate === undefined) { - checkedDate = new Date(); - } + const checkedDate = date || new Date(); if (cacheDate !== null && (getDay(checkedDate) !== getDay(cacheDate) || getMonth(checkedDate) !== getMonth(cacheDate))) { cacheDate = null; @@ -806,3 +819,18 @@ export function getScheduleMatchingGroup (type, date) { export function getCurrentGalaKey (date) { return GALA_KEYS[getGalaIndex(date || new Date())]; } + +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, + start: `${today.getFullYear()}.${gala.startMonth + 1}.${GALA_SWITCHOVER_DAY}`, + end: `${today.getFullYear()}.${gala.endMonth + 1}.${GALA_SWITCHOVER_DAY}`, + }; +} diff --git a/website/server/libs/worldState.js b/website/server/libs/worldState.js index 257ab1879f..525bd07578 100644 --- a/website/server/libs/worldState.js +++ b/website/server/libs/worldState.js @@ -5,6 +5,8 @@ import { // eslint-disable-line import/no-cycle TAVERN_ID as tavernId, } from '../models/group'; import common from '../../common'; +import { REPEATING_EVENTS } from '../../common/script/content/constants'; +import { getCurrentGalaEvent } from '../../common/script/content/constants/schedule'; export async function getWorldBoss () { const tavern = await Group @@ -18,26 +20,32 @@ export async function getWorldBoss () { } export function getCurrentEvent () { - const currEvtKey = Object.keys(common.content.events).find(evtKey => { - const event = common.content.events[evtKey]; + const now = moment(); + const currEvtKey = Object.keys(REPEATING_EVENTS).find(evtKey => { + const event = REPEATING_EVENTS[evtKey]; + const startDate = event.start.replace('1970', now.year()); + const endDate = event.end.replace('1970', now.year()); - const now = moment(); - - return now.isBetween(event.start, event.end); // && Boolean(event.npcImageSuffix); + return now.isBetween(startDate, endDate); }); - if (!currEvtKey) return null; + if (!currEvtKey) { + return getCurrentGalaEvent() + } return { event: currEvtKey, - ...common.content.events[currEvtKey], + ...REPEATING_EVENTS[currEvtKey], }; } export function getCurrentEventList () { - const currentEventKeys = filter(Object.keys(common.content.events), eventKey => { - const eventData = common.content.events[eventKey]; + const now = moment(); + const currentEventKeys = filter(Object.keys(REPEATING_EVENTS), eventKey => { + const eventData = REPEATING_EVENTS[eventKey]; + const startDate = eventData.start.replace('1970', now.year()); + const endDate = eventData.end.replace('1970', now.year()); - return moment().isBetween(eventData.start, eventData.end); + return now.isBetween(startDate, endDate); }); const currentEventList = []; @@ -45,9 +53,12 @@ export function getCurrentEventList () { currentEventKeys.forEach(key => { currentEventList.push({ event: key, - ...common.content.events[key], + ...REPEATING_EVENTS[key], }); }); + currentEventList.push(getCurrentGalaEvent()); + + console.log(currentEventList); return currentEventList; }