1 | /* |
2 | Copyright (C) 1997 Mathias Mueller <in5y158@public.uni-hamburg.de> |
3 | |
4 | Kmahjongg is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or |
7 | (at your option) any later version. |
8 | |
9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License |
15 | along with this program; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | */ |
18 | |
19 | #ifndef BOARD_LAYOUT_H |
20 | #define BOARD_LAYOUT_H |
21 | |
22 | #include <QString> |
23 | #include <QByteArray> |
24 | #include "KmTypes.h" |
25 | |
26 | const QString layoutMagic1_0 = "kmahjongg-layout-v1.0" ; |
27 | const QString layoutMagic1_1 = "kmahjongg-layout-v1.1" ; |
28 | |
29 | /** |
30 | * @short This class implements methods for loading and manipulating board |
31 | * |
32 | * longer description |
33 | * |
34 | * @author Mauricio Piacentini <mauricio@tabuleiro.com> |
35 | */ |
36 | class BoardLayout { |
37 | |
38 | public: |
39 | /** |
40 | * Default Constructor |
41 | */ |
42 | BoardLayout(); |
43 | |
44 | /** |
45 | * Copy constructor */ |
46 | BoardLayout(const BoardLayout &boardLayout); |
47 | |
48 | /** |
49 | * Default Deconstructor |
50 | */ |
51 | ~BoardLayout(); |
52 | /** |
53 | * Method description |
54 | * |
55 | * @param from blah blah |
56 | * @return @c true if ... |
57 | * @return @c false if ... |
58 | */ |
59 | bool loadBoardLayout(const QString &from); |
60 | /** |
61 | * Method description |
62 | * |
63 | * @param from blah blah |
64 | * @return @c true if ... |
65 | * @return @c false if ... |
66 | * @see loadBoardLayout |
67 | */ |
68 | bool loadBoardLayout_10(const QString &from); |
69 | /** |
70 | * Method description |
71 | * |
72 | * @param where blah blah |
73 | * @return @c true if ... |
74 | * @return @c false if ... |
75 | * @see loadBoardLayout |
76 | */ |
77 | bool saveBoardLayout(const QString &where); |
78 | /** |
79 | * Method description |
80 | * |
81 | * @param z blah blah |
82 | * @param y blah blah |
83 | * @param x blah blah |
84 | * @return UCHAR ... |
85 | */ |
86 | UCHAR getBoardData(short z, short y, short x); |
87 | /** |
88 | * Method description |
89 | * |
90 | * @param z blah blah |
91 | * @param y blah blah |
92 | * @param x blah blah |
93 | * @param value blah blah |
94 | */ |
95 | void setBoardData(short z, short y, short x, UCHAR value); |
96 | |
97 | /** |
98 | * is there a tile anywhere above here (top left to bot right quarter) |
99 | * |
100 | * @param z blah blah |
101 | * @param y blah blah |
102 | * @param x blah blah |
103 | * @return @c true if title abowe |
104 | * @return @c false if title not abowe |
105 | */ |
106 | bool tileAbove(short z, short y, short x); |
107 | /** |
108 | * is there a tile anywhere above here (top left to bot right quarter) |
109 | * |
110 | * @param &p blah blah @ref pos |
111 | * @return @c true if title abowe |
112 | * @return @c false if title not abowe |
113 | * @see tileAbove |
114 | */ |
115 | bool tileAbove(POSITION &p) { return(tileAbove(p.e, p.y, p.x)); } |
116 | |
117 | /** |
118 | * is this tile blocked to the left or right |
119 | * |
120 | * @param z blah blah |
121 | * @param y blah blah |
122 | * @param x blah blah |
123 | * @return @c true if ... |
124 | * @return @c false if ... |
125 | */ |
126 | bool blockedLeftOrRight(short z, short y, short x); |
127 | /** |
128 | * Description |
129 | * |
130 | * @param &p blah blah @ref pos |
131 | */ |
132 | void deleteTile(POSITION &p); |
133 | /** |
134 | * Description |
135 | * |
136 | * @param &p blah blah @ref pos |
137 | * @return @c true if title abowe |
138 | * @return @c false if title not abowe |
139 | */ |
140 | bool anyFilled(POSITION &p); |
141 | /** |
142 | * Description |
143 | * |
144 | * @param &p blah blah @ref pos |
145 | * @return @c true if title abowe |
146 | * @return @c false if title not abowe |
147 | */ |
148 | bool allFilled(POSITION &p); |
149 | /** |
150 | * Description |
151 | * |
152 | * @param &p blah blah |
153 | * @see pos |
154 | */ |
155 | void insertTile(POSITION &p); |
156 | /** |
157 | * Description |
158 | * |
159 | * @param &p blah blah |
160 | * @see pos |
161 | * @return @c true if title abowe |
162 | * @return @c false if title not abowe |
163 | */ |
164 | bool isTileAt(POSITION &p) { return getBoardData(p.e, p.y, p.x) == '1'; } |
165 | /** |
166 | * Description |
167 | * |
168 | * @param *to blah blah |
169 | * @param &numTiles blah blah |
170 | */ |
171 | void copyBoardLayout(UCHAR *to , unsigned short &numTiles); |
172 | /** |
173 | * Method description |
174 | */ |
175 | void clearBoardLayout(); |
176 | /** |
177 | * Method description |
178 | */ |
179 | void shiftLeft(); |
180 | /** |
181 | * Method description |
182 | */ |
183 | void shiftRight(); |
184 | /** |
185 | * Method description |
186 | */ |
187 | void shiftUp(); |
188 | /** |
189 | * Method description |
190 | */ |
191 | void shiftDown(); |
192 | |
193 | /** |
194 | * Get the loaded board. */ |
195 | QByteArray getLoadedBoard() const; |
196 | |
197 | /** |
198 | * Get the board. */ |
199 | QByteArray getBoard() const; |
200 | |
201 | /** |
202 | * Get max tile num. */ |
203 | unsigned short getMaxTileNum() const; |
204 | |
205 | int m_width; /**< Member Description */ |
206 | int m_height; /**< Member Description */ |
207 | int m_depth; /**< Member Description */ |
208 | int m_maxTiles;/**< Member Description */ |
209 | /** |
210 | * Get filename |
211 | * |
212 | * @return filename |
213 | */ |
214 | QString getFilename() const; |
215 | |
216 | protected: |
217 | /** |
218 | * Protected Method description |
219 | */ |
220 | void initialiseBoard(); |
221 | |
222 | private: |
223 | QString filename; /**< Private Member Description */ |
224 | QByteArray loadedBoard; /**< Private Member Description */ |
225 | QByteArray board; /**< Private Member Description */ |
226 | unsigned short maxTileNum; /**< Private Member Description */ |
227 | }; |
228 | |
229 | #endif |
230 | |
231 | |