/** §7 任务清单 — closed set of 15 */

export type TaskId =
  | 'T1'
  | 'T2'
  | 'T3'
  | 'T4'
  | 'T5'
  | 'T6'
  | 'T7'
  | 'T8'
  | 'T9'
  | 'T10'
  | 'T11'
  | 'T12'
  | 'T13'
  | 'T14'
  | 'T15';

export interface TaskDef {
  id: TaskId;
  day: number;
  /** Display / board description — D4 matches D1 verbatim */
  description: string;
  happinessReward: number;
  refuseable: boolean;
  /** T8–T10 mirror T1–T3 */
  mirrors?: TaskId;
}

export const TASKS: readonly TaskDef[] = [
  {
    id: 'T1',
    day: 1,
    description: '从圆圆处取蜂蜜面包送给大宝、咪咪、龟爷爷',
    happinessReward: 15,
    refuseable: false,
  },
  {
    id: 'T2',
    day: 1,
    description: '给广场花坛浇水 ×3',
    happinessReward: 10,
    refuseable: false,
  },
  {
    id: 'T3',
    day: 1,
    description: '与任意三位村民问好',
    happinessReward: 10,
    refuseable: false,
  },
  {
    id: 'T4',
    day: 2,
    description: '替大宝送信 ×3（收件人：圆圆、咪咪、芙医生）',
    happinessReward: 15,
    refuseable: false,
  },
  {
    id: 'T5',
    day: 2,
    description: '帮咪咪清点货架',
    happinessReward: 10,
    refuseable: false,
  },
  {
    id: 'T6',
    day: 3,
    description: '去花田采莓果 ×5',
    happinessReward: 10,
    refuseable: false,
  },
  {
    id: 'T7',
    day: 3,
    description: '湖畔野餐（走到野餐布触发过场）',
    happinessReward: 15,
    refuseable: false,
  },
  {
    id: 'T8',
    day: 4,
    description: '从圆圆处取蜂蜜面包送给大宝、咪咪、龟爷爷',
    happinessReward: 15,
    refuseable: false,
    mirrors: 'T1',
  },
  {
    id: 'T9',
    day: 4,
    description: '给广场花坛浇水 ×3',
    happinessReward: 10,
    refuseable: false,
    mirrors: 'T2',
  },
  {
    id: 'T10',
    day: 4,
    description: '与任意三位村民问好',
    happinessReward: 10,
    refuseable: false,
    mirrors: 'T3',
  },
  {
    id: 'T11',
    day: 5,
    description: '帮圆圆揉面',
    happinessReward: 10,
    refuseable: true,
  },
  {
    id: 'T12',
    day: 5,
    description: '擦拭公告板',
    happinessReward: 10,
    refuseable: true,
  },
  {
    id: 'T13',
    day: 6,
    description: '在广场挂彩带 ×4',
    happinessReward: 10,
    refuseable: false,
  },
  {
    id: 'T14',
    day: 6,
    description: '保持微笑 60 秒（原地站立，镜头缓慢拉近，全村注视）',
    happinessReward: 15,
    refuseable: false,
  },
  {
    id: 'T15',
    day: 7,
    description: '参加第 413 届丰收庆典',
    happinessReward: 0,
    refuseable: false,
  },
] as const;

export function getTasksForDay(day: number): TaskDef[] {
  return TASKS.filter((t) => t.day === day);
}

export function getTask(id: TaskId): TaskDef {
  const t = TASKS.find((x) => x.id === id);
  if (!t) throw new Error(`Unknown task ${id}`);
  return t;
}
