import 'package:flutter/material.dart';
import '../../providers.dart';
import '../../game/config.dart';
import 'package:provider/provider.dart';

class BattleHeader extends StatelessWidget {
  const BattleHeader({super.key});

  String _getStageDisplayString(int stage) {
    // Tier 1: 1-12 -> Underground Illegal Arena
    // Tier 2: 13-24 -> Colosseum
    // Tier 3: 25-36 -> King's Arena

    final int tier = (stage - 1) ~/ 12 + 1;
    final int round = (stage - 1) % 12 + 1;
    String tierName = "";

    switch (tier) {
      case 1:
        tierName = "지하 불법 투기장";
        break;
      case 2:
        tierName = "콜로세움";
        break;
      case 3:
      default:
        tierName = "왕의 투기장";
        break;
    }

    if (round == 12) {
      return "$tierName - BOSS";
    }

    return "$tierName - $round";
  }

  @override
  Widget build(BuildContext context) {
    final battleProvider = context.watch<BattleProvider>();

    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Flexible(
            child: FittedBox(
              fit: BoxFit.scaleDown,
              child: Text(
                _getStageDisplayString(battleProvider.stage),
                style: const TextStyle(
                  color: ThemeConfig.textColorWhite,
                  fontSize: ThemeConfig.fontSizeLarge,
                  fontWeight: ThemeConfig.fontWeightBold,
                ),
              ),
            ),
          ),
          Flexible(
            child: FittedBox(
              fit: BoxFit.scaleDown,
              child: Text(
                "${AppStrings.turn} ${battleProvider.turnCount}",
                style: const TextStyle(
                  color: ThemeConfig.textColorWhite,
                  fontSize: ThemeConfig.fontSizeHeader,
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
