From e48ce4469cee270687e04bc1a2b91d3c2bba0789 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Fri, 2 Nov 2018 21:22:29 -0700 Subject: arglbargl --- Source/Panel.h | 109 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 33 deletions(-) (limited to 'Source/Panel.h') diff --git a/Source/Panel.h b/Source/Panel.h index fa3f750..4982f17 100644 --- a/Source/Panel.h +++ b/Source/Panel.h @@ -6,50 +6,95 @@ class Decoration { public: enum Shape { - Stone = 100, - Star = 200, - Poly = 400, - Eraser = 500, - Triangle = 600, + Stone = 0x100, + Star = 0x200, + Poly = 0x400, + Eraser = 0x500, + Triangle = 0x600, + }; + enum Color { + Black = 0x1, + White = 0x2, + Red = 0x3, + Blue = 0x4, + Green = 0x5, }; - Decoration() = default; - explicit Decoration(int shape); - - int GetValue(); + static nlohmann::json to_json(int decoration) { + nlohmann::json json = {}; + int shape = decoration & 0x00000F00; + if (shape == Shape::Stone) json["type"] = "square"; + if (shape == Shape::Star) json["type"] = "star"; + if (shape == Shape::Poly) json["type"] = "poly"; + if (shape == Shape::Eraser) json["type"] = "eraser"; + if (shape == Shape::Triangle) json["type"] = "triangle"; + + int color = decoration & 0x0000000F; + if (color == Color::Black) json["color"] = "black"; + if (color == Color::White) json["color"] = "white"; + if (color == Color::Red) json["color"] = "red"; + if (color == Color::Blue) json["color"] = "blue"; + if (color == Color::Green) json["color"] = "green"; + + if (json.empty()) return false; + return json; + } +}; -//private: - int _shape; +enum IntersectionFlags { + IS_ENDPOINT = 0x1, + IS_STARTPOINT = 0x2, + IS_GAP = 0x10000, + HAS_DOT = 0x8, + DOT_IS_BLUE = 0x100, + DOT_IS_ORANGE = 0x200, + DOT_IS_INVISIBLE = 0x1000, }; -class Intersection -{ +class Endpoint { public: - enum Flags { - IS_ENDPOINT = 0x1, - IS_STARTPOINT = 0x2, - IS_GAP = 0x10000, - HAS_DOT = 0x8, - DOT_IS_BLUE = 0x100, - DOT_IS_ORANGE = 0x200, - DOT_IS_INVISIBLE = 0x1000, + enum Direction { + LEFT, + RIGHT, + UP, + DOWN }; - Intersection() = default; - explicit Intersection(float x, float y, int flags); + Endpoint(int x, int y, Direction dir) { + _x = x; + _y = y; + _dir = dir; + } + + int GetX() {return _x;} + void SetX(int x) {_x = x;} + int GetY() {return _y;} + void SetY(int y) {_y = y;} + Direction GetDir() {return _dir;} + void SetDir(Direction dir) {_dir = dir;} + + nlohmann::json to_json() { + nlohmann::json json = {{"x", _x}, {"y", _y}}; + if (_dir == LEFT) json["dir"] = "left"; + if (_dir == RIGHT) json["dir"] = "right"; + if (_dir == UP) json["dir"] = "up"; + if (_dir == DOWN) json["dir"] = "down"; + return json; + } - int GetValue(); - -// private: - float _x, _y; - int _flags; +private: + int _x, _y; + Direction _dir; }; class Panel { public: explicit Panel(int id); + // explicit Panel(nlohmann::json json); + void Write(int id); + nlohmann::json Serialize(); void Random(); @@ -72,14 +117,12 @@ private: // TODO: Reflection data // TODO: Decoration colors - Memory _memory = Memory("witness64_d3d11.exe"); int _width, _height; - std::vector> _decorations; - std::vector> _intersections; - std::vector _endpoints; - std::vector _gaps; + std::vector> _grid; + std::vector _endpoints; + std::vector> _startpoints; int _style; }; \ No newline at end of file -- cgit 1.4.1