Files
Text-Adventure/Engine/headers/game.h
T

75 lines
1.4 KiB
C++

#pragma once
#include <filesystem>
#include <fstream>
#include <string>
#include <vector>
#include "CommandParser.h"
#include "game.h"
#include "json.hpp"
#include "player.h"
#include "room.h"
static int curX, curY;
extern std::vector<std::vector<Room>> rooms;
#define MAP_HEIGHT 5
#define MAP_WIDTH 5
namespace fs = std::filesystem;
class Game {
private:
Player player;
int progress;
CommandParser parser;
nlohmann::json json;
fs::path filePath = "Resources/Rooms.json";
std::ifstream stream;
bool isActive;
inline static Game *game_;
// Likely need to make sure Player is ADDED to room
// We want player and objects to exist IN room
Room currentRoom;
public:
Game();
inline bool GetIsActive() const { return isActive; }
bool Init();
void Run();
bool Save();
void ChangeRoom(Room r);
Room GetCurrentRoom() { return currentRoom; }
inline bool operator!() const {
if (isActive) {
return false;
}
return true;
}
void SetIsActive(const bool active) { isActive = active; }
static void SetGameInstance(Game * g) {
game_ = g;
}
static Game &Instance() {
if (game_ == nullptr) {
game_ = new Game();
}
return *game_;
}
~Game() = default;
};
// Commands
static int Quit(const std::string &n);
static int Move(const std::string &c);
static int Look(const std::string &c);