File indexing completed on 2024-04-21 04:02:06

0001 /***************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                *
0003 *   SPDX-FileCopyrightText: 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com>       *
0004 *                                                                         *
0005 *   SPDX-License-Identifier: GPL-2.0-or-later
0006 ***************************************************************************/
0007 #ifndef KBLOCKSFIELD_H
0008 #define KBLOCKSFIELD_H
0009 
0010 #include "FieldInterface.h"
0011 
0012 class KBlocksField : public FieldInterface
0013 {
0014 protected:
0015     bool **maBoard;
0016     int mHeight;
0017     int mWidth;
0018 
0019 private:
0020     int mCurModifyID;
0021     int mLastModifyID;
0022     unsigned char *maEncodeData;
0023 
0024 public:
0025     explicit KBlocksField(int width = 10, int height = 20);
0026     explicit KBlocksField(FieldInterface *p);
0027     ~KBlocksField() override;
0028 
0029 public:
0030     bool getCell(int xPos, int yPos) override;
0031     void setCell(int xPos, int yPos, bool value);
0032 
0033     void copy(FieldInterface *p);
0034     void clear();
0035 
0036     bool checkFilledLine(int lineID);
0037     void removeFilledLine(int lineID);
0038 
0039     bool addPunishLine(int lineCount, int punishSeed);
0040 
0041     int  getModifyID();
0042     int  encodeData(unsigned char *data);
0043     void decodeData(unsigned char *data);
0044 
0045     int  getWidth() override;
0046     int  getHeight() override;
0047 
0048     bool equals(KBlocksField *rhs);
0049 
0050     int  getBlockHeight(int xPos);
0051     int  getFreeHeight(int xPos);
0052     void getSignature(int *data);
0053 };
0054 
0055 #endif
0056