🚧 Added provisional "Game over" status text

main
Isabell Pflug 12 months ago
parent 576295b049
commit c01b6fddb4

@ -44,6 +44,22 @@ void MainWindow::checkColumn(int column) {
}
}
bool MainWindow::checkLeftoverMoves() {
for(int row = 0; row < rows; row++) {
for(int column = 0; column < columns; column++)
{
if (game->getCell(row,column) != "none") {
std::set<std::vector<int>> tset;
game->getConnected(&tset, game->getCell(row,column), row, column);
if (tset.size() > 1) {
return true;
}
}
}
}
return false;
}
void MainWindow::bubbleRight(int column) {
if (column < columns-1) {
for (int row = 0; row < rows; row++) {
@ -92,9 +108,13 @@ void MainWindow::buttonPressed(int row, int column) {
ui->statusBar->showMessage("Only friends get Stars!", 2000);
}
MainWindow::setEnabled(true);
if (!checkLeftoverMoves()) {
ui->statusBar->showMessage("Game over.");
}
}
void MainWindow::newGame() {
ui->statusBar->clearMessage();
MainWindow::setEnabled(false);
QMessageBox newGameDialog;
newGameDialog.setText("Do you really want to start a new game?");
@ -105,6 +125,9 @@ void MainWindow::newGame() {
ui->lcdScore->display(0);
}
MainWindow::setEnabled(true);
if (!checkLeftoverMoves()) {
ui->statusBar->showMessage("Game over.");
}
}
// initialisation functions

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

Loading…
Cancel
Save