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' | 'suneung' | 'newyear' 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: '보름달' }, ], }, { key: 'suneung', name: '수능 응원', // 수능 날(11월 셋째 목요일)은 해마다 달라 그해만. 전날(응원 글이 가장 많은 날)부터 ranges: [['2026-11-18', '2026-11-19']], topic: TalkTopic.SUNEUNG, bg: 'sky', game: [ { icon: 'suneung_pencil', name: '연필' }, { icon: 'suneung_eraser', name: '지우개' }, { icon: 'suneung_heatpack', name: '핫팩' }, { icon: 'suneung_yeot', name: '엿' }, { icon: 'suneung_mochi', name: '찹쌀떡' }, { icon: 'suneung_lunchbox', name: '도시락' }, { icon: 'suneung_ticket', name: '수험표' }, { icon: 'suneung_bouquet', name: '꽃다발' }, ], }, { key: 'newyear', name: '연말·새해', // 해를 넘기므로 하루씩 두 줄 ranges: [['12-31', '12-31'], ['01-01', '01-01']], topic: TalkTopic.NEWYEAR, bg: 'night', game: [ { icon: 'newyear_popper', name: '폭죽' }, { icon: 'newyear_pouch', name: '복주머니' }, { icon: 'calendar', name: '달력' }, { icon: 'newyear_tteokguk', name: '떡국' }, { icon: 'newyear_bell', name: '제야의 종' }, { icon: 'fireworks', name: '불꽃놀이' }, { icon: 'newyear_sunset', name: '해넘이' }, { icon: 'sunrise', 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)