void MainWindow::newGame() { BranchWidget * w = new BranchWidget(fieldSize, cellSize); connect(w, SIGNAL(gameFinished()), this, SLOT(gameFinished())); connect(w, SIGNAL(requestToClose()), this, SLOT(close())); ui.scrollArea->setWidget(w); }
int main() { getNames(); setCombinationNames(); while (gameFinished() == false) { printf("\n%s ist dran!\n\n", players[currentPlayer].name); pause(); for (int i = 1; i <= 3; i++) { //Every time we may throw three times throwDices(); if (i < 3) { if (ask("Nochmal wuerfeln?")) { keepDices(); } else { break; } } } selectCombination(); nextPlayer(); } showPlayerEvalution(); return 0; }
/* * GUI callbacks. */ void KBBGame::callBack( int witch ) { switch (witch) { case ID_HELP: help(); break; case ID_ABOUT: about(); break; case ID_ABOUT_QT: aboutQt(); break; case ID_QUIT: kapp->quit(); break; case ID_NEW: newGame(); break; case ID_GIVEUP: giveUp(); break; case ID_DONE: gameFinished(); break; case ID_RESIZE: setMinSize(); gameResize(); break; } }
void GameScene::showGameOverText(quint32 score) { m_gameOverItem = addPixmap(PixmapCache::gameOverText()); const auto center = m_gameOverItem->boundingRect().center(); m_gameOverItem->setPos(width() / 2 - center.x(), height() / 2 - center.y()); m_paused = true; emit gameFinished(score); }
void GameHandler::checkForNewMoves() { if (StateHandler::getInstance().isEditorMode()) { for (Player* player: this->players) if (player->isMoveReady()) { Move move = player->getMove(); if (this->getSource(move) != NULL) { this->moveTile(move, false); this->game.makeUnsafeMove(move); } } return; } if (this->players[this->currentPlayer]->isTurnFinished()) this->changeCurrentPlayer(); if (this->players[this->currentPlayer]->isMoveReady()) { this->playersTimer.stop(); Move move = this->players[this->currentPlayer]->getMove(); if (this->game.isMoveValid(move) ) { qDebug("Valid move!"); this->moveTile(move); //if the move was the next from the history, increase the index //if not, erase the end of the vector and start appending new moves //forgetting the move if it's not from history: if (this->lastMoveId + 1 < (int)this->turnsHistory[this->currentTurnId].size() && this->turnsHistory[this->currentTurnId][this->lastMoveId + 1] != move) { //a different move this->sendUndoTurn(this->players[this->currentPlayer]->getPlayerInfo().player, this->currentTurnId); this->dropHistoryTail(); } this->lastMoveId++; if ((int)this->turnsHistory[this->currentTurnId].size() == this->lastMoveId) this->turnsHistory[this->currentTurnId].push_back(move); this->game.makeMove(move); emit moveFinished(); } //TODO make this a feature /*if (this->game.getMovesLeft() <= 0 && this->game.getPassessLeft() <= 0) this->changeCurrentPlayer();*/ if (this->game.isFinished()) { qDebug("Game finished!"); emit gameFinished(); return; } this->playersTimer.start(); } }
void MainWindow::generateGame(int level) { if (gameBoard != NULL) delete gameBoard; gameBoard = new Board(level); generateBoard(); connect(gameBoard, SIGNAL(theEnd()), this, SLOT(gameFinished())); counter->setText("Number of moves: " + QString::number(gameBoard->previousMoves.size())); }
void nextPlayer () { resetDicesHolder(); currentPlayer++; if (currentPlayer >= AmountOfPlayers) { if (PlayerFinished(currentPlayer) == true && gameFinished() == false) { printf("%s ist fertig!\n", players[currentPlayer].name); nextPlayer(); } else { currentPlayer = 0; } } }
void PlayField::gameOver(Sea::Player winner) { if (winner == Sea::Player(0)) { const Stats* stats = m_menu->player(0)->stats(); if (stats && qobject_cast<const AIEntity*>(m_menu->player(1))) { KScoreDialog* highscoredialog = new KScoreDialog( KScoreDialog::Name | KScoreDialog::Score | KScoreDialog::Custom1 | KScoreDialog::Custom2 | KScoreDialog::Custom3, this); highscoredialog->initFromDifficulty(Kg::difficulty()); highscoredialog->addField(KScoreDialog::Custom1, i18n("Shots"), "shots"); highscoredialog->addField(KScoreDialog::Custom2, i18n("Hits"), "hits"); highscoredialog->addField(KScoreDialog::Custom3, i18n("Misses"), "water"); KScoreDialog::FieldInfo info; info[KScoreDialog::Name] = m_menu->player(0)->nick(); info[KScoreDialog::Score].setNum(stats->score()); info[KScoreDialog::Custom1] = QString::number(stats->shots()); info[KScoreDialog::Custom2] = QString::number(stats->hits()); info[KScoreDialog::Custom3] = QString::number(stats->misses()); int temp = highscoredialog->addScore(info, KScoreDialog::AskName); qDebug() << "temp =" << temp; //if (highscoredialog->addScore(info, KScoreDialog::AskName)) { if (temp != 0) { highscoredialog->exec(); return; } } m_status_bar->showMessage(i18n("You win!")); if (m_show_endofgame_message) { KMessageBox::information(this, i18n("You win. Excellent!")); } } else { m_status_bar->showMessage(i18n("You lose.")); if (m_show_endofgame_message) { KMessageBox::information(this, i18n("You lose. Better luck next time!")); } } // When we have finished, show again the welcome screen emit gameFinished(); }
void CLlinesDoc::makeMove(int x_source,int y_source,int x, int y) { int col = m_grid[x_source][y_source]; // moveBall(); m_grid[x_source][y_source] = (byte) EMPTY; m_grid[x][y] = (byte)col; // pView->drawCell(x, y); afterMove(x, y); if (!bonusMove) { if (numFree <= 0) { gameFinished(); } else { throwBalls(); } } }
/** * Main Action whe the button is clicked */ void Doppelclick::buttonClicked(void) { if (!gameRunning) { gameRunning = true; startTime = QDateTime::currentMSecsSinceEpoch(); gameStateLabel->setText("<b>Start ...</b>"); gameIcon->setText(NEUTRAL); } else { gameRunning = false; qint64 stopTime = QDateTime::currentMSecsSinceEpoch(); qint64 diffTime = stopTime - startTime; if (diffTime <= timeDifficult) gameIcon->setText(GOOD); else gameIcon->setText(BAD); QString result = "<b>Ergebnis: "; result.append(QString::number(diffTime)); result.append(" </b>"); gameStateLabel->setText(result); emit gameFinished(); } }
void Game::nextGameFrame() { static float chaseTimer = 0.0; static QTime lastFrameTime; if(!lastFrameTime.isNull()) { chaseTimer += lastFrameTime.msecsTo(QTime::currentTime())/1000.0; } lastFrameTime = QTime::currentTime(); Level *level = m_levels.at(m_currentLevel); // Mouvements QList<Ghost*> collision; level->movePacman(); level->moveGhosts(); collision.append(level->checkUnitsPositions()); level->updateTimer(); // if(level->eatenPellets() == level->pelletCount()) { m_timer->stop(); m_currentLevel++; if(m_currentLevel == m_levels.size()) { m_victory = true; emit gameFinished(); return; } else { m_isChangingLevel = true; m_currentLevelImageReady = false; Level *level = m_levels.at(m_currentLevel); level->startLevel(); return; } } if(collision.size() > 0) { if(!Ghost::areGhostsScared()) { m_lifes--; if(m_lifes>0) { level->resetUnitsPosition(); } else { m_defeat = true; emit gameFinished(); return; } m_timer->stop(); } else { for(int i=0; i<collision.size(); i++) { m_score += 200 * qPow(2, m_consecutivesEnergizers); m_consecutivesEnergizers ++; QTimer::singleShot(500, this, SLOT(resumeGame())); m_timer->stop(); } } } if(!Ghost::areGhostsScared()) m_consecutivesEnergizers = 0; QPixmap *image = level->render(); m_image = *image; delete image; m_currentLevelImageReady = true; }
KBBGame::KBBGame() : KTopLevelWidget() { int i; setCaption(QString("KBlackBox ")+KBVERSION); menu = new KMenuBar(this, "menu"); QPopupMenu *game = new QPopupMenu; QPopupMenu *file = new QPopupMenu; sizesm = new QPopupMenu; ballsm = new QPopupMenu; QPopupMenu *help = new QPopupMenu; options = new QPopupMenu; CHECK_PTR( file ); CHECK_PTR( game ); CHECK_PTR( help ); CHECK_PTR( sizesm ); CHECK_PTR( ballsm ); CHECK_PTR( options ); CHECK_PTR( menu ); help->insertItem( trans->translate("&Help"), ID_HELP ); help->setAccel( CTRL+Key_H, ID_HELP ); help->insertSeparator(); help->insertItem( trans->translate("&About KBlackBox"), ID_ABOUT ); help->setAccel( CTRL+Key_A, ID_ABOUT ); help->insertItem( trans->translate("About &Qt"), ID_ABOUT_QT ); file->insertItem( trans->translate("&Quit"), ID_QUIT ); file->setAccel( CTRL+Key_Q, ID_QUIT ); game->insertItem( trans->translate("&New"), ID_NEW ); game->insertItem( trans->translate("&Give up"), ID_GIVEUP ); game->insertItem( trans->translate("&Done"), ID_DONE ); game->insertSeparator(); game->insertItem( trans->translate("&Resize"), ID_RESIZE ); sizes1id = sizesm->insertItem( " 8 x 8 ", this, SLOT(size1()) ); sizes2id = sizesm->insertItem( " 10 x 10 ", this, SLOT(size2()) ); sizes3id = sizesm->insertItem( " 12 x 12 ", this, SLOT(size3()) ); sizesm->setCheckable( TRUE ); balls1id = ballsm->insertItem( " 4 ", this, SLOT(balls1()) ); balls2id = ballsm->insertItem( " 6 ", this, SLOT(balls2()) ); balls3id = ballsm->insertItem( " 8 ", this, SLOT(balls3()) ); ballsm->setCheckable( TRUE ); options->insertItem( trans->translate("&Size"), sizesm ); options->insertItem( trans->translate("&Balls"), ballsm ); tut1id = options->insertItem( trans->translate("&Tutorial"), this, SLOT(tutorialSwitch()) ); options->setCheckable( TRUE ); connect( file, SIGNAL(activated(int)), SLOT(callBack(int)) ); connect( help, SIGNAL(activated(int)), SLOT(callBack(int)) ); connect( game, SIGNAL(activated(int)), SLOT(callBack(int)) ); menu->insertItem( trans->translate("&File"), file ); menu->insertItem( trans->translate("&Game"), game ); menu->insertItem( trans->translate("&Options"), options ); menu->insertSeparator(); menu->insertItem( trans->translate("&Help"), help ); menu->show(); setMenu( menu ); KIconLoader *loader = kapp->getIconLoader(); QPixmap **pix = new QPixmap*[NROFTYPES]; pix[0] = new QPixmap(); *pix[0] = loader->loadIcon( pFNames[0] ); if (!pix[0]->isNull()) { debug( "Pixmap \"%s\" loaded.", pFNames[0] ); for (i = 1; i < NROFTYPES; i++) { pix[i] = new QPixmap; *pix[i] = loader->loadIcon( pFNames[i] ); if (!pix[i]->isNull()) { debug( "Pixmap \"%s\" loaded.", pFNames[i] ); } else { pix[i] = pix[i-1]; pix[i]->detach(); debug( "Cannot find pixmap \"%s\". Using previous one.", pFNames[i] ); } } } else { debug( "Cannot find pixmap \"%s\". Pixmaps will not be loaded.", pFNames[0] ); delete pix[0]; delete pix; pix = NULL; } gr = new KBBGraphic( pix, this ); connect( gr, SIGNAL(inputAt(int,int,int)), this, SLOT(gotInputAt(int,int,int)) ); connect( this, SIGNAL(gameRuns(bool)), gr, SLOT(setInputAccepted(bool)) ); connect( gr, SIGNAL(endMouseClicked()), this, SLOT(gameFinished()) ); /* QToolTip::add( doneButton, trans->translate( "Click here when you think you placed all the balls.") ); */ QString tmps; stat = new KStatusBar( this ); tmps.sprintf( "aaaaaaaa" ); stat->insertItem( (const char *) tmps, SSCORE ); tmps.sprintf( "aaaaaaaaaaa" ); stat->insertItem( (const char *) tmps, SBALLS ); tmps.sprintf( "aaaaaaa" ); stat->insertItem( (const char *) tmps, SRUN ); tmps.sprintf( "aaaaaaaaaa" ); stat->insertItem( (const char *) tmps, SSIZE ); setStatusBar( stat ); tool = new KToolBar( this ); tool->insertButton( loader->loadIcon("exit.xpm"), ID_QUIT, TRUE, trans->translate("Quit") ); tool->insertButton( loader->loadIcon("reload.xpm"), ID_NEW, TRUE, trans->translate("New") ); tool->insertButton( loader->loadIcon("giveup.xpm"), ID_GIVEUP, TRUE, trans->translate("Give up") ); tool->insertButton( loader->loadIcon("done.xpm"), ID_DONE, TRUE, trans->translate("Done") ); tool->insertSeparator(); tool->insertButton( loader->loadIcon("help.xpm"), ID_HELP, TRUE, trans->translate("Help") ); connect( tool, SIGNAL(clicked(int)), SLOT(callBack(int)) ); addToolBar( tool ); tool->setBarPos( KToolBar::Top ); tool->show(); /* Game initializations */ running = FALSE; gameBoard = NULL; KConfig *kConf; int j; kConf = KApplication::getKApplication()->getConfig(); kConf->setGroup( "KBlackBox Setup" ); if (kConf->hasKey( "Balls" )) { i = kConf->readNumEntry( "Balls" ); balls = i; switch (i) { case 4: ballsm->setItemChecked( balls1id, TRUE ); break; case 6: ballsm->setItemChecked( balls2id, TRUE ); break; case 8: ballsm->setItemChecked( balls3id, TRUE ); break; } } else { balls = 4; ballsm->setItemChecked( balls1id, TRUE ); } if ((kConf->hasKey( "Width" )) && (kConf->hasKey( "Balls" ))) { i = kConf->readNumEntry( "Width" ); j = kConf->readNumEntry( "Height" ); gr->setSize( i+4, j+4 ); // +4 is the space for "lasers" and an edge... gameBoard = new RectOnArray( gr->numC(), gr->numR() ); switch (i) { case 8: sizesm->setItemChecked( sizes1id, TRUE ); break; case 10: sizesm->setItemChecked( sizes2id, TRUE ); break; case 12: sizesm->setItemChecked( sizes3id, TRUE ); break; } } else { gr->setSize( 8+4, 8+4 ); // +4 is the space for "lasers" and an edge... gameBoard = new RectOnArray( gr->numC(), gr->numR() ); sizesm->setItemChecked( sizes1id, TRUE ); } if (kConf->hasKey( "tutorial" )) { tutorial = (bool) kConf->readNumEntry( "tutorial" ); } else tutorial = FALSE; options->setItemChecked( tut1id, tutorial ); QString s, s1; int pos; setMinSize(); gameResize(); if (kConf->hasKey( "appsize" )) { s = kConf->readEntry( "appsize" ); debug("%s", (const char *) s); pos = s.find( 'x' ); s1 = s.right( s.length() - pos - 1 ); s.truncate( pos - 1 ); // debug("%s", (const char *) s); // debug("%s", (const char *) s1); resize( s.toInt(), s1.toInt() ); } setScore( 0 ); ballsPlaced = 0; updateStats(); setView( gr ); newGame(); }
void MainWindow::on_diceButton_clicked() { diceRoll1 = (rand() % 6) + 1; diceRoll2 = (rand() % 6) + 1; z.setNum(diceRoll1); ui->dice1_label->setText(z); z.setNum(diceRoll2); ui->dice2_label->setText(z); if (evaluateJail(diceRoll1, diceRoll2)) { int spaceMove = players[curPlayer].curPos + diceRoll1 + diceRoll2; if (spaceMove >= 40) { spaceMove -= 40; } switch (curPlayer) { case 0: ui->player1_char->move(board[spaceMove].xCoord, board[spaceMove].yCoord); break; case 1: ui->player2_char->move(board[spaceMove].xCoord, board[spaceMove].yCoord); break; case 2: ui->player3_char->move(board[spaceMove].xCoord, board[spaceMove].yCoord); break; case 3: ui->player4_char->move(board[spaceMove].xCoord, board[spaceMove].yCoord); break; case 4: ui->player5_char->move(board[spaceMove].xCoord, board[spaceMove].yCoord); break; case 5: ui->player6_char->move(board[spaceMove].xCoord, board[spaceMove].yCoord); break; } tempPlayer = curPlayer; Move(diceRoll1 + diceRoll2); if(board[spaceMove].spaceType == _Property || board[spaceMove].spaceType == _Railroad ||board[spaceMove].spaceType == _Utility) { if (board[spaceMove].owner == -1 && players[curPlayer].money >= board[spaceMove].cost) { displayMessage(board[spaceMove].cost); } else if (evaluateHouse() && players[curPlayer].money >= board[spaceMove].costPerHouse && board[spaceMove].spaceType == _Property) { displayHouse(board[players[curPlayer].curPos].costPerHouse); } else { updateBoard(); } } else { updateBoard(); } } else { Move(0); } if (gameEnd) { gameFinished(); } }
void myGraphicsScene::signalHandler(int stateChangeID, bool continuePreviousGame){ switch(stateChangeID){ case 1: // this is a start new game signal from qml //remove qml UI from scene removeItem(myQmlobject); // If a game was lost ("game over") it's possible to continue from the previously played level if(continuePreviousGame){ myCurrentLevel--; // subtract one, so the when it's ++:d below the same level is displayed that was previously played (and failed) }else{ // This means restart from beginning myCurrentLevel = -1; // this will be incremented to 0 below myTotalTimeUsed = 0; // reset time used myTotalTrapsUsed = 0; // reset trap count } //break; //no break, fall through to next case -> case 2: // this is a "level completed" signal from game. Leave this as "case 2", as "case 1" depends on it being the next. myCurrentLevel++; // if we are already in the game, delete previous level, any enemies and stop timer if (myCurrentLevel > 0 && !continuePreviousGame){ myGameActive = false; // this is used by the event() function myAdvanceTimer.stop(); // stop advance timer myBGItem->disconnect(); // disconnect all signals myBGItem->setVisible(false); // hide myBGItem (necessary?) // increase time used in-game myTotalTimeUsed = myTotalTimeUsed + myBGItem->myReturnTimeUsed(); // increase number of traps used in-game myTotalTrapsUsed = myTotalTrapsUsed + myBGItem->myReturnNumTrapsUsed(); this->clear(); // Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged } if(myCurrentLevel >= myNumLevels){ // No more levels //if(myCurrentLevel >= 1){ // No more levels myGameActive = true; // this is used by the event() function addItem(myQmlobject); emit gameFinished(myTotalTrapsUsed, myTotalTimeUsed); // this displays a screen with end credits (void gameFinished(int numTrapsUsed, int numTimeUsed);) return; } //add game bg to scene, initialise with number of traps available for this level myBGItem = new BGTouch(QPixmap(myBGImageList.at(myCurrentLevel)).scaled(myScreenWidth, myScreenHeight), myCurrentLevel, myTrapCount[myCurrentLevel], myEnemyCount[myCurrentLevel], myTimePerLevel[myCurrentLevel], myBigBossCount[myCurrentLevel]); //Connect touch point information to slot QObject::connect(myBGItem, SIGNAL(bgTouchSignal(int)), this, SLOT(signalHandler(int))); //add to scene addItem(myBGItem); //add Big Bosses myBigBossCount for (int i = 0; i < myBigBossCount[myCurrentLevel]; ++i) { BigBoss *bigboss = new BigBoss(myBGItem); // give myBGItem as parent (and thus when deleting the parent, the "big boss" is automatically deleted) //bigboss->setPos(::sin((i * 6.28) / myBigBossCount[myCurrentLevel]) * 200 + myScreenWidth/2, // ::cos((i * 6.28) / myBigBossCount[myCurrentLevel]) * 200 + myScreenWidth/2); bigboss->setPos(myScreenWidth/2, myScreenWidth/2); bigboss->setMaxSpeedMult(mySpeedMultiplierPerLevel[myCurrentLevel]); //addItem(bigboss); // no need to add to scene as it's added to scene by setting myBGItem as parent connect(bigboss, SIGNAL(creatureKilled(int)), myBGItem, SLOT(creatureSubtractor(int))); connect(bigboss, SIGNAL(creatureKilled(int)), this, SLOT(myRumbleGenerator(int))); // note that allEnemiesKilledEnabler is actually a slot in creature.h but is only used by class bigboss connect(myBGItem, SIGNAL(allEnemiesKilled()), bigboss, SLOT(allEnemiesKilledEnabler())); // this is a way for the big bosses to know when all ordinary enemies are dealt with } //add enemies for (int i = 0; i < myEnemyCount[myCurrentLevel]; ++i) { Enemy *enemy = new Enemy(myBGItem); // give myBGItem as parent (and thus when deleting the parent, the "enemies" are automatically deleted) enemy->setPos(::sin((i * 6.28) / myEnemyCount[myCurrentLevel]) * 200 + myScreenWidth/2, ::cos((i * 6.28) / myEnemyCount[myCurrentLevel]) * 200 + myScreenWidth/2); enemy->setMaxSpeedMult(mySpeedMultiplierPerLevel[myCurrentLevel]); //addItem(enemy); // no need to add to scene as it's added to scene by setting myBGItem as parent connect(enemy, SIGNAL(creatureKilled(int)), myBGItem, SLOT(creatureSubtractor(int))); connect(enemy, SIGNAL(creatureKilled(int)), this, SLOT(myRumbleGenerator(int))); } //add allies for (int i = 0; i < myAllyCount[myCurrentLevel]; ++i) { Ally *ally = new Ally(myBGItem); // give myBGItem as parent (and thus when deleting the parent, the "allies" are automatically deleted) ally->setPos(::sin((i * 6.28) / myAllyCount[myCurrentLevel] + 0.1) * 200 + myScreenWidth/2, ::cos((i * 6.28) / myAllyCount[myCurrentLevel] + 0.1) * 200 + myScreenWidth/2); ally->setMaxSpeedMult(mySpeedMultiplierPerLevel[myCurrentLevel]); //addItem(ally); // no need to add to scene as it's added to scene by setting myBGItem as parent connect(ally, SIGNAL(creatureKilled(int)), myBGItem, SLOT(creatureSubtractor(int))); connect(ally, SIGNAL(creatureKilled(int)), this, SLOT(myRumbleGenerator(int))); } if (myIsMinimised){ // if minimised, don't start game myBGItem->myLevelTimerStop(); // level timer is started automatically when creating a new myBGItem, so stop it here as window is minimised } else myAdvanceTimer.start(1000/25); // / 33); myGameActive = true; // this is used by the event() function break; case 3: // this is a "game over" signal from game // stop timer, remove BG, remove items, return to main menu myGameActive = false; // this is used by the event() function myAdvanceTimer.stop(); // increase time used in-game myTotalTimeUsed = myTotalTimeUsed + myBGItem->myReturnTimeUsed(); // increase number of traps used in-game myTotalTrapsUsed = myTotalTrapsUsed + myBGItem->myReturnNumTrapsUsed(); myBGItem->disconnect(); myBGItem->setVisible(false); this->clear(); // Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged addItem(myQmlobject); myQmlobject->setProperty("levelContinuable", true); break; default: //qDebug() << "Should not be here!"; break; } }
void GameHandler::botCrashed() { emit error("The AI has crashed! :("); this->playersTimer.stop(); emit gameFinished(); }
void GameHandler::changeCurrentPlayer(const bool undo) { this->deselectTiles(); this->players[this->getNextPlayerId()]->startTurn(); this->players[this->currentPlayer]->finishTurn(); if (!undo && this->lastMoveId != (int)this->turnsHistory[currentTurnId].size() - 1) this->dropHistoryTail(); if (!undo) { this->historyHandler.finishTurn(); //for (int i = 0; i < PLAYERS_QTY; ++i) //this->players[i]->play(this->players[this->currentPlayer]->getPlayerInfo().player, //this->turnsHistory[this->currentTurnId]); if ((int)this->turnsHistory.size() <= this->currentTurnId + 1) this->turnsHistory.push_back(vector<Move>()); if ((int)this->movesLeft.size() <= this->currentTurnId + 1) this->movesLeft.push_back(make_pair(2, 1)); this->movesLeft[this->currentTurnId] = make_pair(this->game.getMovesLeft(), this->game.getPassessLeft()); this->currentTurnId++; this->lastMoveId = -1; } else { // qDebug("player change for undo"); bool tmp = true; if (this->currentTurnId > 0) { if (this->turnsHistory[this->currentTurnId].empty()) { // this->turnsHistory.pop_back(); tmp = false; } this->movesLeft.pop_back(); this->currentTurnId--; //TODO stopped here //if (tmp) //this->sendUndoTurn(this->players[this->currentPlayer]->getPlayerInfo().player, //this->currentTurnId + 1); this->lastMoveId = this->turnsHistory[this->currentTurnId].size() - 1; } else { this->currentTurnId = 0; this->lastMoveId = -1; } } this->currentPlayer = this->getNextPlayerId(); this->game.setCurrentPlayer(engine::getOppositePlayer(this->game.getCurrentPlayer()), this->movesLeft[this->currentTurnId].first, this->movesLeft[this->currentTurnId].second); qDebug("Next player! %s", qPrintable(this->players[this->currentPlayer]->getPlayerInfo().name)); if (this->hintAI != NULL) this->hintAI->gameChanged(this->game); //hashes if (!undo) { //new configuration QString h = QString::fromStdString(this->game.getHash()); if (this->hashes.contains(h)) { //state repetition - draw this->game.setCurrentPlayer(NONE); emit gameFinished(); return; } this->hashes.insert(h); this->hashesHistory.push_back(h); } else { this->hashes.remove(hashesHistory.back()); this->hashesHistory.pop_back(); } emit playerChanged(); }