mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Implement events throughout the year
This commit is contained in:
committed by
Sabe Jones
parent
2a84561e00
commit
249394b4ad
@@ -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
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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}`;
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -627,7 +627,10 @@ export const GALA_KEYS = [
|
||||
'fall',
|
||||
];
|
||||
export const GALA_SCHEDULE = {
|
||||
0: [
|
||||
0: {
|
||||
startMonth: 11,
|
||||
endMonth: 1,
|
||||
filters: [
|
||||
{
|
||||
type: 'seasonalGear',
|
||||
items: SEASONAL_SETS.winter,
|
||||
@@ -653,7 +656,11 @@ export const GALA_SCHEDULE = {
|
||||
]),
|
||||
},
|
||||
],
|
||||
1: [
|
||||
},
|
||||
1: {
|
||||
startMonth: 2,
|
||||
endMonth: 4,
|
||||
filters: [
|
||||
{
|
||||
type: 'seasonalGear',
|
||||
items: SEASONAL_SETS.spring,
|
||||
@@ -672,7 +679,11 @@ export const GALA_SCHEDULE = {
|
||||
]),
|
||||
},
|
||||
],
|
||||
2: [
|
||||
},
|
||||
2: {
|
||||
startMonth: 5,
|
||||
endMonth: 7,
|
||||
filters: [
|
||||
{
|
||||
type: 'seasonalGear',
|
||||
items: SEASONAL_SETS.summer,
|
||||
@@ -690,7 +701,11 @@ export const GALA_SCHEDULE = {
|
||||
]),
|
||||
},
|
||||
],
|
||||
3: [
|
||||
},
|
||||
3: {
|
||||
startMonth: 8,
|
||||
endMonth: 10,
|
||||
filters: [
|
||||
{
|
||||
type: 'seasonalGear',
|
||||
items: SEASONAL_SETS.fall,
|
||||
@@ -709,6 +724,7 @@ export const GALA_SCHEDULE = {
|
||||
]),
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
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}`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user