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
|
#pragma once
#include <vector>
#include <memory>
#include <string>
#include <nlohmann/json.hpp>
#include <tuple>
#include <cstddef> // size_t
#include "../entry.h"
namespace battlescape {
struct battlescapeImpl;
struct Tile {
std::string name;
std::string description;
char look;
int color;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Tile, name, description, look, color);
typedef std::tuple<std::size_t,std::size_t,std::size_t> coord3d;
class Battlescape {
public:
Battlescape();
// Also can be created programmatically
Battlescape(std::vector<std::vector<std::vector<Tile>>> terrain);
// Getters
std::map<std::shared_ptr<entry::Entry>, coord3d> getContents(void) const;
// Setters
bool place(std::shared_ptr<entry::Entry> thing, const coord3d& position);
bool remove(std::shared_ptr<entry::Entry> thing, const coord3d& position);
bool move(std::shared_ptr<entry::Entry> thing, const coord3d& from, const coord3d& to) {
if(place(thing, to)) {
if(remove(thing, from)) {
return true;
}
remove(thing, to);
}
return false;
}
NLOHMANN_FRIEND_DECLARES(Battlescape);
private:
std::shared_ptr<battlescapeImpl> data;
};
}
|