2026-08-07 13:10:07 -05:00
|
|
|
#pragma once
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "json.hpp"
|
2026-09-01 16:27:01 -05:00
|
|
|
#include "scenery.h"
|
2026-08-07 13:10:07 -05:00
|
|
|
|
|
|
|
|
using json = nlohmann::json;
|
|
|
|
|
|
|
|
|
|
enum Direction { N, S, E, W };
|
|
|
|
|
|
|
|
|
|
struct Exit {
|
|
|
|
|
int exitID;
|
|
|
|
|
Direction dir;
|
|
|
|
|
bool isLocked;
|
|
|
|
|
friend void from_json(const json &j, Exit &e);
|
|
|
|
|
friend void to_json(json &j, const Exit &e);
|
|
|
|
|
};
|
|
|
|
|
|
2026-08-21 15:52:12 -05:00
|
|
|
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"}};
|
2026-08-21 08:02:22 -05:00
|
|
|
|
2026-08-07 13:10:07 -05:00
|
|
|
class Room {
|
|
|
|
|
private:
|
|
|
|
|
int id;
|
|
|
|
|
std::string name;
|
|
|
|
|
std::string description;
|
|
|
|
|
std::vector<Exit> exits;
|
2026-09-01 16:27:01 -05:00
|
|
|
std::vector<Scenery> scenery;
|
2026-08-07 13:10:07 -05:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Room();
|
2026-09-02 11:24:10 -05:00
|
|
|
Room(int i, std::string n, std::string desc, std::vector<Exit> e, std::vector<Scenery> s);
|
2026-08-07 13:10:07 -05:00
|
|
|
Room(const Room &r);
|
|
|
|
|
|
2026-08-21 08:02:22 -05:00
|
|
|
void PrintAvalibleExits();
|
2026-08-07 13:10:07 -05:00
|
|
|
void Print() const;
|
2026-08-20 08:10:07 -05:00
|
|
|
int GetID() const { return id; }
|
|
|
|
|
|
2026-08-21 08:02:22 -05:00
|
|
|
bool ValidDirection(Direction d);
|
|
|
|
|
|
2026-08-21 15:52:12 -05:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-07 13:10:07 -05:00
|
|
|
~Room();
|
|
|
|
|
|
|
|
|
|
friend void to_json(nlohmann::json &j, const Room &r);
|
|
|
|
|
friend void from_json(const nlohmann::json &j, Room &r);
|
|
|
|
|
};
|