//
// Created by sebastian on 02.08.26.
//

#ifndef COLORRACE_LUDOGAMESTATE_H
#define COLORRACE_LUDOGAMESTATE_H
#include <vector>

#include "LudoTypes.h"
#include "game/GameState.h"


namespace ludo {
    class LudoGameState: public engine::GameState {
    public:
        explicit LudoGameState(const std::vector<engine::PlayerID>& playerIDs) {
            for (const auto& playerID : playerIDs) {
                PlayerColor playerColor = getColorOf(playerID, playerIDs);
                for (int i = 0; i < 4; i++) {
                    auto piece = Piece(playerColor, PieceState::AtHome, i);
                    m_pieces.push_back(piece);
                }
            }
        };
        [[nodiscard]] const std::vector<Piece> &getPieces() const;
        [[nodiscard]] std::vector<int> getFreeHomePositions(PlayerColor color) const;
        [[nodiscard]] int getDiceValue() const;
        [[nodiscard]] TurnPhase getPhase() const;
        [[nodiscard]] PlayerColor getColorOfPieceIndex(int pieceIndex) const;
    private:
        friend class LudoGameMode;
        std::vector<Piece> m_pieces;
        int m_diceValue = 0;
        TurnPhase m_phase = TurnPhase::AwaitingRoll;
        int m_consecutiveSixes = 0;
    };

}

#endif //COLORRACE_LUDOGAMESTATE_H
