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

#include "LudoGameState.h"

const std::vector<ludo::Piece> & ludo::LudoGameState::getPieces() const {
    return m_pieces;
}

std::vector<int> ludo::LudoGameState::getFreeHomePositions(PlayerColor color) const {
    std::vector<int> freeHomePositions;
    for (int i = 0; i < kHomePiecesPerPlayer; ++i) {
        bool occupied = false;
        for (const auto& piece : m_pieces) {
            if (piece.color == color && piece.state == PieceState::AtHome && piece.position == i) {
                occupied = true;
            }
        }

        if (!occupied) freeHomePositions.push_back(i);
    }
    return freeHomePositions;
}

int ludo::LudoGameState::getDiceValue() const {
    return m_diceValue;
}

ludo::TurnPhase ludo::LudoGameState::getPhase() const {
    return m_phase;
}

ludo::PlayerColor ludo::LudoGameState::getColorOfPieceIndex(int pieceIndex) const {
    return m_pieces[pieceIndex].color;
}
