#pragma once

#include <cstdint>

namespace GameConfig {

    // Mode de juego
    enum class Mode : std::uint8_t {
        NORMAL,  // Partida normal
        DEMO     // Mode demostració (futur)
    };

    // Configuración de una match
    struct MatchConfig {
        bool player1_active{false};  // Es active el player 1?
        bool player2_active{false};  // Es active el player 2?
        Mode mode{Mode::NORMAL};     // Mode de juego

        // Métodos auxiliars

        // Retorna true si solo hay un player active
        [[nodiscard]] auto isSinglePlayer() const -> bool {
            return (player1_active && !player2_active) ||
                (!player1_active && player2_active);
        }

        // Retorna true si hay dos jugadors active
        [[nodiscard]] auto isCoop() const -> bool {
            return player1_active && player2_active;
        }

        // Retorna true si no hay sin player active
        [[nodiscard]] auto hasNoPlayers() const -> bool {
            return !player1_active && !player2_active;
        }

        // Compte de jugadors active (0, 1 o 2)
        [[nodiscard]] auto getPlayerCount() const -> uint8_t {
            return (player1_active ? 1 : 0) + (player2_active ? 1 : 0);
        }

        // Retorna l'ID de l'únic player active (0 o 1)
        // Solo vàlid si es_un_jugador() retorna true
        [[nodiscard]] auto getSinglePlayerId() const -> uint8_t {
            if (player1_active && !player2_active) {
                return 0;
            }
            if (!player1_active && player2_active) {
                return 1;
            }
            return 0;  // Fallback (necesario comprovar es_un_jugador() primer)
        }
    };

}  // namespace GameConfig
