// 道具配置系統
// 道具類型：equipment（裝備）、appearance（外觀）、consumable（消耗品）、talisman（護身符）、special（特殊）

export const ITEMS = {
  // ========== 裝備類（有耐久度）==========

  // 武器類
  wooden_sword: {
    id: 'wooden_sword',
    name: '木劍',
    type: 'equipment',
    category: 'weapon',
    slot: 'weapon',
    rarity: 'common',
    dropRate: 0.50, // 掉落機率 50%
    durability: 100, // 最大耐久度
    maxDurability: 100,
    effects: {
      flat: { attack: 5 },
      percent: { attack: 0.05 } // 攻擊力 +5%
    },
    description: '基礎木製武器，增加攻擊力',
    icon: '⚔️',
    appearance: null // 武器不改變外觀
  },

  iron_sword: {
    id: 'iron_sword',
    name: '鐵劍',
    type: 'equipment',
    category: 'weapon',
    slot: 'weapon',
    rarity: 'uncommon',
    dropRate: 0.30, // 掉落機率 30%
    durability: 200,
    maxDurability: 200,
    effects: {
      flat: { attack: 15, str: 3 },
      percent: { attack: 0.10 }
    },
    description: '堅固的鐵製武器，大幅增加攻擊力',
    icon: '🗡️',
    appearance: null
  },

  magic_staff: {
    id: 'magic_staff',
    name: '魔法杖',
    type: 'equipment',
    category: 'weapon',
    slot: 'weapon',
    rarity: 'rare',
    dropRate: 0.15, // 掉落機率 15%
    durability: 150,
    maxDurability: 150,
    effects: {
      flat: { attack: 10, int: 5 },
      percent: { attack: 0.08, intGain: 0.10 }
    },
    description: '蘊含魔力的法杖，增加智力和智力成長',
    icon: '🪄',
    appearance: null
  },

  // 防具類
  leather_armor: {
    id: 'leather_armor',
    name: '皮甲',
    type: 'equipment',
    category: 'armor',
    slot: 'armor',
    rarity: 'common',
    dropRate: 0.50, // 掉落機率 50%
    durability: 120,
    maxDurability: 120,
    effects: {
      flat: { defense: 8, health: 10 },
      percent: { defense: 0.05 }
    },
    description: '輕便的皮製護甲，增加防禦力和最大健康',
    icon: '🛡️',
    appearance: null
  },

  iron_armor: {
    id: 'iron_armor',
    name: '鐵甲',
    type: 'equipment',
    category: 'armor',
    slot: 'armor',
    rarity: 'uncommon',
    dropRate: 0.30, // 掉落機率 30%
    durability: 250,
    maxDurability: 250,
    effects: {
      flat: { defense: 20, health: 20 },
      percent: { defense: 0.15 }
    },
    description: '厚重的鐵製護甲，大幅增加防禦力',
    icon: '⚔️',
    appearance: null
  },

  // ========== 外觀類（無耐久，不壞）==========

  cute_hat: {
    id: 'cute_hat',
    name: '可愛帽子',
    type: 'appearance',
    category: 'hat',
    slot: 'hat',
    rarity: 'common',
    durability: Infinity, // 外觀類永不損壞
    maxDurability: Infinity,
    effects: {
      flat: { happiness: 5 } // 外觀類可以有小加成
    },
    description: '可愛的帽子，讓寵物看起來更萌',
    icon: '🎩',
    appearance: {
      hat: 'cute_hat'
    }
  },

  cool_sunglasses: {
    id: 'cool_sunglasses',
    name: '酷炫墨鏡',
    type: 'appearance',
    category: 'accessory',
    slot: 'accessory',
    rarity: 'uncommon',
    durability: Infinity,
    maxDurability: Infinity,
    effects: {
      percent: { happinessRecovery: 0.10, dex: 2 }
    },
    description: '超酷的墨鏡，增加快樂恢復和敏捷',
    icon: '🕶️',
    appearance: {
      accessory: 'cool_sunglasses'
    }
  },

  red_scarf: {
    id: 'red_scarf',
    name: '紅色圍巾',
    type: 'appearance',
    category: 'accessory',
    slot: 'accessory',
    rarity: 'common',
    durability: Infinity,
    maxDurability: Infinity,
    effects: {},
    description: '溫暖的紅色圍巾，純外觀道具',
    icon: '🧣',
    appearance: {
      accessory: 'red_scarf'
    }
  },

  // ========== 消耗品類 ==========

  cookie: {
    id: 'cookie',
    name: '幸運餅乾',
    type: 'consumable',
    category: 'food',
    rarity: 'common',
    stackable: true,
    effects: {
      modifyStats: { hunger: 20, happiness: 10 }
    },
    description: '美味的餅乾，增加飢餓和快樂',
    icon: '🍪'
  },

  health_potion: {
    id: 'health_potion',
    name: '治療藥水',
    type: 'consumable',
    category: 'potion',
    rarity: 'common',
    stackable: true,
    effects: {
      modifyStats: { health: 30 },
      cureSickness: true
    },
    description: '恢復健康並治癒疾病',
    icon: '🧪'
  },

  energy_drink: {
    id: 'energy_drink',
    name: '能量飲料',
    type: 'consumable',
    category: 'potion',
    rarity: 'uncommon',
    stackable: true,
    effects: {
      modifyStats: { happiness: 20 },
      addBuff: {
        id: 'energized',
        name: '精力充沛',
        durationTicks: 10, // 持續 10 ticks
        flat: { dex: 5 },
        percent: { speed: 0.10 }
      }
    },
    description: '提供臨時速度和敏捷加成',
    icon: '🥤'
  },

  growth_pill: {
    id: 'growth_pill',
    name: '成長藥丸',
    type: 'consumable',
    category: 'potion',
    rarity: 'rare',
    stackable: true,
    effects: {
      modifyStats: { str: 1, int: 1, dex: 1 }
    },
    description: '永久增加力量、智力、敏捷各 1 點',
    icon: '💊'
  },

  // ========== 護身符類（永久加成）==========

  lucky_amulet: {
    id: 'lucky_amulet',
    name: '幸運護身符',
    type: 'talisman',
    category: 'talisman',
    slot: 'talisman',
    rarity: 'uncommon',
    durability: Infinity,
    maxDurability: Infinity,
    effects: {
      flat: { luck: 5 },
      percent: { dropRate: 0.10 }
    },
    description: '帶來好運的護身符，增加運勢和掉落率',
    icon: '🔮'
  },

  protection_amulet: {
    id: 'protection_amulet',
    name: '平安符',
    type: 'talisman',
    category: 'talisman',
    slot: 'talisman',
    rarity: 'rare',
    durability: Infinity,
    maxDurability: Infinity,
    effects: {
      flat: { health: 20 },
      percent: { sicknessReduction: 0.20, healthRecovery: 0.15 }
    },
    description: '保佑平安的護身符，增加健康上限和恢復效率',
    icon: '🛡️'
  },

  wisdom_amulet: {
    id: 'wisdom_amulet',
    name: '智慧護身符',
    type: 'talisman',
    category: 'talisman',
    slot: 'talisman',
    rarity: 'rare',
    durability: Infinity,
    maxDurability: Infinity,
    effects: {
      flat: { int: 5 },
      percent: { intGain: 0.15, happinessRecovery: 0.10 }
    },
    description: '提升智慧的護身符，增加智力和智力成長',
    icon: '📿'
  },

  // ========== 特殊道具類 ==========

  training_manual: {
    id: 'training_manual',
    name: '訓練手冊',
    type: 'special',
    category: 'book',
    slot: 'special',
    rarity: 'uncommon',
    durability: Infinity,
    maxDurability: Infinity,
    effects: {
      percent: { strGain: 0.15, dexGain: 0.15 }
    },
    description: '訓練指南，增加力量和敏捷成長效率',
    icon: '📖'
  },

  time_crystal: {
    id: 'time_crystal',
    name: '時間水晶',
    type: 'special',
    category: 'crystal',
    slot: 'special',
    rarity: 'legendary',
    durability: Infinity,
    maxDurability: Infinity,
    effects: {
      percent: {
        strGain: 0.10,
        intGain: 0.10,
        dexGain: 0.10,
        happinessRecovery: 0.10,
        healthRecovery: 0.10
      }
    },
    description: '神秘的水晶，全面提升成長和恢復效率',
    icon: '💎'
  },

  // ========== 永久裝備（不會壞）==========

  golden_crown: {
    id: 'golden_crown',
    name: '黃金王冠',
    type: 'equipment',
    category: 'crown',
    slot: 'hat',
    rarity: 'legendary',
    durability: Infinity, // 永久裝備
    maxDurability: Infinity,
    effects: {
      flat: { str: 10, int: 10, dex: 10, luck: 10 },
      percent: { attack: 0.20, defense: 0.20, speed: 0.20 }
    },
    description: '傳說中的黃金王冠，全面提升所有屬性',
    icon: '👑',
    appearance: {
      hat: 'golden_crown'
    }
  }
}

// 道具類型定義
export const ITEM_TYPES = {
  equipment: { name: '裝備', icon: '⚔️' },
  appearance: { name: '外觀', icon: '👕' },
  consumable: { name: '消耗品', icon: '🍪' },
  talisman: { name: '護身符', icon: '🔮' },
  special: { name: '特殊', icon: '⭐' }
}

// 稀有度定義（資料檔保持英文 key，但 name 為中文顯示用）
export const ITEM_RARITY = {
  common: {
    name: '普通',
    color: '#9d9d9d',
    multiplier: 1.0,
    dropRate: 0.50, // 50% 基礎掉落機率
    description: '最常見的道具，容易獲得'
  },
  uncommon: {
    name: '優秀',
    color: '#1eff00',
    multiplier: 1.2,
    dropRate: 0.30, // 30% 基礎掉落機率
    description: '較為少見的道具，有一定價值'
  },
  rare: {
    name: '稀有',
    color: '#0070dd',
    multiplier: 1.5,
    dropRate: 0.15, // 15% 基礎掉落機率
    description: '稀有的道具，效果顯著'
  },
  epic: {
    name: '史詩',
    color: '#a335ee',
    multiplier: 2.0,
    dropRate: 0.05, // 5% 基礎掉落機率
    description: '史詩級道具，非常珍貴'
  },
  legendary: {
    name: '傳說',
    color: '#ff8000',
    multiplier: 3.0,
    dropRate: 0.01, // 1% 基礎掉落機率
    description: '傳說級道具，極其稀有且強大'
  }
}

// 裝備槽位定義
export const EQUIPMENT_SLOTS = {
  weapon: { name: '武器', icon: '⚔️' },
  armor: { name: '防具', icon: '🛡️' },
  hat: { name: '帽子', icon: '🎩' },
  accessory: { name: '飾品', icon: '💍' },
  talisman: { name: '護身符', icon: '🔮' },
  special: { name: '特殊', icon: '⭐' }
}

// 道具類型定義
export const ITEM_TYPE = {
  EQUIPMENT: 'equipment',
  CONSUMABLE: 'consumable',
  TALISMAN: 'talisman',
  SPECIAL: 'special',
  APPEARANCE: 'appearance'
}

// 道具類別定義
export const ITEM_CATEGORY = {
  FOOD: 'food',
  MEDICINE: 'potion',
  WEAPON: 'weapon',
  ARMOR: 'armor',
  TOY: 'toy',
  ACCESSORY: 'accessory',
  TALISMAN: 'talisman',
  BOOK: 'book'
}
