-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTerr.h
38 lines (28 loc) · 788 Bytes
/
Terr.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
#ifndef TERR_H
#define TERR_H
#include "json/json/json.h"
#include "Piece.h"
#include <memory>
#include <string>
#include <vector>
#include <map>
class Terr : public std::enable_shared_from_this<Terr> {
public:
Terr(const Json::Value& loc,
const Json::Value locs,
std::map<std::string, std::shared_ptr<Terr>>& terrs);
bool has_piece()
{ return piece.use_count(); }
std::shared_ptr<Piece> get_piece()
{ return piece; }
// double dispatch
// TODO because of shared_from_this, does this not work? need to check
virtual bool can_be_occupied_by(std::shared_ptr<const Piece>& piece) const = 0;
private:
std::string short_name;
std::string display_name;
bool has_center;
std::vector<std::shared_ptr<Terr>> adjacent;
std::shared_ptr<Piece> piece;
};
#endif // TERR_H