Files
evilspins/utils/cards.ts
valere 9618f76a6c
All checks were successful
Deploy App / build (push) Successful in 1m19s
Deploy App / deploy (push) Successful in 15s
fix card rank ♣ is for automne
2025-10-11 11:15:59 +02:00

22 lines
586 B
TypeScript

import type { CardSuit, CardRank } from '~/types/cards'
export function getCardFromDate(date: Date): { suit: CardSuit; rank: CardRank } {
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const suit: CardSuit =
month >= 12 || month <= 2
? '♠'
: month >= 3 && month <= 5
? '♥'
: month >= 6 && month <= 8
? '♦'
: '♣'
const ranks: CardRank[] = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
const rank = ranks[(day + hour) % ranks.length]
return { suit, rank }
}