-
Notifications
You must be signed in to change notification settings - Fork 0
/
formation.h
66 lines (54 loc) · 1.32 KB
/
formation.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
#ifndef FORMATION_H
#define FORMATION_H
#include <unordered_set>
#include "player.h"
#include <algorithm>
namespace std{
template<>
struct hash<pair<position,position>>{
size_t operator()(const pair<position,position> & p) const{
auto h1 = hash<int>()(static_cast<int>(p.first));
auto h2 = hash<int>()(static_cast<int>(p.second));
return h1^h2;
}
};
}
class formation
{
private :
int nbPlayers;
std::vector<position> positions;
std::unordered_set<std::pair<position,position>> formationSynergy;
public:
formation(int);
int getNbPlayers() const
{
return nbPlayers;
}
std::vector<position> getPositions() const
{
return positions;
}
void setPositions(std::vector<position> & newPos)
{
positions = newPos;
}
void addPosition(position p)
{
positions.push_back(p);
}
void addSynergy(position p1, position p2)
{
formationSynergy.insert(std::pair<position,position> (p1,p2));
}
std::unordered_set<std::pair<position,position>> getSynergies() const
{
return formationSynergy;
}
bool hasPosition(position p) const
{
return std::find(positions.cbegin(),positions.cend(),p)!=positions.cend()? true:false;
}
virtual ~formation();
};
#endif // FORMATION_H