/
SC2Replay.cpp
109 lines (90 loc) · 1.81 KB
/
SC2Replay.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
#include "SC2Replay.h"
//Private
void SC2Replay::deepCopy(const SC2Replay &obj)
{
this->contentSize = obj.contentSize;
this->title = obj.title;
this->mapID = obj.mapID;
this->nrOfplayers = obj.nrOfplayers;
this->fullPath = obj.fullPath;
this->names = obj.names;
this->races = obj.races;
}
SC2Replay::SC2Replay(string replayTitle,Vector<string> replayContent,string fullPath)
{
this->title = replayTitle;
this->fullPath = fullPath;
contentSize = replayContent.size();
for(int i = 0; i < contentSize-1; i++)
{
if(i % 2 == 0)
{
names.addLast(replayContent.getAt(i));
}
else
{
races.addLast(replayContent.getAt(i));
}
}
this->nrOfplayers = names.size();
this->mapID = replayContent.getAt(contentSize -1);
}
SC2Replay::SC2Replay()
{
this->title ="";
}
SC2Replay::SC2Replay(const SC2Replay &obj)
{
deepCopy(obj);
}
SC2Replay::~SC2Replay(void)
{
}
void SC2Replay::operator=(const SC2Replay &obj)
{
deepCopy(obj);
}
void SC2Replay::initiate(string replayTitle,Vector<string> replayContent,string fullPath)
{
names.clear();
races.clear();
this->title = replayTitle;
this->fullPath = fullPath;
contentSize = replayContent.size();
for(int i = 0; i < contentSize-1; i++)
{
if(i % 2 == 0)
{
names.addLast(replayContent.getAt(i));
}
else
{
races.addLast(replayContent.getAt(i));
}
}
this->mapID = (replayContent.getAt(contentSize-1));
}
bool SC2Replay::operator<(const SC2Replay &obj)
{
return this->title < obj.title;
}
bool SC2Replay::operator>(const SC2Replay &obj)
{
return this->title > obj.title;
}
string SC2Replay::getMapTitle() const
{
return this->mapID;
}
string SC2Replay::getName(int pos) const
{
return this->names[pos];
}
string SC2Replay::getRace(int pos) const
{
return this->races[pos];
}
int SC2Replay::getNrOfPlayers() const
{
return this->nrOfplayers;
}