Game.cpp
//
// Game:: resetChips()
// Go around the table and see if any player runs out of chips and ask them to reset chips
// to 20, if they deny, then they must quit the game
//

: resetChips()
Go around the table and see if any player runs out of chips and ask them to reset chips
to 20, if they deny, then they must quit the game
: resetChips () Go around the table and see if any player runs out of chips and ask them to reset chips to 20 if they deny then they must quit the game
void Game::resetChips() {
	vector<shared_ptr<Player>> tmpPlayers(players);
	for (auto it = tmpPlayers.begin(); it < tmpPlayers.end(); it++){
		int noChips = 0;
		int startingChips = 20;
		if ((*it)->chips == noChips) {
			bool validResponse = false;
			while (!validResponse) {
				cout << (*it)->name <<": Do you want to reset your chips? yes/no" << endl;
				string response;
				getline(cin, response);
				string saidNo = "no";
				string saidYes = "yes";
				if (response == saidNo) {
					ofstream ofs;
					ofs.open((*it)->name);
					ofs << (*it)->name << endl;
					ofs << (*it)->win << endl;
					ofs << (*it)->lose << endl;
					ofs << (*it)->chips << endl;
					ofs.close();
					validResponse = true;
					remove_player((*it)->name);
				}
				else if (response == saidYes) {
					validResponse = true;
					(*it)->chips = startingChips;
				}
				else {
					validResponse = false;
				}
			}
		}
	}
	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);
	}
}
void Game :: resetChips ( ) { vector < shared_ptr < Player > > tmpPlayers ( players ) ; for ( auto it = tmpPlayers . begin ( ) ; it < tmpPlayers . end ( ) ; it ++ ) { int noChips = 0 ; int startingChips = 20 ; if ( ( * it ) -> chips == noChips ) { bool validResponse = false ; while ( ! validResponse ) { cout << ( * it ) -> name << " " << endl ; string response ; getline ( cin , response ) ; string saidNo = " " ; string saidYes = " " ; if ( response == saidNo ) { ofstream ofs ; ofs . open ( ( * it ) -> name ) ; ofs << ( * it ) -> name << endl ; ofs << ( * it ) -> win << endl ; ofs << ( * it ) -> lose << endl ; ofs << ( * it ) -> chips << endl ; ofs . close ( ) ; validResponse = true ; remove_player ( ( * it ) -> name ) ; } else if ( response == saidYes ) { validResponse = true ; ( * it ) -> chips = startingChips ; } else { validResponse = false ; } } } } 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 ) ; } }
Game:: resetChips()
Go around the table and see if any player runs out of chips and ask them to reset chips
to 20, if they deny, then they must quit the game
Game :: resetChips () Go around the table and see if any player runs out of chips and ask them to reset chips to 20 if they deny then they must quit the game
//kick
 //reset
