diff --git a/src/kode/Tournament.cpp b/src/kode/Tournament.cpp index 6d7fddcb9b481d3528fa0ce925906108ef023960..649964465b05f9ae2439b1d00a29a6e667d677f0 100644 --- a/src/kode/Tournament.cpp +++ b/src/kode/Tournament.cpp @@ -15,15 +15,62 @@ using namespace std; extern vector<Tournament *> gTournaments; +extern vector<Player*> playerList; +extern vector<Player*> sortedRankings; void Tournament::startNewTournament() +{ + char answer; + do { + cout << endl << "Are you certain you wish to start a new tournament?" + << "This will delete all existing tournament data, including the player list."; + answer = lesChar(" Y/N\n"); + answer= tolower(answer); + }while (answer != 'y' && answer != 'n'); + if (answer == 'n') + { + return; + } + playerList.clear(); + sortedRankings.clear(); + gTournaments.clear(); + + Tournament* newTournament; + newTournament = new Tournament; + + newTournament->nrOfTables = lesInt("\nHow many tables should the tournament have?\n",1,1000); + newTournament->currentRound = 0; + newTournament->nrOfRounds = lesInt("\nHow many rounds should the tournament have?\n",1,20); + gTournaments.push_back(newTournament); +} + + + +void Tournament::enterResults() { } -void Tournament::nextRound() +void Tournament::printTables() { + if(canStartRound() == false) + { + cout << endl << "There number of tables does not correspond to the amount of players," + << " please add or remove players so that there is exactly two players per table." << endl; + return; + } +} +bool Tournament::canStartRound() +{ + if (playerList.size() == nrOfTables*2) + { + return true; + } + else + { + return false; + } } void Tournament::endTournament() diff --git a/src/kode/Tournament.h b/src/kode/Tournament.h index 3a54c7bdc2c743697400fad81e68ef4f51a274ab..cc053c525205b5906098675a50d2a3df3d23959b 100644 --- a/src/kode/Tournament.h +++ b/src/kode/Tournament.h @@ -28,9 +28,11 @@ class Tournament vector<int>white; vector<int>black; - virtual void startNewTournament(); //- - virtual void nextRound(); //- + virtual void startNewTournament(); //+ + virtual void enterResults(); //- virtual void endTournament(); //- + virtual void printTables(); //- + bool canStartRound();// void writeToFileTournament(ofstream &out); //- void readFromFileTournaments(ifstream &in); //- diff --git a/src/kode/checkmate.cpp b/src/kode/checkmate.cpp index 88b75e10d2f6fc6b5c1258fdf72e5a8d0c04ce76..4c45c8b2d6a0dc3a21e33da4edc3c073783df58b 100644 --- a/src/kode/checkmate.cpp +++ b/src/kode/checkmate.cpp @@ -213,35 +213,6 @@ void enterResults() } } - - -/** - * Create a new tournament, with black and white players and what table they're playing at - * @see writeTournament() - * @see fillTableArray() - */ -void newTournament() -{ - if(gRounds == 0){ - cout<<"Table: \tPlayer 1: \tPlayer 2:\n"; - for(int i=0; i<gPlayers.size(); i+2){ - cout<< i+1 <<"\t" <<gPlayers[i]->returnName() <<"\t" <<gPlayers[i+1]->returnName() <<"\n"; - } - gRounds++; - } - - else{ - cout<<"Table: \tPlayer 1: \tPlayer 2:\n"; - for(int i=0; i<gPlayers.size(); i++){ - for(int j=1; j<gPlayers.size(); j++){ - // gPlayers[i]->playedBefore[j]; - - } - } - gRounds++; - } -} - /** * edit info about a player * @@ -317,12 +288,3 @@ void skrivMeny() << "\t6 - View results\n" << "\tQ - Quit\n\n"; } - -/** - * Asks user for number of tables - * - */ -void amntTables(){ - cout<<"How many tables do you have?\n"; - gTables = lesInt("Tables:",1,200); -}