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

60 lines
1.2 KiB
C++
Raw Normal View History

2026-08-07 13:10:07 -05:00
#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"
2026-08-21 08:02:22 -05:00
static int curX, curY;
2026-08-07 13:10:07 -05:00
extern bool isActive;
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-21 08:02:22 -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();
static bool GetIsActive() { return isActive; }
bool Init();
void Run();
bool Save();
2026-08-21 08:02:22 -05:00
2026-08-21 15:52:12 -05:00
void ChangeRoom(Room r);
2026-08-21 08:02:22 -05:00
Room GetCurrentRoom() { return currentRoom; }
2026-08-07 13:10:07 -05:00
static void SetIsActive(const bool active) { isActive = active; }
2026-08-21 08:02:22 -05:00
static Game &instance() {
static Game *game_;
if (game_ == nullptr) {
game_ = new Game();
}
return *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);