school/cs142/smcquay/cootie/cootie.cc
2016-04-06 20:45:34 -07:00

43 lines
957 B
C++

#include <iostream>
#include <vector>
#include <cstdlib>
#include "dice.h"
#include "player.h"
using namespace std;
const string usage = "usage: cootie <number of players>";
int main(int argc, char * argv[]) {
if(argc < 2) {
cerr << usage << endl;;
return 1;
}
random_init();
int number_of_players = int(atof(argv[1]));
vector<player> players;
for(int i=0; i < number_of_players; i++) {
players.push_back(player(i));
}
auto keep_playing = true;
while(keep_playing) {
for(player & p : players) {
// cout << p << endl;
p.turn();
if(p.won()) {
keep_playing = false;
cout << "player " << p.id << " wins!!" << endl;
cout << p << endl;
break;
}
}
}
cout << "total rolls: " << get_roll_count() << endl;
cout << "thanks for playing" << endl;
return 0;
}