You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
918 B
C++
31 lines
918 B
C++
#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];
|
|
}
|