#ifndef Q2048VIEW_H
#define Q2048VIEW_H

#include <q2048ai.h>

#include <QGraphicsView>

class Q2048Tile;

class Q2048View : public QGraphicsView
{
	Q_OBJECT
public:
	explicit Q2048View(QWidget *parent = 0);
	QRectF tileRect(int x, int y) const;
private:
	static QString key2txt(int k);
	void keyPressEvent(QKeyEvent * event);
	void resizeEvent(QResizeEvent * event);
	int moveTiles(int x, int y);
	int score(int);
	Q2048Tile* addTile();
	bool gameOver(void) const;

	Q2048AI AI;
	int Score;
	bool AutoPlay;
public:
	const int Size;
	const int Width;
	const int Height;
	const int Border;
signals:
	void newScore(QString);
public slots:
	void deleteMerged();
	void newGame();
	void setAutoPlay(bool);
};

#endif // Q2048VIEW_H
