Added several commands
This commit is contained in:
@@ -11,7 +11,6 @@ static std::vector<std::string> Nouns{"Object", "Door", "North", "South", "East"
|
||||
|
||||
class CommandParser {
|
||||
private:
|
||||
// std::vector<std::string> commands;
|
||||
std::map<std::string, FUNCTION> commands;
|
||||
|
||||
public:
|
||||
|
||||
+17
-5
@@ -9,16 +9,14 @@
|
||||
#include "player.h"
|
||||
#include "room.h"
|
||||
|
||||
static int curX, curY;
|
||||
|
||||
extern bool isActive;
|
||||
|
||||
extern int curX, curY;
|
||||
|
||||
|
||||
#define MAP_HEIGHT 5
|
||||
#define MAP_WIDTH 5
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class Game {
|
||||
private:
|
||||
std::vector<std::vector<Room>> rooms;
|
||||
@@ -29,6 +27,7 @@ private:
|
||||
fs::path filePath = "Resources/Rooms.json";
|
||||
std::ifstream stream;
|
||||
|
||||
|
||||
// Likely need to make sure Player is ADDED to room
|
||||
// We want player and objects to exist IN room
|
||||
Room currentRoom;
|
||||
@@ -37,10 +36,23 @@ public:
|
||||
Game();
|
||||
static bool GetIsActive() { return isActive; }
|
||||
bool Init();
|
||||
void ChangeRoom(Direction dir);
|
||||
void Run();
|
||||
bool Save();
|
||||
|
||||
Room GetCurrentRoom() { return currentRoom; }
|
||||
|
||||
static void SetIsActive(const bool active) { isActive = active; }
|
||||
|
||||
static Game &instance() {
|
||||
static Game *game_;
|
||||
if (game_ == nullptr) {
|
||||
game_ = new Game();
|
||||
}
|
||||
return *game_;
|
||||
}
|
||||
};
|
||||
|
||||
// Commands
|
||||
static int Quit(std::string n);
|
||||
static int Move(std::string c);
|
||||
static int Look(std::string c);
|
||||
|
||||
@@ -18,6 +18,9 @@ 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"}};
|
||||
|
||||
class Room {
|
||||
private:
|
||||
int id;
|
||||
@@ -30,15 +33,14 @@ public:
|
||||
Room(int id, std::string name, std::string desc, std::vector<Exit> e);
|
||||
Room(const Room &r);
|
||||
|
||||
int AvalibleExits() const { return exits.size(); }
|
||||
void PrintAvalibleExits();
|
||||
void Print() const;
|
||||
|
||||
int GetID() const { return id; }
|
||||
|
||||
bool ValidDirection(Direction d);
|
||||
|
||||
~Room();
|
||||
|
||||
friend void to_json(nlohmann::json &j, const Room &r);
|
||||
friend void from_json(const nlohmann::json &j, Room &r);
|
||||
};
|
||||
|
||||
static int Move(std::string c);
|
||||
|
||||
Reference in New Issue
Block a user