diff options
author | Your Name <you@example.com> | 2022-08-09 16:57:53 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2022-08-09 16:57:53 -0400 |
commit | 5937d893da5656be3f486c863ae54e08bbe66579 (patch) | |
tree | 15aedaf0753fcf73fe85e90e88a7d0af33036eca /src/battlescape | |
parent | 947d83c59ea86615e3a81a2ec122d843b5eceee9 (diff) | |
download | dmtool-5937d893da5656be3f486c863ae54e08bbe66579.tar.gz dmtool-5937d893da5656be3f486c863ae54e08bbe66579.tar.bz2 dmtool-5937d893da5656be3f486c863ae54e08bbe66579.zip |
Added generic items, worked on features
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; + }; +} |