Fixed bug with unseen events
The bug occured because the currentMonth + 1 went over the limit
This commit is contained in:
@@ -224,6 +224,38 @@ export const useCalendar = defineStore('calendar', () => {
|
||||
params.month = newValue.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous month number
|
||||
*
|
||||
* @param monthNumber Initial month
|
||||
* @returns The previous month number in the year
|
||||
*/
|
||||
function getPreviousMonth(monthNumber: number): number {
|
||||
const target: number = monthNumber - 1
|
||||
|
||||
if (target < 0) {
|
||||
return monthsPerYear - 1
|
||||
}
|
||||
|
||||
return target
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the following month number
|
||||
*
|
||||
* @param monthNumber Initial month
|
||||
* @returns The next month number in the year
|
||||
*/
|
||||
function getNextMonth(monthNumber: number): number {
|
||||
const target: number = monthNumber + 1
|
||||
|
||||
if (target + 1 >= monthsPerYear) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return target
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the current date to a particular month
|
||||
*/
|
||||
@@ -370,6 +402,8 @@ export const useCalendar = defineStore('calendar', () => {
|
||||
incrementMonth,
|
||||
decrementMonth,
|
||||
setMonth,
|
||||
getPreviousMonth,
|
||||
getNextMonth,
|
||||
incrementYear,
|
||||
decrementYear,
|
||||
jumpToDate,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useCharacters } from './CharacterStore'
|
||||
import { regularEvents } from '@/data/Events'
|
||||
|
||||
export const useCalendarEvents = defineStore('calendar-events', () => {
|
||||
const { currentDate, currentConfig } = useCalendar()
|
||||
const { currentDate, currentConfig, getNextMonth } = useCalendar()
|
||||
const { charactersWithBirthData, charactersWithDeathData } = useCharacters()
|
||||
|
||||
const baseEvents = ref<CalendarEvent[]>(regularEvents)
|
||||
@@ -16,7 +16,7 @@ export const useCalendarEvents = defineStore('calendar-events', () => {
|
||||
return {
|
||||
title: `Naissance de ${character.name}`,
|
||||
date: character.birth,
|
||||
category: 'birth'
|
||||
category: 'naissance'
|
||||
} as CalendarEvent
|
||||
})
|
||||
})
|
||||
@@ -26,7 +26,7 @@ export const useCalendarEvents = defineStore('calendar-events', () => {
|
||||
return {
|
||||
title: `Décès de ${character.name}`,
|
||||
date: character.death,
|
||||
category: 'death'
|
||||
category: 'mort'
|
||||
} as CalendarEvent
|
||||
})
|
||||
})
|
||||
@@ -56,7 +56,7 @@ export const useCalendarEvents = defineStore('calendar-events', () => {
|
||||
case 'month':
|
||||
return (
|
||||
event.date.month === currentDate.currentMonth ||
|
||||
(event.date.month === currentDate.currentMonth + 1 && event.date.day <= 8) // This is to allow leap events from appearing on the last 8 tiles
|
||||
(event.date.month === getNextMonth(currentDate.currentMonth) && event.date.day <= 8) // This is to allow leap events from appearing on the last 8 tiles
|
||||
)
|
||||
|
||||
case 'year':
|
||||
|
||||
Reference in New Issue
Block a user