2026-08-07 13:10:07 -05:00
|
|
|
#pragma once
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <string>
|
2026-08-28 20:38:11 -05:00
|
|
|
#include <utility>
|
2026-08-07 13:10:07 -05:00
|
|
|
#include <vector>
|
|
|
|
|
#include "CommandParser.h"
|
|
|
|
|
#include "game.h"
|
|
|
|
|
#include "json.hpp"
|
|
|
|
|
#include "player.h"
|
|
|
|
|
#include "room.h"
|
|
|
|
|
|
2026-08-21 08:02:22 -05:00
|
|
|
static int curX, curY;
|
|
|
|
|
|
2026-08-21 15:52:12 -05:00
|
|
|
extern std::vector<std::vector<Room>> rooms;
|
2026-08-07 13:10:07 -05:00
|
|
|
|
|
|
|
|
#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;
|
2026-08-28 14:54:45 -05:00
|
|
|
bool isActive;
|
|
|
|
|
|
2026-08-21 20:02:11 -05:00
|
|
|
inline static Game *game_;
|
2026-08-07 13:10:07 -05:00
|
|
|
|
2026-08-18 12:04:39 -05:00
|
|
|
// Likely need to make sure Player is ADDED to room
|
|
|
|
|
// We want player and objects to exist IN room
|
|
|
|
|
Room currentRoom;
|
|
|
|
|
|
2026-08-07 13:10:07 -05:00
|
|
|
public:
|
|
|
|
|
Game();
|
2026-08-28 20:38:11 -05:00
|
|
|
|
2026-08-28 14:54:45 -05:00
|
|
|
inline bool GetIsActive() const { return isActive; }
|
2026-08-07 13:10:07 -05:00
|
|
|
bool Init();
|
|
|
|
|
void Run();
|
|
|
|
|
bool Save();
|
2026-08-21 08:02:22 -05:00
|
|
|
|
2026-09-11 16:07:17 -05:00
|
|
|
void ChangeRoom(const Room &r);
|
2026-08-21 08:02:22 -05:00
|
|
|
Room GetCurrentRoom() { return currentRoom; }
|
|
|
|
|
|
2026-08-28 14:54:45 -05:00
|
|
|
inline bool operator!() const {
|
|
|
|
|
if (isActive) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetIsActive(const bool active) { isActive = active; }
|
|
|
|
|
|
2026-08-21 20:02:11 -05:00
|
|
|
static Game &Instance() {
|
2026-08-21 08:02:22 -05:00
|
|
|
if (game_ == nullptr) {
|
|
|
|
|
game_ = new Game();
|
2026-08-28 20:38:11 -05:00
|
|
|
game_->Init();
|
2026-08-21 08:02:22 -05:00
|
|
|
}
|
|
|
|
|
return *game_;
|
|
|
|
|
}
|
2026-08-21 20:02:11 -05:00
|
|
|
|
2026-09-11 16:07:17 -05:00
|
|
|
static void SetGameInstance(Game *g) { game_ = g; }
|
2026-08-28 20:38:11 -05:00
|
|
|
|
|
|
|
|
~Game();
|
2026-08-07 13:10:07 -05:00
|
|
|
};
|
|
|
|
|
|
2026-08-21 08:02:22 -05:00
|
|
|
// Commands
|
2026-08-21 15:52:12 -05:00
|
|
|
static int Quit(const std::string &n);
|
|
|
|
|
static int Move(const std::string &c);
|
|
|
|
|
static int Look(const std::string &c);
|