-
Notifications
You must be signed in to change notification settings - Fork 0
/
soccerCSV.h
95 lines (90 loc) · 4.02 KB
/
soccerCSV.h
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
#include <string>
#include <vector>
using namespace std;
struct SoccerCSV{
int nRecord;
string Time; //Time #1
string PlayerNumber; //Player's number #2 ]Posseccion
string Area; //Area #3 ]Posseccion
string ROP; //Result of Possession #4 ]Posseccion
string PassedToward; //Passed toward #5 ]Posseccion
string OppPassedTimes; //OPT before our possession #6 ]Defensive
string Defensive; // #7 ]Defensive
string FoulCommited; // #8 ]Displine
string FoulDrawn; // #9 ]Displine
string Yellow; // #10 ]Displine
string Red; // #11 ]Displine
string Offsides; // #12 ]Displine
string OppTOC; // #13 ]OppChance
string OppDOS; // #14 ]OppChance
string OppROS; // #15 ]OppChance
string OppNOP; // #16 ]OppChance
string TOC; // #17 ]OurChance
string DOS; // #18 ]OurChance
string ROS; // #19 ]OurChance
string NOS; // #20 ]OurChance
string Shooter; // #21 ]OurChance
string FirstPass; // #22 ]OurChance
string SecondPass; // #23 ]OurChance
string ThirdPass; // #24 ]OurChance
string FourthPass; // #25 ]OurChance
vector<string> Player; // #26-36
vector<string> Position; // #37-47
SoccerCSV(string input){
//cout << input << endl;
int last_comma_pos = -1;
int id=1,count=0;
for(int i=0;i<input.size();i++){ //parsing string
if(input[i] != ',') count++;
else{
if(count == 0) {id++;continue;}
string buffer = input.substr(last_comma_pos+1,count);
switch(id){
case 1:Time = buffer;break;
case 2:PlayerNumber = buffer;break;
case 3:Area = buffer;break;
case 4:ROP = buffer;break;
case 5:PassedToward = buffer;break;
case 6:OppPassedTimes = buffer;break;
case 7:Defensive = buffer;break;
case 8:FoulCommited = buffer;break;
case 9:FoulDrawn = buffer;break;
case 10:Yellow = buffer;break;
case 11:Red = buffer;break;
case 12:Offsides = buffer;break;
case 13:OppTOC = buffer;break;
case 14:OppDOS = buffer;break;
case 15:OppROS = buffer;break;
case 16:OppNOP = buffer;break;
case 17:TOC = buffer;break;
case 18:DOS = buffer;break;
case 19:ROS = buffer;break;
case 20:NOS = buffer;break;
case 21:Shooter = buffer;break;
case 22:FirstPass = buffer;break;
case 23:SecondPass = buffer;break;
case 24:ThirdPass = buffer;break;
case 25:FourthPass = buffer;break;
default: //cout << "Wrong id=" << id << endl;
break;
}
id++; count = 0;
last_comma_pos = i;
}
}
}
SoccerCSV(){ cout << "**Error: Require parameter for constructor SoccerCSV" << endl; exit(0);}
void print(){
cout << "-------------------------------------------------------" << endl;
cout << "@" << Time << "\t#" << PlayerNumber << "(" << Area << ")->#" << PassedToward << "=" << ROP<<endl;
cout << OppPassedTimes << endl;
}
};
struct Player{
int number;
string pos;
int total_pass;
int total_pass_end_shot;
unordered_map<unsigned int, unsigned int> successful_passes; //successful pass to all player.
unordered_map<unsigned int, unsigned int> successful_passes_end_shot; //successful_passes_end_shot
};