Implement events throughout the year

This commit is contained in:
Phillip Thelen
2024-02-15 16:14:42 +01:00
committed by Sabe Jones
parent 2a84561e00
commit 249394b4ad
8 changed files with 174 additions and 100 deletions

View File

@@ -812,6 +812,7 @@ import heart from '@/assets/svg/heart.svg';
import { mapState } from '@/libs/store'; import { mapState } from '@/libs/store';
import buyGemsModal from './payments/buyGemsModal.vue'; import buyGemsModal from './payments/buyGemsModal.vue';
import reportBug from '@/mixins/reportBug.js'; 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 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 const ENABLE_TIME_TRAVEL = process.env.ENABLE_TIME_TRAVEL === 'true'; // eslint-disable-line no-process-env
@@ -819,7 +820,10 @@ export default {
components: { components: {
buyGemsModal, buyGemsModal,
}, },
mixins: [reportBug], mixins: [
reportBug,
worldStateMixin,
],
data () { data () {
return { return {
icons: Object.freeze({ icons: Object.freeze({
@@ -903,6 +907,7 @@ export default {
Vue.config.clock.setSystemTime(moment().add(amount, 'days').toDate()); Vue.config.clock.setSystemTime(moment().add(amount, 'days').toDate());
} }
this.lastTimeJump = response.data.data.time; this.lastTimeJump = response.data.data.time;
this.triggerGetWorldState(true);
}, },
addExp () { addExp () {
// @TODO: Name these variables better // @TODO: Name these variables better

View File

@@ -424,6 +424,7 @@ export default {
this.$root.$emit('buyModal::hidden', this.selectedItemToBuy.key); 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))); this.currentEvent = _find(this.currentEventList, event => Boolean(['winter', 'spring', 'summer', 'fall'].includes(event.season)));
}, },
beforeDestroy () { beforeDestroy () {

View File

@@ -8,6 +8,7 @@ export default {
}, },
methods: { methods: {
npcClass (name) { npcClass (name) {
console.log('npcClass', name, this.currentEvent);
if (!this.currentEvent || !this.currentEvent.season) return `npc_${name}`; if (!this.currentEvent || !this.currentEvent.season) return `npc_${name}`;
return `npc_${name} npc_${name}_${this.currentEvent.season}`; return `npc_${name} npc_${name}_${this.currentEvent.season}`;
}, },

View File

@@ -6,6 +6,7 @@ export async function getWorldState (store, options = {}) {
path: 'worldState', path: 'worldState',
url: '/api/v4/world-state', url: '/api/v4/world-state',
deserialize (response) { deserialize (response) {
console.log(response.data.data);
return response.data.data; return response.data.data;
}, },
forceLoad: options.forceLoad, forceLoad: options.forceLoad,

View File

@@ -8,6 +8,33 @@ const gemsPromo = {
'84gems': 125, '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 = { export const EVENTS = {
noEvent: { noEvent: {
start: '2024-05-01T00:00-04:00', start: '2024-05-01T00:00-04:00',

View File

@@ -24,7 +24,7 @@ export const USER_CAN_OWN_QUEST_CATEGORIES = [
'pet', 'pet',
]; ];
export { EVENTS } from './events'; export { EVENTS, REPEATING_EVENTS } from './events';
export { default as SEASONAL_SETS } from './seasonalSets'; export { default as SEASONAL_SETS } from './seasonalSets';
export { default as ANIMAL_COLOR_ACHIEVEMENTS } from './animalColorAchievements'; export { default as ANIMAL_COLOR_ACHIEVEMENTS } from './animalColorAchievements';
export { default as ANIMAL_SET_ACHIEVEMENTS } from './animalSetAchievements'; export { default as ANIMAL_SET_ACHIEVEMENTS } from './animalSetAchievements';

View File

@@ -627,88 +627,104 @@ export const GALA_KEYS = [
'fall', 'fall',
]; ];
export const GALA_SCHEDULE = { export const GALA_SCHEDULE = {
0: [ 0: {
{ startMonth: 11,
type: 'seasonalGear', endMonth: 1,
items: SEASONAL_SETS.winter, filters: [
}, {
{ type: 'seasonalGear',
type: 'seasonalSpells', items: SEASONAL_SETS.winter,
items: [ },
'snowball', {
], type: 'seasonalSpells',
}, items: [
{ 'snowball',
type: 'seasonalQuests', ],
items: [ },
'evilsanta', {
'evilsanta2', type: 'seasonalQuests',
], items: [
}, 'evilsanta',
{ 'evilsanta2',
type: 'customizations', ],
matcher: customizationMatcher([ },
'winteryHairColors', {
'winterySkins', type: 'customizations',
]), matcher: customizationMatcher([
}, 'winteryHairColors',
], 'winterySkins',
1: [ ]),
{ },
type: 'seasonalGear', ],
items: SEASONAL_SETS.spring, },
}, 1: {
{ startMonth: 2,
type: 'seasonalSpells', endMonth: 4,
items: [ filters: [
'shinySeed', {
], type: 'seasonalGear',
}, items: SEASONAL_SETS.spring,
{ },
type: 'customizations', {
matcher: customizationMatcher([ type: 'seasonalSpells',
'shimmerHairColors', items: [
'pastelSkins', 'shinySeed',
]), ],
}, },
], {
2: [ type: 'customizations',
{ matcher: customizationMatcher([
type: 'seasonalGear', 'shimmerHairColors',
items: SEASONAL_SETS.summer, 'pastelSkins',
}, ]),
{ },
type: 'seasonalSpells', ],
items: [ },
'seafoam', 2: {
], startMonth: 5,
}, endMonth: 7,
{ filters: [
type: 'customizations', {
matcher: customizationMatcher([ type: 'seasonalGear',
'splashySkins', items: SEASONAL_SETS.summer,
]), },
}, {
], type: 'seasonalSpells',
3: [ items: [
{ 'seafoam',
type: 'seasonalGear', ],
items: SEASONAL_SETS.fall, },
}, {
{ type: 'customizations',
type: 'seasonalSpells', matcher: customizationMatcher([
items: [ 'splashySkins',
'spookySparkles', ]),
], },
}, ],
{ },
type: 'customizations', 3: {
matcher: customizationMatcher([ startMonth: 8,
'hauntedHairColors', endMonth: 10,
'supernaturalSkins', filters: [
]), {
}, type: 'seasonalGear',
], items: SEASONAL_SETS.fall,
},
{
type: 'seasonalSpells',
items: [
'spookySparkles',
],
},
{
type: 'customizations',
matcher: customizationMatcher([
'hauntedHairColors',
'supernaturalSkins',
]),
},
],
},
}; };
function getDay (date) { 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; return items;
} }
let cachedScheduleMatchers = null; let cachedScheduleMatchers = null;
export function getScheduleMatchingGroup (type, date) { export function getScheduleMatchingGroup (type, date) {
let checkedDate = date; const checkedDate = date || new Date();
if (checkedDate === undefined) {
checkedDate = new Date();
}
if (cacheDate !== null && (getDay(checkedDate) !== getDay(cacheDate) if (cacheDate !== null && (getDay(checkedDate) !== getDay(cacheDate)
|| getMonth(checkedDate) !== getMonth(cacheDate))) { || getMonth(checkedDate) !== getMonth(cacheDate))) {
cacheDate = null; cacheDate = null;
@@ -806,3 +819,18 @@ export function getScheduleMatchingGroup (type, date) {
export function getCurrentGalaKey (date) { export function getCurrentGalaKey (date) {
return GALA_KEYS[getGalaIndex(date || new 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}`,
};
}

View File

@@ -5,6 +5,8 @@ import { // eslint-disable-line import/no-cycle
TAVERN_ID as tavernId, TAVERN_ID as tavernId,
} from '../models/group'; } from '../models/group';
import common from '../../common'; import common from '../../common';
import { REPEATING_EVENTS } from '../../common/script/content/constants';
import { getCurrentGalaEvent } from '../../common/script/content/constants/schedule';
export async function getWorldBoss () { export async function getWorldBoss () {
const tavern = await Group const tavern = await Group
@@ -18,26 +20,32 @@ export async function getWorldBoss () {
} }
export function getCurrentEvent () { export function getCurrentEvent () {
const currEvtKey = Object.keys(common.content.events).find(evtKey => { const now = moment();
const event = common.content.events[evtKey]; 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(startDate, endDate);
return now.isBetween(event.start, event.end); // && Boolean(event.npcImageSuffix);
}); });
if (!currEvtKey) return null; if (!currEvtKey) {
return getCurrentGalaEvent()
}
return { return {
event: currEvtKey, event: currEvtKey,
...common.content.events[currEvtKey], ...REPEATING_EVENTS[currEvtKey],
}; };
} }
export function getCurrentEventList () { export function getCurrentEventList () {
const currentEventKeys = filter(Object.keys(common.content.events), eventKey => { const now = moment();
const eventData = common.content.events[eventKey]; 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 = []; const currentEventList = [];
@@ -45,9 +53,12 @@ export function getCurrentEventList () {
currentEventKeys.forEach(key => { currentEventKeys.forEach(key => {
currentEventList.push({ currentEventList.push({
event: key, event: key,
...common.content.events[key], ...REPEATING_EVENTS[key],
}); });
}); });
currentEventList.push(getCurrentGalaEvent());
console.log(currentEventList);
return currentEventList; return currentEventList;
} }