implement proper dice-rolling mechanic, as seen on Wikipedia
This commit is contained in:
@@ -52,11 +52,13 @@ void Engine::nextTurn() {
|
|||||||
std::cout << "Ruch gracza " << currentPlayer.getName()
|
std::cout << "Ruch gracza " << currentPlayer.getName()
|
||||||
<< " (" << colorNames[currentPlayer.getColor()] << ").\n";
|
<< " (" << colorNames[currentPlayer.getColor()] << ").\n";
|
||||||
|
|
||||||
|
// Rysuj pionki
|
||||||
|
// ...
|
||||||
|
|
||||||
// Rzut kostką
|
// Rzut kostką
|
||||||
if (dicerollLoaded) this->dicerollBuffer.play();
|
if (dicerollLoaded) this->dicerollBuffer.play();
|
||||||
int diceRoll = rollDice(currentPlayer.getSeed(), currentPlayer.getRollCount());
|
int diceRoll = rollDice(currentPlayer.getSeed(), currentPlayer.getRollCount());
|
||||||
std::cout << "Wylosowano " << diceRoll << ".\n";
|
std::cout << "Wylosowano " << diceRoll << ".\n";
|
||||||
currentPlayer.incrementRollCount();
|
|
||||||
this->board.smartSleep(1000);
|
this->board.smartSleep(1000);
|
||||||
|
|
||||||
// Wybieranie pionka
|
// Wybieranie pionka
|
||||||
@@ -70,6 +72,7 @@ void Engine::nextTurn() {
|
|||||||
// 0 pionków na planszy - musi wyjść pionkiem
|
// 0 pionków na planszy - musi wyjść pionkiem
|
||||||
case 0:
|
case 0:
|
||||||
std::cout << currentPlayer.getName() << " wychodzi pierwszym pionkiem z bazy.\n";
|
std::cout << currentPlayer.getName() << " wychodzi pierwszym pionkiem z bazy.\n";
|
||||||
|
currentPlayer.hasLeftBase = true;
|
||||||
currentPlayer.pawnsAtBase--;
|
currentPlayer.pawnsAtBase--;
|
||||||
currentPlayer.pawnsActive++;
|
currentPlayer.pawnsActive++;
|
||||||
this->pawnmoveBuffer.play();
|
this->pawnmoveBuffer.play();
|
||||||
@@ -190,13 +193,25 @@ void Engine::nextTurn() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (currentPlayer.hasWon()) {
|
if (currentPlayer.hasWon()) {
|
||||||
|
|
||||||
// Zostanie wykorzystane do zwiększenia liczby wygranych
|
// Zostanie wykorzystane do zwiększenia liczby wygranych
|
||||||
this->tadaBuffer.play();
|
this->tadaBuffer.play();
|
||||||
this->winnerNickname = currentPlayer.getName();
|
this->winnerNickname = currentPlayer.getName();
|
||||||
announceWinner(currentPlayer);
|
announceWinner(currentPlayer);
|
||||||
|
|
||||||
} else {
|
} 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);
|
this->board.smartSleep(1000);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class Player {
|
|||||||
short pawnsAtHome = 0;
|
short pawnsAtHome = 0;
|
||||||
|
|
||||||
bool hasWon() const;
|
bool hasWon() const;
|
||||||
|
bool hasLeftBase = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|||||||
Reference in New Issue
Block a user