diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-09 12:04:19 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-09 12:04:19 -0800 |
commit | ecbcb91e95a08201fbf90476ee4a18526cfc80bb (patch) | |
tree | 2a45b8c8785d022eac1d84a3bb004f3aaeb1d200 /Source/Panel.h | |
parent | 4d55d7d9aad8d3c2bedec371c165bbb848c3786b (diff) | |
download | witness-tutorializer-ecbcb91e95a08201fbf90476ee4a18526cfc80bb.tar.gz witness-tutorializer-ecbcb91e95a08201fbf90476ee4a18526cfc80bb.tar.bz2 witness-tutorializer-ecbcb91e95a08201fbf90476ee4a18526cfc80bb.zip |
Commit early, commit often
Diffstat (limited to 'Source/Panel.h')
-rw-r--r-- | Source/Panel.h | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/Source/Panel.h b/Source/Panel.h index caa7b04..0ee94f8 100644 --- a/Source/Panel.h +++ b/Source/Panel.h | |||
@@ -30,30 +30,31 @@ enum Color { | |||
30 | struct Decoration { | 30 | struct Decoration { |
31 | Shape type; | 31 | Shape type; |
32 | Color color; | 32 | Color color; |
33 | int polyshape; | 33 | int polyshape = 0; |
34 | // For triangles only | 34 | // For triangles only |
35 | int count; | 35 | int count = 0; |
36 | }; | 36 | }; |
37 | 37 | ||
38 | struct Cell { | 38 | struct Cell { |
39 | bool start; | 39 | bool start = false; |
40 | enum class Dir {NONE, LEFT, RIGHT, UP, DOWN}; | 40 | enum class Dir {NONE, LEFT, RIGHT, UP, DOWN}; |
41 | Dir end; | 41 | Dir end = Dir::NONE; |
42 | std::shared_ptr<Decoration> decoration; | 42 | std::shared_ptr<Decoration> decoration = nullptr; |
43 | enum class Dot {NONE, BLACK, BLUE, YELLOW, INVISIBLE}; | 43 | enum class Dot {NONE, BLACK, BLUE, YELLOW, INVISIBLE}; |
44 | Dot dot; | 44 | Dot dot = Dot::NONE; |
45 | enum class Gap {NONE, BREAK, FULL}; | 45 | enum class Gap {NONE, BREAK, FULL}; |
46 | Gap gap; | 46 | Gap gap = Gap::NONE; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | struct Puzzle { | 49 | struct Puzzle { |
50 | int16_t height; | 50 | int16_t height; |
51 | int16_t width; | 51 | int16_t width; |
52 | bool hasDecorations = false; | ||
52 | std::vector<std::vector<Cell>> grid; | 53 | std::vector<std::vector<Cell>> grid; |
53 | 54 | ||
54 | enum class Symmetry {NONE, X, Y, XY}; | 55 | enum class Symmetry {NONE, X, Y, XY}; |
55 | Symmetry sym; | 56 | Symmetry sym = Symmetry::NONE; |
56 | bool pillar; | 57 | bool pillar = false; |
57 | }; | 58 | }; |
58 | 59 | ||
59 | class PuzzleSerializer { | 60 | class PuzzleSerializer { |
@@ -65,13 +66,16 @@ public: | |||
65 | private: | 66 | private: |
66 | // @Bug: Blue and orange are swapped? | 67 | // @Bug: Blue and orange are swapped? |
67 | enum Flags { | 68 | enum Flags { |
68 | IS_ENDPOINT = 0x1, | 69 | IS_ENDPOINT = 0x1, |
69 | IS_STARTPOINT = 0x2, | 70 | IS_STARTPOINT = 0x2, |
70 | DOT_IS_BLUE = 0x100, | 71 | IS_FULL_GAP = 0x8, |
71 | DOT_IS_ORANGE = 0x200, | 72 | HAS_DOT = 0x20, |
72 | DOT_IS_INVISIBLE = 0x1000, | 73 | DOT_IS_BLUE = 0x100, |
73 | IS_GAP = 0x10000, | 74 | DOT_IS_ORANGE = 0x200, |
74 | HAS_DOT = 0x40020, | 75 | DOT_IS_INVISIBLE = 0x1000, |
76 | HAS_NO_CONN = 0x100000, | ||
77 | HAS_VERTI_CONN = 0x200000, | ||
78 | HAS_HORIZ_CONN = 0x400000, | ||
75 | }; | 79 | }; |
76 | 80 | ||
77 | void ReadIntersections(Puzzle& p, int id); | 81 | void ReadIntersections(Puzzle& p, int id); |
@@ -79,12 +83,14 @@ private: | |||
79 | void WriteIntersections(const Puzzle& p, int id); | 83 | void WriteIntersections(const Puzzle& p, int id); |
80 | void WriteDecorations(const Puzzle& p, int id); | 84 | void WriteDecorations(const Puzzle& p, int id); |
81 | 85 | ||
82 | std::tuple<int, int> loc_to_xy(const Puzzle& p, int location); | 86 | std::tuple<int, int> loc_to_xy(const Puzzle& p, int location) const; |
83 | int xy_to_loc(const Puzzle& p, int x, int y); | 87 | int xy_to_loc(const Puzzle& p, int x, int y) const; |
84 | // Decoration location | 88 | // Decoration location |
85 | std::tuple<int, int> dloc_to_xy(const Puzzle& p, int location); | 89 | std::tuple<int, int> dloc_to_xy(const Puzzle& p, int location) const; |
86 | int xy_to_dloc(const Puzzle& p, int x, int y); | 90 | int xy_to_dloc(const Puzzle& p, int x, int y) const; |
87 | Cell::Dot FlagsToDot(int flags); | 91 | Cell::Dot FlagsToDot(int flags) const; |
92 | // Iterate connection lists for another location which is connected to us; return that other location. | ||
93 | int FindConnection(int i, const std::vector<int>& connections_a, const std::vector<int>& connections_b) const; | ||
88 | 94 | ||
89 | std::shared_ptr<Memory> _memory; | 95 | std::shared_ptr<Memory> _memory; |
90 | }; | 96 | }; |