import 'package:asciineverdie/src/core/model/potion.dart';

/// 게임 내 물약 정의
///
/// HP/MP 물약 데이터 (티어 1~5)
class PotionData {
  PotionData._();

  // ============================================================================
  // HP 물약
  // ============================================================================

  /// Minor Health Patch - 소형 HP 물약
  static const minorHealthPatch = Potion(
    id: 'minor_health_patch',
    name: 'Minor Health Patch',
    type: PotionType.hp,
    tier: 1,
    healAmount: 30,
    healPercent: 0.0,
    price: 25,
  );

  /// Health Patch - 일반 HP 물약
  static const healthPatch = Potion(
    id: 'health_patch',
    name: 'Health Patch',
    type: PotionType.hp,
    tier: 2,
    healAmount: 50,
    healPercent: 0.10,
    price: 75,
  );

  /// Major Health Patch - 대형 HP 물약
  static const majorHealthPatch = Potion(
    id: 'major_health_patch',
    name: 'Major Health Patch',
    type: PotionType.hp,
    tier: 3,
    healAmount: 80,
    healPercent: 0.20,
    price: 200,
  );

  /// Super Health Patch - 초대형 HP 물약
  static const superHealthPatch = Potion(
    id: 'super_health_patch',
    name: 'Super Health Patch',
    type: PotionType.hp,
    tier: 4,
    healAmount: 120,
    healPercent: 0.30,
    price: 500,
  );

  /// Ultra Health Patch - 최고급 HP 물약
  static const ultraHealthPatch = Potion(
    id: 'ultra_health_patch',
    name: 'Ultra Health Patch',
    type: PotionType.hp,
    tier: 5,
    healAmount: 200,
    healPercent: 0.40,
    price: 1200,
  );

  // ============================================================================
  // MP 물약
  // ============================================================================

  /// Minor Mana Cache - 소형 MP 물약
  static const minorManaCache = Potion(
    id: 'minor_mana_cache',
    name: 'Minor Mana Cache',
    type: PotionType.mp,
    tier: 1,
    healAmount: 20,
    healPercent: 0.0,
    price: 20,
  );

  /// Mana Cache - 일반 MP 물약
  static const manaCache = Potion(
    id: 'mana_cache',
    name: 'Mana Cache',
    type: PotionType.mp,
    tier: 2,
    healAmount: 40,
    healPercent: 0.10,
    price: 60,
  );

  /// Major Mana Cache - 대형 MP 물약
  static const majorManaCache = Potion(
    id: 'major_mana_cache',
    name: 'Major Mana Cache',
    type: PotionType.mp,
    tier: 3,
    healAmount: 60,
    healPercent: 0.20,
    price: 160,
  );

  /// Super Mana Cache - 초대형 MP 물약
  static const superManaCache = Potion(
    id: 'super_mana_cache',
    name: 'Super Mana Cache',
    type: PotionType.mp,
    tier: 4,
    healAmount: 90,
    healPercent: 0.30,
    price: 400,
  );

  /// Ultra Mana Cache - 최고급 MP 물약
  static const ultraManaCache = Potion(
    id: 'ultra_mana_cache',
    name: 'Ultra Mana Cache',
    type: PotionType.mp,
    tier: 5,
    healAmount: 150,
    healPercent: 0.40,
    price: 1000,
  );

  // ============================================================================
  // 물약 목록
  // ============================================================================

  /// 모든 물약 목록
  static const List<Potion> all = [
    // HP 물약
    minorHealthPatch,
    healthPatch,
    majorHealthPatch,
    superHealthPatch,
    ultraHealthPatch,
    // MP 물약
    minorManaCache,
    manaCache,
    majorManaCache,
    superManaCache,
    ultraManaCache,
  ];

  /// HP 물약 목록
  static List<Potion> get hpPotions =>
      all.where((p) => p.type == PotionType.hp).toList();

  /// MP 물약 목록
  static List<Potion> get mpPotions =>
      all.where((p) => p.type == PotionType.mp).toList();

  /// ID로 물약 찾기
  static Potion? getById(String id) {
    for (final potion in all) {
      if (potion.id == id) return potion;
    }
    return null;
  }

  /// 티어별 HP 물약
  static Potion? getHpPotionByTier(int tier) {
    for (final potion in hpPotions) {
      if (potion.tier == tier) return potion;
    }
    return null;
  }

  /// 티어별 MP 물약
  static Potion? getMpPotionByTier(int tier) {
    for (final potion in mpPotions) {
      if (potion.tier == tier) return potion;
    }
    return null;
  }

  /// 레벨에 맞는 HP 물약 티어
  static int tierForLevel(int level) {
    if (level < 10) return 1;
    if (level < 25) return 2;
    if (level < 45) return 3;
    if (level < 70) return 4;
    return 5;
  }
}
