|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
#include "samegame.h"
|
|
|
|
|
|
|
|
|
|
// ist es nicht cool?
|
|
|
|
|
extern std::unique_ptr<QSettings> settings;
|
|
|
|
|
|
|
|
|
|
void SameGame::initialiseGameMatrix(int rows, int columns) {
|
|
|
|
@ -11,7 +10,6 @@ void SameGame::initialiseGameMatrix(int rows, int columns) {
|
|
|
|
|
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));
|
|
|
|
@ -20,7 +18,6 @@ void SameGame::initialiseGameMatrix(int rows, int columns) {
|
|
|
|
|
|
|
|
|
|
SameGame::SameGame(int rows, int columns)
|
|
|
|
|
: colors(settings->value("colors/colors", QList<QVariant>() << "#A90A5A" << "#FFD1D9" << "#DB7093" << "#F7A8B8" << "#660033").toStringList())
|
|
|
|
|
// also ich finds echt cool!
|
|
|
|
|
{
|
|
|
|
|
initialiseGameMatrix(rows, columns);
|
|
|
|
|
}
|
|
|
|
@ -34,11 +31,8 @@ void SameGame::setCell(int row, int column, QString color) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SameGame::checkNeighbour(std::set<std::vector<int>> *connectedSet, QString color, int row, int column) {
|
|
|
|
|
// check for grid boundaries
|
|
|
|
|
if (row > -1 && column > -1 && (unsigned long) row < gameMatrix.size() && (unsigned long) column < gameMatrix[0].size()) {
|
|
|
|
|
// check if already visited
|
|
|
|
|
if ( !(connectedSet->contains(std::vector<int>{row, column})) ) {
|
|
|
|
|
// check color
|
|
|
|
|
if (gameMatrix[row][column] == color)
|
|
|
|
|
getConnected(connectedSet, color, row, column);
|
|
|
|
|
}
|
|
|
|
|