#pragma once
#include <vector>
#include <hotseatgame/unitsqueue.h>
#include <playermanager.h>
#include <QGraphicsView>

class Cell;

class GameManager : public QObject
{
    Q_OBJECT

public:

    static GameManager& getInstance() {
        static GameManager instance;
        return instance;
    }

    void buildGameTable(double start_x_coordinate, double start_y_coordinate);

    UnitsQueue* getTurnQueue();

    void AddToUnitQueue(Unit* unit);

    void RmFromUnitQueue(Unit* unit);

    Player* getCurrentPlayer();

    int getCurPlayerId();

    std::vector<std::vector<Cell *> > getGameField();

private:
    explicit GameManager(QObject *parent = nullptr);

    std::vector< std::vector< Cell* > > game_table_;
    double start_x_coordinate_, start_y_coordinate_;

    void generateTable();

    /******************************/
    UnitsQueue turn_queue_;
    PlayerManager* player_manager_;
    int cur_player_id_;
};
