#include "samegame.h"

// ist es nicht cool?
extern std::unique_ptr<QSettings> settings;

void SameGame::initialiseGameMatrix(int rows, int columns) {
    gameMatrix = std::vector<std::vector<QString>>();

    srand (time(NULL));
    std::vector<QString> t_row;
    for (int i = 0; i < rows; i++) {
        t_row.clear();
        for (int j = 0; j < columns; j++) {
            // wähle zufällige Farbe aus den verfügbaren Farben
            t_row.push_back( colors[rand() % colors.size()] );
        }
        gameMatrix.push_back(std::move(t_row));
    }
}

SameGame::SameGame(int rows, int columns)
    : colors(settings->value("colors/colors", QStringList() << "0xBD005E" << "0xFFC0CB" << "0xDB7093" << "0xF7A8B8" << "0x660033").toStringList())
    // also ich finds echt cool!
{
    initialiseGameMatrix(rows, columns);
}

QString SameGame::getCell(int row, int column) {
    return gameMatrix[row][column];
}
