Skip to content
Snippets Groups Projects
Commit dcd16e19 authored by TheHresvelgian's avatar TheHresvelgian
Browse files

Organizing code

parent 2c31dedc
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -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); //-
......
......@@ -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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment