From 5937d893da5656be3f486c863ae54e08bbe66579 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 9 Aug 2022 16:57:53 -0400 Subject: Added generic items, worked on features --- src/battlescape/battlescape.h | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/battlescape/battlescape.h (limited to 'src/battlescape') 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 +#include +#include +#include +#include +#include // 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 coord3d; + + class Battlescape { + public: + Battlescape(); + // Also can be created programmatically + Battlescape(std::vector>> terrain); + + // Getters + std::map, coord3d> getContents(void) const; + + // Setters + bool place(std::shared_ptr thing, const coord3d& position); + bool remove(std::shared_ptr thing, const coord3d& position); + bool move(std::shared_ptr 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 data; + }; +} -- cgit v1.2.3