-
Notifications
You must be signed in to change notification settings - Fork 0
/
StateMap.cpp
47 lines (39 loc) · 926 Bytes
/
StateMap.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
#include <map>
#include "enums.hpp"
#include "TypeConverter.cpp"
namespace HexLab {
struct StateMap : std::map<Type, States>
{
int count{};
StateMap()
{
this->insert(std::pair<Type, States>(Top, undefined));
this->insert(std::pair<Type, States>(TopLeft, undefined));
this->insert(std::pair<Type, States>(TopRight, undefined));
this->insert(std::pair<Type, States>(Bottom, undefined));
this->insert(std::pair<Type, States>(BottomRight, undefined));
this->insert(std::pair<Type, States>(BottomLeft, undefined));
}
States at(Type type)
{
return this->find(type)->second;
}
States operator[] (Type type)
{
return this->at(type);
}
States operator[] (int i)
{
return this->at(converter::ToType(i));
}
int Closed()
{
int counter{};
for (int i = 0; i < 6; i++)
if (this->at(converter::ToType(i)) == closed)
counter += 1;
this->count = counter;
return counter;
}
};
};