-
Notifications
You must be signed in to change notification settings - Fork 1
/
twintool.cpp
61 lines (50 loc) · 1.47 KB
/
twintool.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "twintool.h"
#include "gamesound.h"
#include "gamebonus.h"
#include "scene_if.h"
TwinTool::TwinTool(int x, int y, int score) : GameTool(x,y, score, "twins")
{
bonusInfo = new BonusInfo(1000, myPixmap, tr("Twin Blaster"),
tr("Removes all the identical items from the field"));
}
GameTool::ToolAction TwinTool::checkItemState(int row, int col)
{
PlaceInfo &pi = scene->data(row,col);
PlaceInfo &pi1 = scene->data(myToolset->toolRow(), myToolset->toolCol());
if (pi.itemCanBeHighlighted() && pi1.itemCanBeHighlighted())
{
if (pi1.item->id() == pi.item->id())
return ToolActive;
}
return ToolOutOfRange;
}
bool TwinTool::checkItemClick(int row, int col)
{
PlaceInfo &pi = scene->data(row,col);
if (pi.itemCanBeHighlighted())
{
quint8 id = pi.item->id();
int rows = scene->numRows();
int cols = scene->numCols();
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
PlaceInfo &pi1 = scene->data(i,j);
if (pi1.itemCanBeHighlighted())
{
if (pi1.item->id() == id)
{
// remove block
scene->removeAndCountItem(i,j);
//scene->createPixmapPopup(scene->col2x(j), scene->row2y(i), 0, 5, myPixmap, 5);
scene->createPixmapPopup(scene->col2x(j), scene->row2y(i), 0, -5, myPixmap, 5);
}
}
}
}
sndEngine->playSound(GameSound::sndTwin);
return true;
}
return false;
}