-
Notifications
You must be signed in to change notification settings - Fork 1
/
thundertool.cpp
66 lines (49 loc) · 1.31 KB
/
thundertool.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
62
63
64
65
#include "thundertool.h"
#include "gameitem.h"
#include "gamesound.h"
#include "gamebonus.h"
#include "scene_if.h"
ThunderTool::ThunderTool(int x, int y, int score) : GameTool(x,y, score, "cross")
{
bonusInfo = new BonusInfo(1000, myPixmap, tr("Row Blaster"),
tr("Removes items in a row"));
}
GameTool::ToolAction ThunderTool::checkItemState(int row, int col)
{
int tr = myToolset->toolRow(), tc = myToolset->toolCol();
PlaceInfo &pi1 = scene->data(tr,tc);
if (pi1.empty())
return ToolOutOfRange;
if (row == tr)
{
PlaceInfo &pi = scene->data(row,col);
if (pi.itemCanBeHighlighted())
{
if (!pi1.itemCanBeHighlighted())
return ToolInactive;
return ToolActive;
}
if (!pi.empty())
return ToolInactive;
}
return ToolOutOfRange;
}
bool ThunderTool::checkItemClick(int row, int col)
{
PlaceInfo &pi = scene->data(row,col);
if (!pi.itemCanBeHighlighted())
return false;
int cx = -1;
for (int j = 0; j < scene->numCols(); j++)
{
PlaceInfo &pi = scene->data(row,j);
if (pi.itemCanBeHighlighted())
{
scene->removeAndCountItem(row,j);
scene->createPixmapPopup(scene->col2x(j), scene->row2y(row), 0, 5*cx, myPixmap, 5);
}
cx = -cx;
}
sndEngine->playSound(GameSound::sndRow);
return true;
}