diff options
Diffstat (limited to 'Source/Puzzle.h')
-rw-r--r-- | Source/Puzzle.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Source/Puzzle.h b/Source/Puzzle.h index 7a98a78..94cb4b0 100644 --- a/Source/Puzzle.h +++ b/Source/Puzzle.h | |||
@@ -37,7 +37,6 @@ struct Decoration { | |||
37 | int count = 0; | 37 | int count = 0; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | |||
41 | struct Cell { | 40 | struct Cell { |
42 | inline static Cell Undefined() { | 41 | inline static Cell Undefined() { |
43 | Cell c; | 42 | Cell c; |
@@ -63,7 +62,9 @@ struct Cell { | |||
63 | struct Negation {}; | 62 | struct Negation {}; |
64 | struct Pos {int x; int y;}; | 63 | struct Pos {int x; int y;}; |
65 | 64 | ||
66 | struct Puzzle { | 65 | #include <cassert> // TODO: Move this + impl to cpp |
66 | class Puzzle { | ||
67 | public: | ||
67 | int16_t height; | 68 | int16_t height; |
68 | int16_t width; | 69 | int16_t width; |
69 | bool hasDecorations = false; | 70 | bool hasDecorations = false; |
@@ -72,6 +73,10 @@ struct Puzzle { | |||
72 | Symmetry sym = Symmetry::NONE; | 73 | Symmetry sym = Symmetry::NONE; |
73 | bool pillar = false; | 74 | bool pillar = false; |
74 | 75 | ||
76 | bool valid; | ||
77 | std::vector<Negation> negations; | ||
78 | std::vector<Pos> invalidElements; | ||
79 | |||
75 | inline Cell GetCell(int x, int y) const { | 80 | inline Cell GetCell(int x, int y) const { |
76 | x = Mod(x); | 81 | x = Mod(x); |
77 | if (!SafeCell(x, y)) return Cell::Undefined(); | 82 | if (!SafeCell(x, y)) return Cell::Undefined(); |
@@ -80,13 +85,24 @@ struct Puzzle { | |||
80 | inline Cell::Color GetLine(int x, int y) const { | 85 | inline Cell::Color GetLine(int x, int y) const { |
81 | return grid[x][y].color; | 86 | return grid[x][y].color; |
82 | } | 87 | } |
88 | inline void NewGrid(int newWidth, int newHeight) { | ||
89 | if (newWidth == 0) { | ||
90 | assert(false); | ||
91 | newWidth = width; | ||
92 | newHeight = height; | ||
93 | } else { | ||
94 | // @Cleanup! This should be in the ctor... | ||
95 | width = 2*newWidth + 1; | ||
96 | height = 2*newHeight + 1; | ||
97 | } | ||
98 | grid.clear(); | ||
99 | grid.resize(width); | ||
100 | for (int x=0; x<width; x++) grid[x].resize(height); | ||
101 | } | ||
102 | |||
83 | // @TODO: | 103 | // @TODO: |
84 | Pos GetSymmetricalPos(int x, int y); | 104 | Pos GetSymmetricalPos(int x, int y); |
85 | 105 | ||
86 | bool valid; | ||
87 | std::vector<Negation> negations; | ||
88 | std::vector<Pos> invalidElements; | ||
89 | |||
90 | // private: | 106 | // private: |
91 | std::vector<std::vector<Cell>> grid; | 107 | std::vector<std::vector<Cell>> grid; |
92 | 108 | ||