From 103587c2d5f9deb20e549a86cdf5023b429cc6a1 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 18 Mar 2015 18:23:54 -0400 Subject: Wrote an XML Schema describing maps file and also changed the spec a bit --- src/map.h | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/map.h') diff --git a/src/map.h b/src/map.h index 1234dbb..4e661ab 100644 --- a/src/map.h +++ b/src/map.h @@ -3,6 +3,7 @@ #include #include +#include class Entity; @@ -23,25 +24,31 @@ class Map { ReverseWarp }; + enum class MoveDir { + Left, + Right, + Up, + Down + }; + struct EntityData { std::string name; std::pair position; }; + struct Adjacent { + MoveType type = MoveType::Wall; + int map = -1; + }; + static MoveType moveTypeForShort(std::string str); + static MoveDir moveDirForShort(std::string str); static bool moveTypeTakesMap(MoveType type); int getID() const; const int* getMapdata() const; std::string getTitle() const; - MoveType getLeftMoveType() const; - MoveType getRightMoveType() const; - MoveType getUpMoveType() const; - MoveType getDownMoveType() const; - int getLeftMapID() const; - int getRightMapID() const; - int getUpMapID() const; - int getDownMapID() const; + const Adjacent& getAdjacent(MoveDir dir) const; void createEntities(std::list>& entities) const; bool operator==(const Map& other) const; @@ -49,22 +56,14 @@ class Map { void setMapdata(int* mapdata); void setTitle(std::string title); - void setLeftMoveType(MoveType type); - void setRightMoveType(MoveType type); - void setUpMoveType(MoveType type); - void setDownMoveType(MoveType type); - void setLeftMapID(int id); - void setRightMapID(int id); - void setUpMapID(int id); - void setDownMapID(int id); + void setAdjacent(MoveDir dir, MoveType type, int map); void addEntity(EntityData& data); private: int* mapdata; std::string title; int id; std::list entities; - MoveType leftType, rightType, upType, downType; - int leftMap, rightMap, upMap, downMap; + std::map adjacents; }; #endif -- cgit 1.4.1