-
Notifications
You must be signed in to change notification settings - Fork 0
/
Types.hpp
138 lines (127 loc) · 4.06 KB
/
Types.hpp
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
/*
* Email: sam.lazareanu@gmail.com
* ID: ****6281
* @SamuraiPolix - Samuel Lazareanu
*/
#ifndef TYPES_HPP
#define TYPES_HPP
#include <cstdlib> // Include for size_t definition
#include <string>
using std::string;
namespace ariel{
class valid_resources : public std::exception {
private:
const char * message;
public:
valid_resources(const char *msg) : message(msg) {}
const char* what() const noexcept override {
return message;
}
};
// enum of all resource types
enum Color {
Black = 30,
Red = 31,
Green = 32,
Blue = 34
};
enum ResourceType {
Ore = 1,
Wheat = 2,
Sheep = 3,
Wood = 4,
Brick = 5,
Desert = 7 // not a resoure - tile type
};
std::string getResourceName(ResourceType resource);
enum VertexPosition {
VERTEX_TOP_LEFT = 0,
VERTEX_TOP = 1,
VERTEX_TOP_RIGHT = 2,
VERTEX_BOTTOM_RIGHT = 3,
VERTEX_BOTTOM = 4,
VERTEX_BOTTOM_LEFT = 5,
NUM_OF_VERTICES = 6
};
enum EdgePosition {
EDGE_TOP_LEFT = 0,
EDGE_TOP_RIGHT = 1,
EDGE_RIGHT = 2,
EDGE_BOTTOM_RIGHT = 3,
EDGE_BOTTOM_LEFT = 4,
EDGE_LEFT = 5,
NUM_OF_EDGES = 6
};
enum BuildableTypes{
None = 0,
Road = 1,
Settlement = 2,
City = 3
};
// edgePosition + - operators override
inline EdgePosition operator+(EdgePosition pos, int num){
return (EdgePosition)((((int)pos + num)) % (int)NUM_OF_EDGES);
}
inline EdgePosition operator+(int num, EdgePosition pos){
return (EdgePosition)((((int)pos + num)) % (int)NUM_OF_EDGES);
}
inline EdgePosition operator-(EdgePosition pos, int num){
int result = ((((int)pos - num)) % (int)NUM_OF_EDGES);
if (result < 0){
result += (int)NUM_OF_EDGES;
}
return (EdgePosition)result;
}
inline EdgePosition operator-(int num, EdgePosition pos){
int result = (((num - (int)pos)) % (int)NUM_OF_EDGES);
if (result < 0){
result += (int)NUM_OF_EDGES;
}
return (EdgePosition)result;
}
inline VertexPosition operator+(VertexPosition pos, int num){
return (VertexPosition)((((int)pos + num)) % (int)NUM_OF_VERTICES);
}
inline VertexPosition operator+(int num, VertexPosition pos){
return (VertexPosition)((((int)pos + num)) % (int)NUM_OF_VERTICES);
}
inline VertexPosition operator-(VertexPosition pos, int num){
int result = ((((int)pos - num)) % (int)NUM_OF_VERTICES);
if (result < 0){
result += (int)NUM_OF_VERTICES;
}
return (VertexPosition)result;
}
inline VertexPosition operator-(int num, VertexPosition pos){
int result = (((num - (int)pos)) % (int)NUM_OF_VERTICES);
if (result < 0){
result += (int)NUM_OF_VERTICES;
}
return (VertexPosition)result;
}
// EdgePosition operator+(EdgePosition pos, size_t num){
// return (EdgePosition)(((size_t)(pos + num)) % 6);
// }
// EdgePosition operator+(size_t num, EdgePosition pos){
// return (EdgePosition)(((size_t)(pos + num)) % 6);
// }
// EdgePosition operator-(EdgePosition pos, size_t num){
// return (EdgePosition)(((size_t)(pos-num)) % 6);
// }
// EdgePosition operator-(size_t num, EdgePosition pos){
// return (EdgePosition)(((size_t)(num - pos)) % 6);
// }
// VertexPosition operator+(VertexPosition pos, size_t num){
// return (VertexPosition)(((size_t)(pos + num)) % 6);
// }
// VertexPosition operator+(size_t num, VertexPosition pos){
// return (VertexPosition)(((size_t)(pos + num)) % 6);
// }
// VertexPosition operator-(VertexPosition pos, size_t num){
// return (VertexPosition)(((size_t)(pos - num)) % 6);
// }
// VertexPosition operator-(size_t num, VertexPosition pos){
// return (VertexPosition)(((size_t)(num - pos)) % 6);
// }
}
#endif // TYPES_HPP