import { TalkTopic } from '../api/client/types.gen' import { kst } from '.' /** 게임 8단계 그림을 바꾼다. 작은 것부터 큰 것 순서, 크기·색은 원래 단계 그대로 */ type GamePiece = { icon: string; name: string } /** * 기념일 꾸밈. 기간(KST, 양 끝 포함) 안에만 켜진다. 'MM-DD' 는 해마다, 'YYYY-MM-DD' 는 그해만(음력 기념일). * 새 기념일: 여기에 한 줄 + TalkTopic(backend/common/enums.py) + 게임 그림(public/b/icons, lib.ts OWN) + 소품 그림(public/b/holiday, 투명 배경, b.css) */ export type Holiday = { key: 'halloween' | 'pepero' | 'christmas' | 'chuseok' name: string ranges: readonly (readonly [string, string])[] topic: TalkTopic /** 글만 있는 사람 글 배경 (b.css b-bg-*) */ bg: string game: readonly GamePiece[] } export const HOLIDAYS: readonly Holiday[] = [ { key: 'halloween', name: '할로윈', ranges: [['10-30', '11-01']], topic: TalkTopic.HALLOWEEN, bg: 'night', game: [ { icon: 'candy', name: '사탕' }, { icon: 'lollipop', name: '막대사탕' }, { icon: 'spider', name: '거미' }, { icon: 'spider_web', name: '거미줄' }, { icon: 'bat', name: '박쥐' }, { icon: 'ghost', name: '유령' }, { icon: 'skull', name: '해골' }, { icon: 'jack_o_lantern', name: '호박등' }, ], }, { key: 'pepero', name: '빼빼로데이', ranges: [['11-11', '11-11']], topic: TalkTopic.PEPERO, bg: 'peach', game: [ { icon: 'pepero_choco', name: '초코' }, { icon: 'pepero_almond', name: '아몬드' }, { icon: 'pepero_strawberry', name: '딸기' }, { icon: 'pepero_nude', name: '누드' }, { icon: 'pepero_pair', name: '한 쌍' }, { icon: 'pepero_bundle', name: '다발' }, { icon: 'pepero_box', name: '한 상자' }, { icon: 'pepero_basket', name: '바구니' }, ], }, { key: 'christmas', name: '크리스마스', ranges: [['12-24', '12-25']], topic: TalkTopic.CHRISTMAS, bg: 'mint', game: [ { icon: 'xmas_candy_cane', name: '캔디케인' }, { icon: 'xmas_ornament', name: '장식볼' }, { icon: 'xmas_gingerbread', name: '진저쿠키' }, { icon: 'xmas_santa_hat', name: '산타 모자' }, { icon: 'xmas_stocking', name: '양말' }, { icon: 'xmas_wreath', name: '리스' }, { icon: 'xmas_santa', name: '산타' }, { icon: 'christmas_tree', name: '트리' }, ], }, { key: 'chuseok', name: '추석', ranges: [['2027-09-14', '2027-09-16']], topic: TalkTopic.CHUSEOK, bg: 'butter', game: [ { icon: 'chestnut', name: '밤' }, { icon: 'pear', name: '배' }, { icon: 'apple', name: '사과' }, { icon: 'dango', name: '떡' }, { icon: 'rabbit', name: '토끼' }, { icon: 'maple', name: '단풍' }, { icon: 'moon_viewing', name: '달맞이' }, { icon: 'full_moon', name: '보름달' }, ], }, ] const pad = (n: number) => String(n).padStart(2, '0') function inRange([from, to]: readonly [string, string], y: number, md: string) { const day = from.length === 10 ? `${y}-${md}` : md return from <= day && day <= to } /** 그날(KST) 켜진 기념일 */ export function holidayOn(now = new Date()): Holiday | undefined { const { y, mo, d } = kst(now) const md = `${pad(mo)}-${pad(d)}` return HOLIDAYS.find((h) => h.ranges.some((r) => inRange(r, y, md))) } export const holidayByTopic = (t?: number) => HOLIDAYS.find((h) => h.topic === t)