Made period option for LeimDate

Should have done this sooner since period is derived from year
This commit is contained in:
Alexis
2024-04-08 17:47:58 +02:00
parent 386074d497
commit e3d689edf9
4 changed files with 71 additions and 65 deletions

View File

@@ -2,45 +2,45 @@ import type { Character } from '@/models/Characters'
export const charactersList: Character[] = [ export const charactersList: Character[] = [
// Player characters // Player characters
{ name: 'Sulvan Trois-Barbes', birth: { day: 20, month: 3, year: 3169, period: 'nante' } }, { name: 'Sulvan Trois-Barbes', birth: { day: 20, month: 3, year: 3169 } },
{ name: 'Vascylly', birth: { day: 3, month: 5, year: 3181, period: 'nante' } }, { name: 'Vascylly', birth: { day: 3, month: 5, year: 3181 } },
{ name: 'Tara Belyus', birth: { day: 14, month: 9, year: 3186, period: 'nante' } }, { name: 'Tara Belyus', birth: { day: 14, month: 9, year: 3186 } },
// Counts of the Alliance // Counts of the Alliance
{ name: 'Alfrid de Lagarde', birth: { day: 29, month: 7, year: 3193, period: 'nante' } }, { name: 'Alfrid de Lagarde', birth: { day: 29, month: 7, year: 3193 } },
{ name: 'Alaric de Lagarde', birth: { day: 23, month: 8, year: 3192, period: 'nante' } }, { name: 'Alaric de Lagarde', birth: { day: 23, month: 8, year: 3192 } },
{ name: 'Anastael III de Quillon', birth: { day: 1, month: 5, year: 3184, period: 'nante' } }, { name: 'Anastael III de Quillon', birth: { day: 1, month: 5, year: 3184 } },
{ name: 'Antoine de Mireloin', birth: { day: 31, month: 5, year: 3190, period: 'nante' } }, { name: 'Antoine de Mireloin', birth: { day: 31, month: 5, year: 3190 } },
{ name: 'Armance Ronchère', birth: { day: 1, month: 1, year: 3132, period: 'nante' } }, { name: 'Armance Ronchère', birth: { day: 1, month: 1, year: 3132 } },
{ name: 'Baranne Rougefer', birth: { day: 1, month: 0, year: 3175, period: 'nante' } }, { name: 'Baranne Rougefer', birth: { day: 1, month: 0, year: 3175 } },
{ name: 'Béatrice II de Grandlac', birth: { day: 21, month: 4, year: 3158, period: 'nante' } }, { name: 'Béatrice II de Grandlac', birth: { day: 21, month: 4, year: 3158 } },
{ name: 'Favio Asharos-Losantelle', birth: { day: 17, month: 3, year: 3091, period: 'nante' } }, { name: 'Favio Asharos-Losantelle', birth: { day: 17, month: 3, year: 3091 } },
{ name: 'Firmin de Montardieu', birth: { day: 9, month: 2, year: 3203, period: 'nante' } }, { name: 'Firmin de Montardieu', birth: { day: 9, month: 2, year: 3203 } },
{ {
name: 'Laura de Montardieu', name: 'Laura de Montardieu',
birth: { day: 32, month: 3, year: 3167, period: 'nante' }, birth: { day: 32, month: 3, year: 3167 },
death: { day: 1, month: 4, year: 3217, period: 'nante' }, death: { day: 1, month: 4, year: 3217 },
hiddenDeath: true hiddenDeath: true
}, },
{ name: 'Lazarus Tymos', birth: { day: 29, month: 9, year: 3145, period: 'nante' } }, { name: 'Lazarus Tymos', birth: { day: 29, month: 9, year: 3145 } },
{ name: 'Marion de Corambre', birth: { day: 14, month: 7, year: 3190, period: 'nante' } }, { name: 'Marion de Corambre', birth: { day: 14, month: 7, year: 3190 } },
{ name: 'Relforg Pergaré', birth: { day: 18, month: 9, year: 3182, period: 'nante' } }, { name: 'Relforg Pergaré', birth: { day: 18, month: 9, year: 3182 } },
{ name: 'Vilgarde de Ternâcre', birth: { day: 3, month: 3, year: 2998, period: 'nante' } }, { name: 'Vilgarde de Ternâcre', birth: { day: 3, month: 3, year: 2998 } },
{ name: 'Ysildy Milopée', birth: { day: 3, month: 1, year: 3187, period: 'nante' } }, { name: 'Ysildy Milopée', birth: { day: 3, month: 1, year: 3187 } },
// Sparks // Sparks
{ name: 'Izàc Tymos', birth: { day: 13, month: 6, year: 3192, period: 'nante' } }, { name: 'Izàc Tymos', birth: { day: 13, month: 6, year: 3192 } },
{ name: 'Tvernée', birth: { day: 19, month: 2, year: 3205, period: 'nante' } }, { name: 'Tvernée', birth: { day: 19, month: 2, year: 3205 } },
// Pirates // Pirates
{ name: 'Räzal', birth: { day: 13, month: 8, year: 3178, period: 'nante' } }, { name: 'Räzal', birth: { day: 13, month: 8, year: 3178 } },
// "Les Milles Cages" // "Les Milles Cages"
{ name: 'Ernestin Pomel', birth: { day: 11, month: 2, year: 3179, period: 'nante' } }, { name: 'Ernestin Pomel', birth: { day: 11, month: 2, year: 3179 } },
{ name: 'Quacille Lévios', birth: { day: 3, month: 6, year: 3162, period: 'nante' } }, { name: 'Quacille Lévios', birth: { day: 3, month: 6, year: 3162 } },
{ name: 'Morel Lévios', birth: { day: 26, month: 3, year: 3157, period: 'nante' } }, { name: 'Morel Lévios', birth: { day: 26, month: 3, year: 3157 } },
{ name: 'Anastael Simon', birth: { day: 32, month: 2, year: 3166, period: 'nante' } }, { name: 'Anastael Simon', birth: { day: 32, month: 2, year: 3166 } },
{ name: 'Grestain', birth: { day: 9, month: 2, year: 3162, period: 'nante' } }, { name: 'Grestain', birth: { day: 9, month: 2, year: 3162 } },
{ name: 'Lucien Malanth', birth: { day: 31, month: 4, year: 3167, period: 'nante' } }, { name: 'Lucien Malanth', birth: { day: 31, month: 4, year: 3167 } },
{ name: 'Tivian Rodhus', birth: { day: 13, month: 3, year: 3157, period: 'nante' } } { name: 'Tivian Rodhus', birth: { day: 13, month: 3, year: 3157 } }
] ]

View File

@@ -4,7 +4,7 @@ export const regularEvents: CalendarEvent[] = [
// Histoire Antique // Histoire Antique
{ {
title: 'Exécution de Tyhos', title: 'Exécution de Tyhos',
date: { day: 1, month: 0, year: 0, period: 'nante' }, date: { day: 1, month: 0, year: 0 },
description: description:
"Le léviathan Tyhos rend l'âme après un combat de plusieurs années contre Lystos, le dieu du Soleil.", "Le léviathan Tyhos rend l'âme après un combat de plusieurs années contre Lystos, le dieu du Soleil.",
category: 'boon', category: 'boon',
@@ -14,7 +14,7 @@ export const regularEvents: CalendarEvent[] = [
}, },
{ {
title: 'Traité de Kadel', title: 'Traité de Kadel',
date: { day: 20, month: 4, year: 100, period: 'nante' }, date: { day: 20, month: 4, year: 100 },
description: '', description: '',
category: 'inauguration', category: 'inauguration',
secondaryCategories: ['legal'], secondaryCategories: ['legal'],
@@ -24,7 +24,7 @@ export const regularEvents: CalendarEvent[] = [
// Histoire Récente // Histoire Récente
{ {
title: 'Création de la buse kaldélienne', title: 'Création de la buse kaldélienne',
date: { day: 4, month: 2, year: 3113, period: 'nante' }, date: { day: 4, month: 2, year: 3113 },
description: description:
'Sophia de Rougefer invente la buse kaldélienne, une arme à feu souple à deux canons.', 'Sophia de Rougefer invente la buse kaldélienne, une arme à feu souple à deux canons.',
category: 'invention', category: 'invention',
@@ -35,7 +35,7 @@ export const regularEvents: CalendarEvent[] = [
// "Les Milles Cages" // "Les Milles Cages"
{ {
title: "Arrivée d'aventuriers à Borélis", title: "Arrivée d'aventuriers à Borélis",
date: { day: 12, month: 7, year: 3209, period: 'nante' }, date: { day: 12, month: 7, year: 3209 },
description: description:
'Tara Belyus, Vascylly et Adol Sulvan livrent 3 condamnés à Handany. Ils partent pour la mer durant la journée.', 'Tara Belyus, Vascylly et Adol Sulvan livrent 3 condamnés à Handany. Ils partent pour la mer durant la journée.',
category: 'player' category: 'player'
@@ -44,25 +44,25 @@ export const regularEvents: CalendarEvent[] = [
title: "Naufrage de l'Éclipse", title: "Naufrage de l'Éclipse",
description: description:
"L'Éclipse, le navire de la garde contenant des condamnés à destination des Cages Handaniennes, s'échoue au large des côtes montagneuses de la Lance d'Aldys.", "L'Éclipse, le navire de la garde contenant des condamnés à destination des Cages Handaniennes, s'échoue au large des côtes montagneuses de la Lance d'Aldys.",
date: { day: 14, month: 7, year: 3209, period: 'nante' }, date: { day: 14, month: 7, year: 3209 },
category: 'catastrophe' category: 'catastrophe'
}, },
{ {
title: 'Emprisonnement de Tivian Rodhus', title: 'Emprisonnement de Tivian Rodhus',
description: "Celui qu'on surnomme la Bête d'Ambrose arrive à Handany, où il purgera sa peine.", description: "Celui qu'on surnomme la Bête d'Ambrose arrive à Handany, où il purgera sa peine.",
date: { day: 14, month: 7, year: 3209, period: 'nante' }, date: { day: 14, month: 7, year: 3209 },
category: 'legal' category: 'legal'
}, },
{ {
title: 'Sulvan et Anastael atteignent Bamast', title: 'Sulvan et Anastael atteignent Bamast',
date: { day: 19, month: 2, year: 3210, period: 'nante' }, date: { day: 19, month: 2, year: 3210 },
category: 'player' category: 'player'
}, },
{ {
title: 'Jugement de Bormis Griloup', title: 'Jugement de Bormis Griloup',
description: description:
"Bromis Griloup est jugé coupable d'escroquerie et sabotage aux Cours d'Acier de Tourgrise. Il purgera une peine de 10 ans au sein des prisons royales.", "Bromis Griloup est jugé coupable d'escroquerie et sabotage aux Cours d'Acier de Tourgrise. Il purgera une peine de 10 ans au sein des prisons royales.",
date: { day: 4, month: 8, year: 3209, period: 'nante' }, date: { day: 4, month: 8, year: 3209 },
category: 'legal' category: 'legal'
}, },
@@ -70,42 +70,42 @@ export const regularEvents: CalendarEvent[] = [
{ {
title: 'Inauguration de la Cloche du Pilier', title: 'Inauguration de la Cloche du Pilier',
description: "Le Moine Premier inaugure la grande cloche d'argent au sommet du Pilier d'Ikami.", description: "Le Moine Premier inaugure la grande cloche d'argent au sommet du Pilier d'Ikami.",
date: { day: 29, month: 5, year: 3209, period: 'nante' }, date: { day: 29, month: 5, year: 3209 },
category: 'religious', category: 'religious',
hidden: true hidden: true
}, },
{ {
title: '1ère disparation à Cantane', title: '1ère disparation à Cantane',
description: 'Première victime de la série de disparitions qui affecte Cantane', description: 'Première victime de la série de disparitions qui affecte Cantane',
date: { day: 28, month: 7, year: 3209, period: 'nante' }, date: { day: 28, month: 7, year: 3209 },
category: 'death', category: 'death',
hidden: true hidden: true
}, },
{ {
title: '2ème disparation à Cantane', title: '2ème disparation à Cantane',
description: 'Seconde victime de la série de disparitions qui affecte Cantane', description: 'Seconde victime de la série de disparitions qui affecte Cantane',
date: { day: 32, month: 7, year: 3209, period: 'nante' }, date: { day: 32, month: 7, year: 3209 },
category: 'death', category: 'death',
hidden: true hidden: true
}, },
{ {
title: '3ème disparation à Cantane', title: '3ème disparation à Cantane',
description: 'Troisième victime de la série de disparitions qui affecte Cantane', description: 'Troisième victime de la série de disparitions qui affecte Cantane',
date: { day: 10, month: 8, year: 3209, period: 'nante' }, date: { day: 10, month: 8, year: 3209 },
category: 'death', category: 'death',
hidden: true hidden: true
}, },
{ {
title: '4ème disparation à Cantane', title: '4ème disparation à Cantane',
description: 'Quatrième victime de la série de disparitions qui affecte Cantane', description: 'Quatrième victime de la série de disparitions qui affecte Cantane',
date: { day: 19, month: 8, year: 3209, period: 'nante' }, date: { day: 19, month: 8, year: 3209 },
category: 'death', category: 'death',
hidden: true hidden: true
}, },
{ {
title: '5ème disparation à Cantane', title: '5ème disparation à Cantane',
description: 'Cinquième victime de la série de disparitions qui affecte Cantane', description: 'Cinquième victime de la série de disparitions qui affecte Cantane',
date: { day: 22, month: 8, year: 3209, period: 'nante' }, date: { day: 22, month: 8, year: 3209 },
category: 'death', category: 'death',
hidden: true hidden: true
} }

View File

@@ -2,7 +2,7 @@ export interface LeimDate {
day: number day: number
month: number month: number
year: number year: number
period: LeimPeriod period?: LeimPeriod
} }
export type LeimPeriod = 'ante' | 'nante' export type LeimPeriod = 'ante' | 'nante'
@@ -36,15 +36,21 @@ export function compareDates(a: LeimDate, b: LeimDate, order: LeimDateOrder = 'd
// Reverses the order if specified // Reverses the order if specified
const orderFactor: number = order === 'desc' ? 1 : -1 const orderFactor: number = order === 'desc' ? 1 : -1
if (a.period === 'ante' && b.period === 'nante') return -1 * orderFactor // Compare eras
if (a.period === 'nante' && b.period === 'ante') return 1 * orderFactor if ((a.period === 'ante' && b.period === 'nante') || (a.year < 0 && b.year >= 0))
return -1 * orderFactor
if ((a.period === 'nante' && b.period === 'ante') || (a.year >= 0 && b.year < 0))
return 1 * orderFactor
// Compare years
if (a.year < b.year) return -1 * orderFactor if (a.year < b.year) return -1 * orderFactor
if (a.year > b.year) return 1 * orderFactor if (a.year > b.year) return 1 * orderFactor
// Compare months
if (a.month < b.month) return -1 * orderFactor if (a.month < b.month) return -1 * orderFactor
if (a.month > b.month) return 1 * orderFactor if (a.month > b.month) return 1 * orderFactor
// Compare days
if (a.day < b.day) return -1 * orderFactor if (a.day < b.day) return -1 * orderFactor
if (a.day > b.day) return 1 * orderFactor if (a.day > b.day) return 1 * orderFactor

View File

@@ -44,7 +44,7 @@ export const useCalendar = defineStore('calendar', () => {
/** /**
* Month list * Month list
*/ */
const months = [ const months: string[] = [
'Jalen', 'Jalen',
'Malsen', 'Malsen',
'Verlys', 'Verlys',
@@ -82,9 +82,9 @@ export const useCalendar = defineStore('calendar', () => {
}) })
// Default date settings (current day in the world) // Default date settings (current day in the world)
const defaultDay = 23 const defaultDay: number = 23
const defaultMonth = 8 const defaultMonth: number = 8
const defaultYear = 3209 const defaultYear: number = 3209
const defaultDate: ComputedRef<LeimDate> = computed(() => { const defaultDate: ComputedRef<LeimDate> = computed(() => {
return { return {
day: defaultDay, day: defaultDay,
@@ -105,17 +105,17 @@ export const useCalendar = defineStore('calendar', () => {
params.year = defaultYear.toString() params.year = defaultYear.toString()
} }
const currentDay = computed(() => { const currentDay = computed<number>(() => {
return Number(params.day) return Number(params.day)
}) })
const currentMonth = computed(() => { const currentMonth = computed<number>(() => {
return Number(params.month) return Number(params.month)
}) })
// Gets the label from currentMonth index // Gets the label from currentMonth index
const currentMonthName = computed(() => getMonthName(currentMonth.value)) const currentMonthName = computed<string>(() => getMonthName(currentMonth.value))
const currentYear = computed(() => { const currentYear = computed<number>(() => {
return Number(params.year) return Number(params.year)
}) })
@@ -125,7 +125,7 @@ export const useCalendar = defineStore('calendar', () => {
() => getPeriodOfYear(currentYear.value).short () => getPeriodOfYear(currentYear.value).short
) )
const currentDateTitle = computed(() => { const currentDateTitle = computed<string>(() => {
switch (currentConfig.value.viewType) { switch (currentConfig.value.viewType) {
case 'month': case 'month':
return getFormattedDateTitle({ return getFormattedDateTitle({
@@ -169,12 +169,12 @@ export const useCalendar = defineStore('calendar', () => {
} }
}) })
const selectedDate = useStorage('selected-date', currentLeimDate.value) const selectedDate = useStorage<LeimDate>('selected-date', currentLeimDate.value)
/** /**
* Check whether the current viewType is active * Check whether the current viewType is active
*/ */
const isCurrentScreenActive = computed(() => { const isCurrentScreenActive = computed<boolean>(() => {
switch (currentConfig.value.viewType) { switch (currentConfig.value.viewType) {
case 'month': case 'month':
return ( return (
@@ -195,7 +195,7 @@ export const useCalendar = defineStore('calendar', () => {
/** /**
* Moves the current date forward one month * Moves the current date forward one month
*/ */
function incrementMonth() { function incrementMonth(): void {
let newValue = Number(params.month) + 1 let newValue = Number(params.month) + 1
// If the new value would exceed the max number of month per year // If the new value would exceed the max number of month per year
@@ -211,7 +211,7 @@ export const useCalendar = defineStore('calendar', () => {
/** /**
* Moves the current date backward one month * Moves the current date backward one month
*/ */
function decrementMonth() { function decrementMonth(): void {
let newValue = Number(params.month) - 1 let newValue = Number(params.month) - 1
// If the new value would go below 0 // If the new value would go below 0
@@ -227,7 +227,7 @@ export const useCalendar = defineStore('calendar', () => {
/** /**
* Moves the current date to a particular month * Moves the current date to a particular month
*/ */
function setMonth(target: number) { function setMonth(target: number): void {
// If the target is outside the month bounds // If the target is outside the month bounds
if (target < 0 || target >= staticConfig.monthsPerYear) { if (target < 0 || target >= staticConfig.monthsPerYear) {
return return
@@ -239,7 +239,7 @@ export const useCalendar = defineStore('calendar', () => {
/** /**
* Moves the current date forward one year * Moves the current date forward one year
*/ */
function incrementYear(inc: number = 1) { function incrementYear(inc: number = 1): void {
const newValue = Number(params.year) + inc const newValue = Number(params.year) + inc
params.year = newValue.toString() params.year = newValue.toString()
@@ -248,7 +248,7 @@ export const useCalendar = defineStore('calendar', () => {
/** /**
* Moves the current date backward one year * Moves the current date backward one year
*/ */
function decrementYear(inc: number = 1) { function decrementYear(inc: number = 1): void {
const newValue = Number(params.year) - inc const newValue = Number(params.year) - inc
params.year = newValue.toString() params.year = newValue.toString()
@@ -334,7 +334,7 @@ export const useCalendar = defineStore('calendar', () => {
* *
* @param date Target date * @param date Target date
*/ */
function jumpToDate(date: LeimDate) { function jumpToDate(date: LeimDate): void {
params.day = date.day.toString() params.day = date.day.toString()
params.month = date.month.toString() params.month = date.month.toString()
params.year = date.year.toString() params.year = date.year.toString()
@@ -344,7 +344,7 @@ export const useCalendar = defineStore('calendar', () => {
/** /**
* Jump the calendar to the default date * Jump the calendar to the default date
*/ */
function jumpToDefaultDate() { function jumpToDefaultDate(): void {
jumpToDate(defaultDate.value) jumpToDate(defaultDate.value)
currentConfig.value.viewType = 'month' currentConfig.value.viewType = 'month'
} }
@@ -352,7 +352,7 @@ export const useCalendar = defineStore('calendar', () => {
/** /**
* Jump the calendar to the default date * Jump the calendar to the default date
*/ */
function selectDate(date: LeimDate) { function selectDate(date: LeimDate): void {
selectedDate.value = date selectedDate.value = date
} }