-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerColors.cpp
More file actions
executable file
·76 lines (64 loc) · 1.18 KB
/
Copy pathPlayerColors.cpp
File metadata and controls
executable file
·76 lines (64 loc) · 1.18 KB
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
#include <cassert>
#include <iostream>
#include "PlayerInfo.hpp"
std::string to_string(const PlayerColors &p)
{
std::string ret;
switch(p)
{
case PlayerColors::Red:
ret = "Red";
break;
case PlayerColors::Blue:
ret = "Blue";
break;
case PlayerColors::Purple:
ret = "Purple";
break;
case PlayerColors::Yellow:
ret = "Yellow";
break;
case PlayerColors::Green:
ret = "Green";
break;
case PlayerColors::All:
ret = "All";
break;
case PlayerColors::Invalid:
assert(0 && "Attempt to print string for invalid Player color!");
break;
default:
assert(0 && "Invalid player color!");
break;
}
return ret;
}
PlayerColors to_color(const std::string &s)
{
PlayerColors ret;
if(s.compare("Red") == 0)
{
ret = PlayerColors::Red;
}
else if(s.compare("Blue") == 0)
{
ret = PlayerColors::Blue;
}
else if(s.compare("Purple") == 0)
{
ret = PlayerColors::Purple;
}
else if(s.compare("Yellow") == 0)
{
ret = PlayerColors::Yellow;
}
else if(s.compare("Green") == 0)
{
ret = PlayerColors::Green;
}
else
{
ret = PlayerColors::Invalid;
}
return ret;
}