🐛 Fixed checking of empty columns

main
Isabell Pflug 1 year ago
parent f8d9eb1a50
commit 643939180d

@ -14,7 +14,6 @@ void MainWindow::clearConnected(std::set<std::vector<int>> *connected) {
qApp->processEvents();
usleep(550000);
for (auto i = connected->begin(); i != connected->end(); i++) {
//buttonGrid[(*i)[0]][(*i)[1]]->setEnabled(false);
game->deleteCell((*i)[0], (*i)[1]);
}
refreshButtonGrid();
@ -34,6 +33,19 @@ void MainWindow::refreshButtonGrid() {
ui->gameGridLayout->addWidget(buttonGrid[i][j], i, j);
}
}
qApp->processEvents();
}
void MainWindow::checkColumn(int column) {
bool isEmpty;
isEmpty = true;
for (int row = 0; row < rows; row++) {
if (game->getCell(row, column) != "")
isEmpty = false;
}
if (isEmpty) {
bubbleRight(column);
}
}
void MainWindow::bubbleRight(int column) {
@ -61,15 +73,12 @@ void MainWindow::bubbleBoxes(std::set<std::vector<int>> *connected) {
for (auto i = connected->begin(); i != connected->end(); i++) {
bubbleUp((*i)[0], (*i)[1]);
}
bool isEmpty;
refreshButtonGrid();
qApp->processEvents();
usleep(400000);
for (int j = 0; j < columns; j++) {
isEmpty = true;
for (int i = 0; i < rows; i++) {
if (game->getCell(i, j) != "")
isEmpty = false;
}
if (isEmpty)
bubbleRight(j);
for (int x = 0; x < columns; x++)
checkColumn(j);
}
refreshButtonGrid();
}
@ -82,9 +91,9 @@ void MainWindow::buttonPressed(int row, int column) {
if ( connected.size() > 1) {
clearConnected(&connected);
bubbleBoxes(&connected);
}
} else
ui->statusBar->showMessage("Only friends get Stars!", 2000);
} else
ui->statusBar->showMessage("Only friends get Stars!", 2000);
}
}
void MainWindow::newGame() {

@ -32,6 +32,7 @@ public:
void clearConnected(std::set<std::vector<int>> *connected);
void refreshButtonGrid();
void refreshSizes();
void checkColumn(int column);
void bubbleRight(int column);
void bubbleUp(int row, int column);
void bubbleBoxes(std::set<std::vector<int>> *connected);

Loading…
Cancel
Save