diff options
Diffstat (limited to 'src/battlescape')
-rw-r--r-- | src/battlescape/battlescape.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/battlescape/battlescape.h b/src/battlescape/battlescape.h new file mode 100644 index 0000000..a170ad3 --- /dev/null +++ b/src/battlescape/battlescape.h @@ -0,0 +1,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; + }; +} |