FiveCardDraw.cpp
//
// FiveCardDraw::after_round()
// sort and print out players by their hand strength (strongest to weakest)
// retrieve the cards from players for next game
// letting players to drop out of the game and other players to join
//

:after_round()
sort and print out players by their hand strength (strongest to weakest)
retrieve the cards from players for next game
letting players to drop out of the game and other players to join
: after_round () sort and print out players by their hand strength ( strongest to weakest ) retrieve the cards from players for next game letting players to drop out of the game and other players to join
int FiveCardDraw::after_round()
{
	cout << endl;
	cout << "The round has come to a close here are the post round stats: " << endl;
	const int empty = 0;
	vector<shared_ptr<Player>> tmpPlayers;
	for (auto it = players.begin(); it != players.end(); it++){
		if (!(*it)->folded){
			tmpPlayers.push_back(*it);
		}
	}
	sort(tmpPlayers.begin(), tmpPlayers.end(), player_rank);
	for (auto it = tmpPlayers.begin(); it != tmpPlayers.end(); ++it)
	{
		if (poker_rank((*it)->hand, (*tmpPlayers.begin())->hand) == poker_rank((*tmpPlayers.begin())->hand, (*it)->hand))
		{
			(*it)->win++;
			(*it)->chips += totalPot;
		}
		else
		{
			(*it)->lose++;
		}
		cout << *(*it) << " current chips: " << (*it)->chips << endl;
		cout << (*it)->hand << endl;
	}
	for (auto it = players.begin(); it != players.end(); it++){
		if ((*it)->folded){
			(*it)->lose++;
			cout << *(*it) << " (FOLDED)" << " current chips: " << (*it)->chips << endl;
		}
	}
	for (auto it = players.begin(); it != players.end(); ++it)
	{
		for (auto i = 0; i < (*it)->hand.size(); ++i)
		{
			main_deck.addCard((*it)->hand[i]);
		}
		(*it)->hand = Hand();
	}
	while (discard_deck.size() != empty)
	{
		main_deck << discard_deck;
	}
	string response = "";
	string saidNo = "no";
	cout << "Anybody wanna call it quits?" << endl;
	getline(cin, response);
	while (response != saidNo)
	{
		istringstream iss(response);
		string word;
		while (iss >> word) {
			shared_ptr<Player> p = find_player(word);
			if (p != nullptr) {
				ofstream ofs;
				ofs.open(word);
				ofs << p->name << endl;
				ofs << p->win << endl;
				ofs << p->lose << endl;
				ofs << p->chips << endl;
				ofs.close();
				remove_player(word);
			}
		}
		cout << "Anybody wanna call it quits?" << endl;
		getline(cin, response);
	}
	string response2 = "";
	cout << "Anybody wanna join?" << endl;
	getline(cin, response2);
	while (response2 != saidNo)
	{
		istringstream iss2(response2);
		string word;
		const int AIOffset = 1;
		const int beginIndex = 0;
		while (iss2 >> word) {
			try{
				bool isAI = false;
				add_player(word, isAI);
			}
			catch (...){
			}
		}
		cout << "Anybody wanna join?" << endl;
		getline(cin, response2);
	}
	int lastPlayer = 1;
	if (players.size() == lastPlayer){
		int playerIndex = 0;
		shared_ptr<Player> p = players[playerIndex];
		ofstream ofs;
		ofs.open(p->name);
		ofs << p->name << endl;
		ofs << p->win << endl;
		ofs << p->lose << endl;
		ofs << p->chips << endl;
		ofs.close();
		remove_player(p->name);
	}
	int nextPlayer = 1;
	if (players.size() != empty)
	{
		dealer_index = (dealer_index + nextPlayer) % players.size();
	}
	return errors::noError;
}
int FiveCardDraw :: after_round ( ) { cout << endl ; cout << " " << endl ; const int empty = 0 ; vector < shared_ptr < Player > > tmpPlayers ; for ( auto it = players . begin ( ) ; it != players . end ( ) ; it ++ ) { if ( ! ( * it ) -> folded ) { tmpPlayers . push_back ( * it ) ; } } sort ( tmpPlayers . begin ( ) , tmpPlayers . end ( ) , player_rank ) ; for ( auto it = tmpPlayers . begin ( ) ; it != tmpPlayers . end ( ) ; ++ it ) { if ( poker_rank ( ( * it ) -> hand , ( * tmpPlayers . begin ( ) ) -> hand ) == poker_rank ( ( * tmpPlayers . begin ( ) ) -> hand , ( * it ) -> hand ) ) { ( * it ) -> win ++ ; ( * it ) -> chips += totalPot ; } else { ( * it ) -> lose ++ ; } cout << * ( * it ) << " " << ( * it ) -> chips << endl ; cout << ( * it ) -> hand << endl ; } for ( auto it = players . begin ( ) ; it != players . end ( ) ; it ++ ) { if ( ( * it ) -> folded ) { ( * it ) -> lose ++ ; cout << * ( * it ) << " " << " " << ( * it ) -> chips << endl ; } } for ( auto it = players . begin ( ) ; it != players . end ( ) ; ++ it ) { for ( auto i = 0 ; i < ( * it ) -> hand . size ( ) ; ++ i ) { main_deck . addCard ( ( * it ) -> hand [ i ] ) ; } ( * it ) -> hand = Hand ( ) ; } while ( discard_deck . size ( ) != empty ) { main_deck << discard_deck ; } string response = " " ; string saidNo = " " ; cout << " " << endl ; getline ( cin , response ) ; while ( response != saidNo ) { istringstream iss ( response ) ; string word ; while ( iss >> word ) { shared_ptr < Player > p = find_player ( word ) ; if ( p != nullptr ) { ofstream ofs ; ofs . open ( word ) ; ofs << p -> name << endl ; ofs << p -> win << endl ; ofs << p -> lose << endl ; ofs << p -> chips << endl ; ofs . close ( ) ; remove_player ( word ) ; } } cout << " " << endl ; getline ( cin , response ) ; } string response2 = " " ; cout << " " << endl ; getline ( cin , response2 ) ; while ( response2 != saidNo ) { istringstream iss2 ( response2 ) ; string word ; const int AIOffset = 1 ; const int beginIndex = 0 ; while ( iss2 >> word ) { try { bool isAI = false ; add_player ( word , isAI ) ; } catch ( ... ) { } } cout << " " << endl ; getline ( cin , response2 ) ; } int lastPlayer = 1 ; if ( players . size ( ) == lastPlayer ) { int playerIndex = 0 ; shared_ptr < Player > p = players [ playerIndex ] ; ofstream ofs ; ofs . open ( p -> name ) ; ofs << p -> name << endl ; ofs << p -> win << endl ; ofs << p -> lose << endl ; ofs << p -> chips << endl ; ofs . close ( ) ; remove_player ( p -> name ) ; } int nextPlayer = 1 ; if ( players . size ( ) != empty ) { dealer_index = ( dealer_index + nextPlayer ) % players . size ( ) ; } return errors :: noError ; }
FiveCardDraw::after_round()
sort and print out players by their hand strength (strongest to weakest)
retrieve the cards from players for next game
letting players to drop out of the game and other players to join
FiveCardDraw :: after_round () sort and print out players by their hand strength ( strongest to weakest ) retrieve the cards from players for next game letting players to drop out of the game and other players to join
//find the winner from players who are not folded
 //print the chips of the players who folded
 //take cards back to the main deck from players 
 //take cards back from the discard deck
 //prompt message to ask if players want to quit the game
 //ask for more players to join
 //store the data of players in case they quit
