File indexing completed on 2023-10-03 07:17:58
0001 /* 0002 SPDX-FileCopyrightText: 1997 Mathias Mueller <in5y158@public.uni-hamburg.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef BOARDLAYOUT_H 0008 #define BOARDLAYOUT_H 0009 0010 // Qt 0011 #include <QString> 0012 0013 // KMahjongg 0014 #include "kmtypes.h" 0015 0016 /** 0017 * @short This class implements methods for loading and manipulating board 0018 * 0019 * @author Mauricio Piacentini <mauricio@tabuleiro.com> 0020 */ 0021 class BoardLayout 0022 { 0023 public: 0024 BoardLayout(); 0025 explicit BoardLayout(const BoardLayout & boardLayout); 0026 ~BoardLayout(); 0027 0028 void copyBoardLayout(UCHAR * to, unsigned short & numTiles) const; 0029 bool loadBoardLayout(const QString & from); 0030 bool saveBoardLayout(const QString & where) const; 0031 UCHAR getBoardData(short z, short y, short x) const; 0032 bool tileAbove(POSITION & p) const 0033 { 0034 return (tileAbove(p.z, p.y, p.x)); 0035 } 0036 void deleteTile(POSITION & p); 0037 bool anyFilled(POSITION & p) const; 0038 bool allFilled(POSITION & p) const; 0039 void insertTile(POSITION & p); 0040 bool isTileAt(POSITION & p) const 0041 { 0042 return getBoardData(p.z, p.y, p.x) == '1'; 0043 } 0044 0045 void clearBoardLayout(); 0046 void shiftLeft(); 0047 void shiftRight(); 0048 void shiftUp(); 0049 void shiftDown(); 0050 0051 int getWidth() const 0052 { 0053 return m_width; 0054 } 0055 int getHeight() const 0056 { 0057 return m_height; 0058 } 0059 int getDepth() const 0060 { 0061 return m_depth; 0062 } 0063 0064 private: 0065 bool loadBoardLayout_10(const QString & from); 0066 void setBoardData(short z, short y, short x, UCHAR value); 0067 0068 /** 0069 * is there a tile anywhere above here (top left to bot right quarter) 0070 */ 0071 bool tileAbove(short z, short y, short x) const; 0072 0073 void initialiseBoard(); 0074 0075 int m_width; 0076 int m_height; 0077 int m_depth; 0078 int m_maxTiles; 0079 0080 QString m_filename; 0081 QByteArray m_loadedBoard; 0082 QByteArray m_board; 0083 unsigned short m_maxTileNum; 0084 }; 0085 0086 #endif