-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
144 lines (115 loc) · 5.29 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include "team.h"
#include "draft.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>
#include <vector>
using namespace std;
void intro(); //intro message
const bool contains(const vector<int>& v, const int& target);
void clearIn(); //clear; ignore;
int main() {
int numTeams, numUsers = 1, draftPosition, i, j; //primitives
string teamName;
Team *teams; //abstracts
NodeData *ptr = NULL;
Draft draft;
vector<NodeData*> players; //all players
vector<int> claimedDraftPositions; //taken Picks
//----------------------------PART ONE--------------------------------
intro();
teams = new Team[numTeams = 10];
draft.setNumTeams(numTeams);
for(i = 0; i < numUsers; i++) { //set user info
cout << "Enter your name: ";
getline(cin, teamName);
cout << endl << endl;
do { //set draft positions
cout << "Enter draft position (1 - " << numTeams << ") : ";
cin >> draftPosition;
clearIn();
} while(draftPosition < 1 || draftPosition > numTeams ||
contains(claimedDraftPositions, draftPosition));
teams[draftPosition - 1] = Team(teamName, draftPosition, true);
claimedDraftPositions.push_back(draftPosition);
}
for(j = 0; j < numTeams; j++) //fill autopicks
if(teams[j].getUser() == false) //not a user?
teams[j] = Team("auto", (j + 1), false); //make autopick
//-------------------------------END PART ONE----------------------------
//now read in player list into vector
//----------------------------------PART TWO----------------------------
cout << "\n\nRetreiving ESPN Player Data... \n";
system("sh 2017.sh");
ifstream in("players.txt"); //open file
if(!in) { //file validity
cout << "File could not be opened.\n";
return 1;
}
while(!in.eof()) {
Player playerObject;
ptr = playerObject.makeFromStream(in);
for(int i = 0; i < players.size(); i++) //search whole vector
if(ptr == players[i]) //...for repeats
delete ptr; //...delete repeats
if(ptr != NULL) players.push_back(ptr); //add player
}
cout << "Players Acquired \n\n\n";
//---------------------------------END PART TWO----------------------------
//--------------------------------PART THREE-----------------------------
draft.pickTime();
draft.makeBoard(teams, players, numTeams);
return 0;
}
const bool contains(const vector<int>& v, const int& target) {
return find(v.begin(), v.end(), target) != v.end();
}
void intro(){
system("clear;");
string line = "-------------------------------------------";
cout << line + line << endl;
cout << " FANTASY FOOTBALL DRAFT SIMULATOR - JOHN ZOELLER" << endl;
cout << line + line << endl << endl << endl;
}
void clearIn() {
cin.clear();
cin.ignore(100, '\n');
}
//commmented out
// cout << "Welcome to The Draft Machine. "
// << "Default teams consist of: " << endl
// << "1 Quarterback" << endl
// << "2 Running backs" << endl
// << "2 Wide Recievers " << endl
// << "1 Flex" << endl
// << "1 Tight End " << endl
// << "1 Defense " << endl
// << "1 Kicker" << endl
// << "8 Bench spots" << endl << endl;
// cout << "10 teams, 1 user " << endl;
/*do{ //get numTeams
cout << "Choose between 4 and 12 teams: ";
cin >> numTeams;
cin.clear();
cin.ignore(100, '\n');
} while(numTeams < 4 || numTeams > 12);
cout << endl << "Ok, there will be " << numTeams << " teams. " << endl << endl;*/
// do{ //get numUsers
// cout << "Choose between 0 and " << numTeams << " users: ";
// cin >> numUsers;
// cin.clear();
// cin.ignore(100, '\n');
// } while(numUsers < 0 || numUsers > numTeams);
// cout << "Ok, there will be " << numUsers << " user(s) and "
// << (numTeams - numUsers) << " autopicks" << endl;
//cout << "Enter user " << i + 1 << "'s name: ";
// teams[i] = Team(teamName, draftPosition, true); //new team object
// teams[draftPosition - 1] = teams[i]; //correct teamsay position
// claimedDraftPositions.push_back(draftPosition); //pick number taken
// if((draftPosition - 1) != i) //replace old teamsay pos
// teams[i] = Team(); //...with a blank team