export type DifficultyLevel = 'easy' | 'normal' | 'hard'

export interface MapConfig {
  id: number
  name: string
  bgKey: string
  bgPath: string
  pathColor: number
  buildColor: number
  waypoints: readonly { x: number; y: number }[]
  decorations: {
    key: string
    col: number
    row: number
  }[]
  labels: { col: number; row: number; text: string }[]
  waveCount: number
  waves: WaveConfigEntry[]
}

export interface WaveConfigEntry {
  enemies: {
    type: 'FreshGraduate' | 'OldEmployee' | 'TroubleMaker' | 'BossVP'
    count: number
    interval: number
  }[]
}

/** 难度倍率配置 */
export const DIFFICULTY_MULTIPLIER: Record<DifficultyLevel, {
  enemyCount: number
  enemySpeed: number
  bossHp: number
  hcReward: number
}> = {
  easy:   { enemyCount: 0.7, enemySpeed: 0.8, bossHp: 0.7,  hcReward: 1.2 },
  normal: { enemyCount: 1.0, enemySpeed: 1.0, bossHp: 1.0,  hcReward: 1.0 },
  hard:   { enemyCount: 1.4, enemySpeed: 1.3, bossHp: 1.5,  hcReward: 0.8 },
}

// 地图1：人力资源部（S型路径）
// 路径：(0,2)→(11,2)→(11,9)→(15,9)
const MAP1: MapConfig = {
  id: 1,
  name: '人力资源部 · 降本增效',
  bgKey: 'map1-bg',
  bgPath: '/game-assets/map1-bg.png',
  pathColor: 0x3d2b1f,
  buildColor: 0x1e3a5f,
  waypoints: [
    { x: 0, y: 2 },
    { x: 11, y: 2 },
    { x: 11, y: 9 },
    { x: 15, y: 9 },
  ],
  decorations: [
    { key: 'deco-coffee',  col: 3,  row: 0 },
    { key: 'deco-monitor', col: 14, row: 1 },
    { key: 'deco-desk',    col: 5,  row: 5 },
    { key: 'deco-coffee',  col: 9,  row: 11 },
    { key: 'deco-monitor', col: 1,  row: 7 },
    { key: 'deco-desk',    col: 13, row: 4 },
  ],
  labels: [
    { col: 0,  row: 0,  text: '面试间' },
    { col: 14, row: 10, text: '财务室' },
    { col: 6,  row: 5,  text: 'HR办公区' },
  ],
  waveCount: 5,
  waves: [
    { enemies: [{ type: 'FreshGraduate', count: 10, interval: 800 }] },
    { enemies: [{ type: 'FreshGraduate', count: 8, interval: 700 }, { type: 'OldEmployee', count: 2, interval: 2000 }] },
    { enemies: [{ type: 'OldEmployee', count: 4, interval: 1800 }, { type: 'TroubleMaker', count: 3, interval: 1500 }] },
    { enemies: [{ type: 'FreshGraduate', count: 12, interval: 600 }, { type: 'TroubleMaker', count: 3, interval: 1200 }] },
    { enemies: [{ type: 'BossVP', count: 1, interval: 0 }, { type: 'OldEmployee', count: 3, interval: 2000 }, { type: 'FreshGraduate', count: 5, interval: 800 }] },
  ],
}

// 地图2：技术研发部（Z型路径）
// 路径：(0,1)→(8,1)→(8,5)→(3,5)→(3,10)→(15,10)
const MAP2: MapConfig = {
  id: 2,
  name: '技术研发部 · 996福报',
  bgKey: 'map2-bg',
  bgPath: '/game-assets/map2-bg.png',
  pathColor: 0x1a3a2a,
  buildColor: 0x0f2040,
  waypoints: [
    { x: 0,  y: 1 },
    { x: 8,  y: 1 },
    { x: 8,  y: 5 },
    { x: 3,  y: 5 },
    { x: 3,  y: 10 },
    { x: 15, y: 10 },
  ],
  decorations: [
    { key: 'deco-monitor', col: 1,  row: 3 },
    { key: 'deco-monitor', col: 10, row: 0 },
    { key: 'deco-coffee',  col: 6,  row: 7 },
    { key: 'deco-desk',    col: 11, row: 3 },
    { key: 'deco-monitor', col: 5,  row: 8 },
    { key: 'deco-coffee',  col: 14, row: 7 },
    { key: 'deco-desk',    col: 0,  row: 6 },
    { key: 'deco-monitor', col: 13, row: 5 },
  ],
  labels: [
    { col: 0,  row: 0,  text: '研发中心' },
    { col: 14, row: 11, text: '服务器机房' },
    { col: 5,  row: 3,  text: '格子间' },
    { col: 10, row: 8,  text: 'Bug池' },
  ],
  waveCount: 5,
  waves: [
    { enemies: [{ type: 'FreshGraduate', count: 12, interval: 700 }, { type: 'OldEmployee', count: 2, interval: 2000 }] },
    { enemies: [{ type: 'OldEmployee', count: 5, interval: 1500 }, { type: 'TroubleMaker', count: 3, interval: 1200 }] },
    { enemies: [{ type: 'FreshGraduate', count: 15, interval: 500 }, { type: 'TroubleMaker', count: 4, interval: 1000 }] },
    { enemies: [{ type: 'BossVP', count: 1, interval: 0 }, { type: 'OldEmployee', count: 4, interval: 1500 }] },
    { enemies: [{ type: 'BossVP', count: 1, interval: 0 }, { type: 'FreshGraduate', count: 10, interval: 600 }, { type: 'TroubleMaker', count: 5, interval: 1000 }] },
  ],
}

// 地图3：高管会议室（W型路径，最难）
// 路径：(0,0)→(5,0)→(5,6)→(10,6)→(10,2)→(15,2)
const MAP3: MapConfig = {
  id: 3,
  name: '高管会议室 · 最后决战',
  bgKey: 'map3-bg',
  bgPath: '/game-assets/map3-bg.png',
  pathColor: 0x3d1f2b,
  buildColor: 0x2d1a40,
  waypoints: [
    { x: 0,  y: 0 },
    { x: 5,  y: 0 },
    { x: 5,  y: 6 },
    { x: 10, y: 6 },
    { x: 10, y: 2 },
    { x: 15, y: 2 },
  ],
  decorations: [
    { key: 'deco-desk',    col: 2,  row: 2 },
    { key: 'deco-desk',    col: 8,  row: 0 },
    { key: 'deco-coffee',  col: 12, row: 5 },
    { key: 'deco-desk',    col: 7,  row: 9 },
    { key: 'deco-monitor', col: 2,  row: 9 },
    { key: 'deco-coffee',  col: 13, row: 9 },
    { key: 'deco-desk',    col: 1,  row: 4 },
    { key: 'deco-monitor', col: 14, row: 4 },
    { key: 'deco-desk',    col: 8,  row: 8 },
  ],
  labels: [
    { col: 0,  row: 1, text: '董事会' },
    { col: 14, row: 3, text: '董事长室' },
    { col: 7,  row: 4, text: '会议室' },
  ],
  waveCount: 5,
  waves: [
    { enemies: [{ type: 'OldEmployee', count: 6, interval: 1500 }, { type: 'TroubleMaker', count: 4, interval: 1000 }] },
    { enemies: [{ type: 'BossVP', count: 1, interval: 0 }, { type: 'FreshGraduate', count: 12, interval: 600 }, { type: 'OldEmployee', count: 3, interval: 1500 }] },
    { enemies: [{ type: 'BossVP', count: 1, interval: 0 }, { type: 'TroubleMaker', count: 6, interval: 800 }, { type: 'OldEmployee', count: 4, interval: 1500 }] },
    { enemies: [{ type: 'BossVP', count: 2, interval: 5000 }, { type: 'OldEmployee', count: 5, interval: 1200 }, { type: 'FreshGraduate', count: 8, interval: 600 }] },
    { enemies: [{ type: 'BossVP', count: 2, interval: 3000 }, { type: 'TroubleMaker', count: 8, interval: 600 }, { type: 'OldEmployee', count: 6, interval: 1000 }] },
  ],
}

export const ALL_MAPS: MapConfig[] = [MAP1, MAP2, MAP3]
