Wip: Working on Room Movement
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
typedef int (*FUNCTION)(std::string s);
|
||||
typedef int (*FUNCTION)(const std::string &s);
|
||||
|
||||
static std::vector<std::string> Verbs{"Quit", "Exit", "Go", "Move", "Look"};
|
||||
static std::vector<std::string> Nouns{"Object", "Door", "North", "South", "East",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
static int curX, curY;
|
||||
|
||||
extern bool isActive;
|
||||
extern std::vector<std::vector<Room>> rooms;
|
||||
|
||||
#define MAP_HEIGHT 5
|
||||
#define MAP_WIDTH 5
|
||||
@@ -19,7 +20,6 @@ extern bool isActive;
|
||||
namespace fs = std::filesystem;
|
||||
class Game {
|
||||
private:
|
||||
std::vector<std::vector<Room>> rooms;
|
||||
Player player;
|
||||
int progress;
|
||||
CommandParser parser;
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
void Run();
|
||||
bool Save();
|
||||
|
||||
void ChangeRoom(Room r);
|
||||
Room GetCurrentRoom() { return currentRoom; }
|
||||
|
||||
static void SetIsActive(const bool active) { isActive = active; }
|
||||
@@ -53,6 +54,6 @@ public:
|
||||
};
|
||||
|
||||
// Commands
|
||||
static int Quit(std::string n);
|
||||
static int Move(std::string c);
|
||||
static int Look(std::string c);
|
||||
static int Quit(const std::string &n);
|
||||
static int Move(const std::string &c);
|
||||
static int Look(const std::string &c);
|
||||
|
||||
+15
-2
@@ -18,8 +18,8 @@ struct Exit {
|
||||
friend void to_json(json &j, const Exit &e);
|
||||
};
|
||||
|
||||
static std::map<char *, Direction> directions{{"N", N}, {"S", S}, {"E", E}, {"W", W}};
|
||||
static std::map<Direction, const char *> directionChar{{N, "N"}, {S, "S"}, {E, "E"}, {W, "W"}};
|
||||
static std::map<std::string, Direction> directions{{"N", N}, {"S", S}, {"E", E}, {"W", W}};
|
||||
static std::map<Direction, std::string> directionChar{{N, "N"}, {S, "S"}, {E, "E"}, {W, "W"}};
|
||||
|
||||
class Room {
|
||||
private:
|
||||
@@ -39,6 +39,19 @@ public:
|
||||
|
||||
bool ValidDirection(Direction d);
|
||||
|
||||
inline bool operator==(const Room &rhs) const {
|
||||
if (id == rhs.id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
inline bool operator!=(const Room &rhs) const {
|
||||
if (id != rhs.id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
~Room();
|
||||
|
||||
friend void to_json(nlohmann::json &j, const Room &r);
|
||||
|
||||
Reference in New Issue
Block a user