SevenCardStud.cpp
//
// SevenCardStud::before_round()
// shuffle the main_deck and deal cards to players
// each player would have 2 down cards and 1 up card
//

:before_round()
shuffle the main_deck and deal cards to players
each player would have 2 down cards and 1 up card
: before_round () shuffle the main_deck and deal cards to players each player would have 2 down cards and 1 up card
int SevenCardStud::before_round()
{
	cout << endl;
	cout << "The round is about to begin! Prepare to play some Seven Card Stud!" << endl;
	totalPot = 0;
	cout << "Collecting Ante" << endl;
	collectAnte();
	main_deck.shuffle();
	int nextPlayer = 1;
	const unsigned int downCardsPerPlayer = 2;
	const unsigned int upCardsPerPlayer = 1;
	int dealToIndex = dealer_index;
	if (players.size()*downCardsPerPlayer + players.size()*upCardsPerPlayer > main_deck.size()){
		throw errors::not_enough_cards;
	}
	for (unsigned int j = 0; j < players.size(); ++j)
	{
		dealToIndex = (dealToIndex + nextPlayer) % players.size();
		while ((*players[dealToIndex]).downCards.size() < downCardsPerPlayer)
		{
			players[dealToIndex]->downCards << main_deck;
		}
		while ((*players[dealToIndex]).upCards.size() < upCardsPerPlayer)
		{
			players[dealToIndex]->upCards << main_deck;
		}
	}
	for (auto it = players.begin(); it < players.end(); it++){
		(*it)->folded = false;
	}
	bet();
	if (!allButOneFolded()){
		unsigned int i = 0;
		dealToIndex = dealer_index;
		while (i < players.size())
		{
			dealToIndex = (dealToIndex + nextPlayer) % players.size();
			before_turn(*players[dealToIndex]);
			i++;
		}
	}
	return errors::noError;
}
int SevenCardStud :: before_round ( ) { cout << endl ; cout << " " << endl ; totalPot = 0 ; cout << " " << endl ; collectAnte ( ) ; main_deck . shuffle ( ) ; int nextPlayer = 1 ; const unsigned int downCardsPerPlayer = 2 ; const unsigned int upCardsPerPlayer = 1 ; int dealToIndex = dealer_index ; if ( players . size ( ) * downCardsPerPlayer + players . size ( ) * upCardsPerPlayer > main_deck . size ( ) ) { throw errors :: not_enough_cards ; } for ( unsigned int j = 0 ; j < players . size ( ) ; ++ j ) { dealToIndex = ( dealToIndex + nextPlayer ) % players . size ( ) ; while ( ( * players [ dealToIndex ] ) . downCards . size ( ) < downCardsPerPlayer ) { players [ dealToIndex ] -> downCards << main_deck ; } while ( ( * players [ dealToIndex ] ) . upCards . size ( ) < upCardsPerPlayer ) { players [ dealToIndex ] -> upCards << main_deck ; } } for ( auto it = players . begin ( ) ; it < players . end ( ) ; it ++ ) { ( * it ) -> folded = false ; } bet ( ) ; if ( ! allButOneFolded ( ) ) { unsigned int i = 0 ; dealToIndex = dealer_index ; while ( i < players . size ( ) ) { dealToIndex = ( dealToIndex + nextPlayer ) % players . size ( ) ; before_turn ( * players [ dealToIndex ] ) ; i ++ ; } } return errors :: noError ; }
SevenCardStud::before_round()
shuffle the main_deck and deal cards to players
each player would have 2 down cards and 1 up card
SevenCardStud :: before_round () shuffle the main_deck and deal cards to players each player would have 2 down cards and 1 up card