-
Notifications
You must be signed in to change notification settings - Fork 0
/
game2048.h
68 lines (55 loc) · 2.17 KB
/
game2048.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef GAME2048_H
#define GAME2048_H
#include "boardgame.h"
class Game2048 : public BoardGame
{
Q_OBJECT
public:
Game2048(QObject *parent) : BoardGame(parent) {}
//~Game2048(void) {constructed = false;}
//virtual void reset(void);
virtual void refresh(QPixmap *cache);
virtual void hoverPixmap(QPixmap *cache, QPixmap *hover, const int player) {hover->resize(-1, -1);}
// Game type information
virtual QSize size(void) const {return QSize(4, 4);}
virtual int playerCount(void) const {return 1;}
virtual QString gameName(void) const {return tr("2048");}
virtual QString winMessage(const int player, const QString msg) const {return "Gameover.";}
virtual bool aiAvailable(void) const {return false;}
virtual int win(void) {return -1;}
//virtual bool mouseReleaseEvent(const ButtonState button, const QPoint& point, const int player);
protected:
virtual bool place(const QPoint& point, const int player) {return false;}
//virtual void paintPoint(QPainter *painter, const QRect& rect, const int id);
//virtual void drawHover(QPixmap *hover, QPainter *painter, const int player);
// Game type information
virtual BoardTypes boardType(void) const {return EdgeLine;}
//virtual QColor playerColor(int player) const {return idColor(player);}
private:
//int mineCount(const QPoint& point) const;
//int flagCount(const QPoint& point) const;
//QColor idColor(int index) const;
enum Displays {Empty = 0, D2, D4, D8, D16, D32, D64, D128, D256, D512, D1024, D2048, D4096, D8192, D16384, D32768, D65536, D131072, Total};
//static bool constructed;
struct {
//bool first, died;
//int w, h, total, remaining;
//QPixmap flag, mine;
QPixmap display[Total];
} info;
//static const unsigned long tileData[13][3];
//static const QColor idColors[TotalIDs];
class Tile
{
public:
enum DataType {Background = 0, Foreground = 1, FontSize = 2};
static QColor foreground(const unsigned int value);
static QColor background(const unsigned int value);
static QFont font(const unsigned int value);
private:
static unsigned long data(const unsigned long index, const DataType type);
static unsigned long toIndex(const unsigned long value);
static const unsigned long d[13][3];
};
};
#endif