Example #1
0
void gameLoop( Game &game )
{
  game.dealCards();
  
  if( game.isBotsOnly() )
    game.showPlayersCards();

  if( !game.takeBiddings() )
  {
    cout << "All players passed." << endl;
    return;
  }

  if( game.getNumberPlayers() == 5 )
    game.chooseKing();
  
  game.takeDog();

  cout << "Taker: " << game.getTakers() << endl;
  if( game.getNumberPlayers() <= 5 )
    cout << "Defenders: " << game.getDefenders() << endl;

  if( game.isBotsOnly() )
    game.showPlayersCards();

  for( int round = 0; round < game.getCardsPerPlayer(); ++round )
  {
    string roundString("Round ");
    roundString += to_string( round + 1 );
    printRound( roundString );

    auto trick = game.playTrick();
    cout << "Trick: ";
    trick->showAllCards();
    cout << "=> Won by " << trick->getLeader()->name << endl;
  }

  Team winners = game.endGame();

  cout << "Won cards:" << endl;
  for( auto player : game.getPlayers() )
  {
    cout << player->name << ": ";
    for( auto card : game.getPlayerWonCards( player ) )
      cout << *card << " ";
    cout << endl;
  }

  if( !winners.isEmpty() )
  {
    game.printScores();  
    cout << "Winners: " << winners << endl;
  }
}