-
Notifications
You must be signed in to change notification settings - Fork 1
/
smallhammertool.cpp
46 lines (37 loc) · 1.26 KB
/
smallhammertool.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 "smallhammertool.h"
#include "gameitem.h"
#include "gamesound.h"
#include "gamebonus.h"
#include "scene_if.h"
SmallHammerTool::SmallHammerTool(int x, int y, int score) : GameTool(x, y, score, "hammer")
{
bonusInfo = new BonusInfo(1000, myPixmap, tr("Hammer"),
tr("Removes only unblocked items (no effect on block & target)"));
}
GameTool::ToolAction SmallHammerTool::checkItemState(int row, int col)
{
if (row == myToolset->toolRow() && col == myToolset->toolCol())
{
PlaceInfo &pi = scene->data(row,col);
if (pi.itemCanBeHighlighted() && !pi.hasBlock())
return ToolActive;
if (!pi.empty())
return ToolInactive;
}
return ToolOutOfRange;
}
bool SmallHammerTool::checkItemClick(int row, int col)
{
PlaceInfo &pi = scene->data(row,col);
if (pi.itemCanBeHighlighted() && !pi.hasBlock() && !pi.item->isNotAlive())
{
// this only schedules a removal
scene->removeAndCountItemOnly(row,col);
//scene->removeAndCountItem(row,col);
scene->createPixmapPopup(scene->col2x(col), scene->row2y(row), 0, 5, myPixmap, 5);
scene->createPixmapPopup(scene->col2x(col), scene->row2y(row), 0, -5, myPixmap, 5);
sndEngine->playSound(GameSound::sndSmallHammer);
return true;
}
return false;
}