--- /dev/null
+#ifndef PLAYFIELD_H
+#define PLAYFIELD_H
+#include <QtCore>
+
+namespace PF
+{
+ const int FIELD_WIDTH=10;
+ const int FIELD_HEIGHT=8;
+
+ const int CELL_EMPTY=0;
+ const int CELL_WALL=1;
+
+ const int MAX_UNDO=10;
+};
+
+typedef int Field[PF::FIELD_WIDTH][PF::FIELD_HEIGHT];
+
+class PlayField : public QObject
+{
+ Q_OBJECT
+private:
+ Field field;
+ Field undos[PF::MAX_UNDO];
+ int undoMade[PF::MAX_UNDO];
+
+ int currentUndo;
+ bool moveBlock(int w, int h, int dw, int dh);
+ bool checkFall(int w, int h);
+ bool checkGlobalFall();
+ bool checkTouch();
+private:
+ void copy(const Field field_src, Field field_dst)
+ {
+ for(int w=0; w<PF::FIELD_WIDTH; w++)
+ for(int h=0; h<PF::FIELD_HEIGHT; h++)
+ field_dst[w][h]=field_src[w][h];
+ }
+ void setup(const Field field_src)
+ {
+ copy(field_src, field);
+ moves=0;
+ }
+public:
+ QString title;
+ QString solution;
+ int moves;
+ int totalUndo;
+
+ PlayField(const QString &_title, const QString &_board, const QString &_solution);
+ PlayField(PlayField *pf):title(pf->title),solution(pf->solution)
+ {
+ setup(pf->field);
+ moves=0;
+ currentUndo=0;
+ totalUndo=0;
+ }
+
+ void set(int w, int h, int cell){field[w][h]=cell;}
+ int get(int w, int h){return field[w][h];}
+ bool checkSolved();
+ const QString& getSolution()
+ {
+ return solution;
+ }
+ void move(int w, int h, int w_new);
+ void undo();
+
+signals:
+ void cellMoved(int w, int h, int wnew, int hnew);
+ void cellGone(int w, int h);
+};
+
+#endif // PLAYFIELD_H