import 'package:flutter/material.dart';
import '../enums.dart';

class BattleConfig {
  // Icons
  static const IconData attackIcon = Icons.flash_on;
  static const IconData defendIcon = Icons.shield;

  // Colors
  static const Color riskyColor = Colors.orangeAccent;
  static const Color normalColor = Colors.white;
  static const Color safeColor = Colors.grey;

  // Layout & Animation
  static const int feedbackCooldownMs = 300;
  static const double damageTextOffsetY = -20.0;
  static const double damageTextOffsetX = -20.0;

  // Effect Offsets (Relative to Card Size)
  static const double effectEnemyOffsetX = 0.1; // 10%
  static const double effectEnemyOffsetY = 0.8; // 80%
  static const double effectPlayerOffsetX = 0.8; // 80%
  static const double effectPlayerOffsetY = 0.2; // 20%

  // Logs
  static const double logsOverlayHeight = 150.0;

  static const Color defendRiskyColor = Colors.deepPurpleAccent;
  static const Color defendNormalColor = Colors.blueAccent;
  static const Color defendSafeColor = Colors.greenAccent;

  // Sizes
  static const double sizeRisky = 80.0;
  static const double sizeNormal = 60.0;
  static const double sizeSafe = 40.0;

  // Damage Text Scale
  static const double damageScaleNormal = 1.0;
  static const double damageScaleHigh = 3.0;
  static const int highDamageThreshold = 15;

  // Logic Constants
  // Safe
  static const double safeBaseChance = 1.0; // 100%
  static const double attackSafeEfficiency = 0.5; // 50%
  static const double defendSafeEfficiency = 1.0; // 100%
  // Normal
  static const double normalBaseChance = 0.8; // 80%
  static const double attackNormalEfficiency = 1.0; // 100%
  static const double defendNormalEfficiency = 2.0; // 150%
  // Risky
  static const double riskyBaseChance = 0.4; // 40%
  static const double attackRiskyEfficiency = 2.0; // 200%
  static const double defendRiskyEfficiency = 3.0; // 300%

  // Enemy Logic
  static const double enemyAttackChance = 0.7; // 70% Attack, 30% Defend

  static IconData getIcon(ActionType type) {
    switch (type) {
      case ActionType.attack:
        return attackIcon;
      case ActionType.defend:
        return defendIcon;
    }
  }

  static Color getColor(ActionType type, RiskLevel risk) {
    if (type == ActionType.attack) {
      switch (risk) {
        case RiskLevel.risky:
          return riskyColor;
        case RiskLevel.normal:
          return normalColor;
        case RiskLevel.safe:
          return safeColor;
      }
    } else {
      switch (risk) {
        case RiskLevel.risky:
          return defendRiskyColor;
        case RiskLevel.normal:
          return defendNormalColor;
        case RiskLevel.safe:
          return defendSafeColor;
      }
    }
  }

  static double getSize(RiskLevel risk) {
    switch (risk) {
      case RiskLevel.risky:
        return sizeRisky;
      case RiskLevel.normal:
        return sizeNormal;
      case RiskLevel.safe:
        return sizeSafe;
    }
  }

  static String getFeedbackText(BattleFeedbackType type) {
    switch (type) {
      case BattleFeedbackType.miss:
        return "MISS";
      case BattleFeedbackType.failed:
        return "FAILED";
      case BattleFeedbackType.dodge:
        return "DODGE";
    }
  }

  static Color getFeedbackColor(BattleFeedbackType type) {
    switch (type) {
      case BattleFeedbackType.miss:
        return Colors.redAccent; // Or use ThemeConfig.missText if preferred
      case BattleFeedbackType.failed:
        return Colors.orangeAccent; // Or use ThemeConfig.failedText
      case BattleFeedbackType.dodge:
        return Colors.greenAccent; // Or use ThemeConfig.statLuckColor
    }
  }
}
