-
Notifications
You must be signed in to change notification settings - Fork 0
/
tile.cpp
46 lines (43 loc) · 1004 Bytes
/
tile.cpp
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
#include "tile.h"
#include <QPushButton>
#include <QTextStream>
Tile::Tile(QWidget *parent)
: QPushButton(parent),
mine(false),
marked(0) {
return;
}
void Tile::mousePressEvent(QMouseEvent *e) {
if (e->button() == Qt::RightButton) {
emit rightClicked();
} else if (e->button() == Qt::LeftButton) {
emit clicked();
} else {
emit middleClicked();
}
}
void Tile::detonate() {
if (this->isEnabled()) {
if (this->mine) {
switch (this->marked) {
case 0:
this->setText("bomb");
break;
case 1:
break;
case 2:
this->setText("? bomb");
}
} else { // not a mine
switch (this->marked) {
case 0:
break;
case 1:
this->setText("⚑X");
break;
case 2:
this->setText("?X");
}
}
}
}