diff --git a/src/kode/LesData3.cpp b/src/kode/LesData3.cpp index aa1655a735e99531d99892a5d14b1861522dc036..777b8196393c12e13789a5b95e25111f50e32f1f 100644 --- a/src/kode/LesData3.cpp +++ b/src/kode/LesData3.cpp @@ -25,7 +25,7 @@ */ char lesChar(const char* t) { char tegn; - std::cout << t << ": "; + std::cout << t; std::cin >> tegn; std::cin.ignore(MAXCHAR, '\n'); return (toupper(tegn)); } diff --git a/src/kode/Tournament.cpp b/src/kode/Tournament.cpp index ed098c03d75b38d760651a09589fb48ab375fe9a..a5b1d9525abbadf1a56024524444915f776e8e5f 100644 --- a/src/kode/Tournament.cpp +++ b/src/kode/Tournament.cpp @@ -25,7 +25,7 @@ void Tournament::enterResults() for (int i = 0; i < nrOfTables; ++i) { int answer; - cout << endl << "Enter results for table " << i << "with " + cout << endl << "Enter results for table " << i+1 << "with " << playerList[searchByID(white[i],1)]->lastName << " as white and " << playerList[searchByID(black[i],1)]->lastName @@ -57,6 +57,7 @@ void Tournament::enterResults() if(currentRound == nrOfRounds) { + finished=true; endTournament(); } else @@ -78,7 +79,7 @@ void Tournament::printTables() currentRound++; - if (currentRound == 0) + if (currentRound == 1) { vector<Player*> playersPlaying = playerList; for (int i = 0; i < nrOfTables; ++i) diff --git a/src/kode/Tournament.h b/src/kode/Tournament.h index eea16fd92eedd63efa270e24ebe4069f643c961b..7c333da061062d58c1cc185fe6c2856481e958d4 100644 --- a/src/kode/Tournament.h +++ b/src/kode/Tournament.h @@ -27,6 +27,7 @@ class Tournament int nrOfRounds; //amount of rounds the tournament has total vector<int>white; //id of the players with white pieces in the current round, so white[0] is the id of the player with white pieces on table 1 vector<int>black; //id of the players with black pieces in the current round, so black[0] is the id of the player with black pieces on table 1 + bool finished; //white and black are reset each round, but still needs to be saved virtual void enterResults(); //Enters the results after a round, goes through each table and asks the result before allowing the next round to start diff --git a/src/kode/checkmate.cpp b/src/kode/checkmate.cpp index 045802bf99442e8cf790da2b1485f16e7660d962..b77e484d89b58921ebed7a97c975230bbc7d8d0d 100644 --- a/src/kode/checkmate.cpp +++ b/src/kode/checkmate.cpp @@ -28,8 +28,8 @@ int main() { char command; - readFromFile(); - readFromFileTournament(); +// readFromFile(); + // readFromFileTournament(); do { @@ -41,7 +41,7 @@ int main() { menuToPrint=menuSetUp; } - else if (gTournaments[0]->nrOfRounds==gTournaments[0]->white.size()) + else if (gTournaments[0]->finished) { menuToPrint=menuEnd; } @@ -52,7 +52,7 @@ int main() cout << endl << menuToPrint; command = lesChar("\nCommand: "); - cout << command; + // cout << command; switch (command) { case 'S': @@ -91,8 +91,8 @@ int main() }while (command != 'Q'); - writeToFileTournament(); - writeToFile(); + // writeToFileTournament(); + // writeToFile(); return 0; } diff --git a/src/kode/newPlayer.cpp b/src/kode/newPlayer.cpp index 340fbe17dff43d515a563a83b2fbd96d7192c494..9f1103207fd7cf63ac1a19c42a59168eab1920da 100644 --- a/src/kode/newPlayer.cpp +++ b/src/kode/newPlayer.cpp @@ -16,11 +16,14 @@ extern vector<Player*>playerList; void newPlayer(int id) { Player* newPlayer; - do + if (searchByID(id,1)!=-1) { - cout << endl << "A player with this ID already exists, please try again!" << endl; - id = lesInt("Please offer a valid ID\n",0,10000); - }while(searchByID(id,1)!=-1); + do + { + cout << endl << "A player with this ID already exists, please try again!" << endl; + id = lesInt("Please offer a valid ID\n",0,10000); + }while(searchByID(id,1)!=-1); + } newPlayer = new Player; newPlayer->playerID = id; cout << endl << "Last name of player " << id << endl; diff --git a/src/kode/startNewTournament.cpp b/src/kode/startNewTournament.cpp index 26e90d22b91411f4fa3f3be409d9fa5d5025b3f4..c3c7ae301a1a4065a984ff3308033873442a3e95 100644 --- a/src/kode/startNewTournament.cpp +++ b/src/kode/startNewTournament.cpp @@ -41,5 +41,6 @@ void startNewTournament() 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); + newTournament->finished=false; gTournaments.push_back(newTournament); } \ No newline at end of file