diff --git a/Chinczyk188/Engine.cpp b/Chinczyk188/Engine.cpp index c6ddb17..62ffdf3 100644 --- a/Chinczyk188/Engine.cpp +++ b/Chinczyk188/Engine.cpp @@ -52,11 +52,13 @@ void Engine::nextTurn() { std::cout << "Ruch gracza " << currentPlayer.getName() << " (" << colorNames[currentPlayer.getColor()] << ").\n"; + // Rysuj pionki + // ... + // Rzut kostką if (dicerollLoaded) this->dicerollBuffer.play(); int diceRoll = rollDice(currentPlayer.getSeed(), currentPlayer.getRollCount()); std::cout << "Wylosowano " << diceRoll << ".\n"; - currentPlayer.incrementRollCount(); this->board.smartSleep(1000); // Wybieranie pionka @@ -70,6 +72,7 @@ void Engine::nextTurn() { // 0 pionków na planszy - musi wyjść pionkiem case 0: std::cout << currentPlayer.getName() << " wychodzi pierwszym pionkiem z bazy.\n"; + currentPlayer.hasLeftBase = true; currentPlayer.pawnsAtBase--; currentPlayer.pawnsActive++; this->pawnmoveBuffer.play(); @@ -190,13 +193,25 @@ void Engine::nextTurn() { // } if (currentPlayer.hasWon()) { + // Zostanie wykorzystane do zwiększenia liczby wygranych this->tadaBuffer.play(); this->winnerNickname = currentPlayer.getName(); announceWinner(currentPlayer); + } else { - // Iteruj po wektorze z graczami - currentPlayerIndex = (currentPlayerIndex + 1) % players.size(); + + currentPlayer.incrementRollCount(); + + if (!currentPlayer.hasLeftBase && currentPlayer.getRollCount() % 3 != 0) { + // Jeśli gracz nie wyszedł z bazy i nie wyrzucił kostki trzy razy pod rząd, + // zaktualizuj liczbę losowań, ale pozwól mu spróbować ponownie. + } else { + // Jeśli gracz wyszedł z bazy, albo rzucił kostką trzy razy pod rząd, + // daj szansę kolejnemu graczowi... pod warunkiem, że nie wyrzucono 6. + if (diceRoll != 6) this->currentPlayerIndex = (this->currentPlayerIndex + 1) % this->players.size(); + } + } this->board.smartSleep(1000); diff --git a/Chinczyk188/Player.hpp b/Chinczyk188/Player.hpp index 56b3333..c594086 100644 --- a/Chinczyk188/Player.hpp +++ b/Chinczyk188/Player.hpp @@ -25,6 +25,7 @@ class Player { short pawnsAtHome = 0; bool hasWon() const; + bool hasLeftBase = false; private: std::string name;