#include "Menu.h"

#include "PiecesList.h"
#include "Player.h"
#include "Game.h"

#include <memory>

static const int DEFAULT_BOARD_WIDTH = 10;  // the default width of the board when starting the menu
static const int DEFAULT_BOARD_HEIGHT = 20; // the default height of the board when starting the menu


Menu::Menu() {
    this->piecesList = std::make_shared<PiecesList>(PiecesList());

    this->boardWidth = DEFAULT_BOARD_WIDTH;
    this->boardHeight = DEFAULT_BOARD_HEIGHT;
}

Game Menu::startGame(Gamemode gamemode) const {
    return Game(gamemode, this->playerControls, this->boardWidth, this->boardHeight, this->piecesList);
}

bool Menu::setBoardWidth(int width) {
    if (width < 1) return false;

    this->boardWidth = width;
    return true;
}

bool Menu::setBoardHeight(int height) {
    if (height < 1) return false;

    this->boardHeight = height;
    return true;
}

int Menu::getBoardWidth() const {
    return this->boardWidth;
}

int Menu::getBoardHeight() const {
    return this->boardHeight;
}

Player& Menu::getPlayerControls() {
    return this->playerControls;
}

const Player& Menu::readPlayerControls() const {
    return this->playerControls;
}

PiecesList& Menu::getPiecesList() {
    return *this->piecesList;
}

const PiecesList& Menu::readPiecesList() const {
    return *this->piecesList;
}
