X-Git-Url: http://git.maemo.org/git/?p=impuzzle;a=blobdiff_plain;f=src%2Fpuzzleitem.cpp;h=500b47507ce0e408e62acdec3bc5c1543f98d558;hp=1be8e9e182f17ac29c3120cb600bc5984829e4b4;hb=a27dea60eebff3d5bd0068f31e7d042e8c7d0048;hpb=e90ecb7db7b5d4d22fb08f8053db4423797b5afc diff --git a/src/puzzleitem.cpp b/src/puzzleitem.cpp index 1be8e9e..500b475 100644 --- a/src/puzzleitem.cpp +++ b/src/puzzleitem.cpp @@ -22,6 +22,8 @@ #include #include +int PuzzleItem::moveCount_ = 0; + PuzzleItem::PuzzleItem(QGraphicsItem *parent) : QGraphicsPixmapItem(parent) { @@ -75,9 +77,17 @@ void PuzzleItem::mousePressEvent(QGraphicsSceneMouseEvent *event) GameView::instance()->setEmptyPlace(tmp); event->accept(); + moveCount_++; + // If piece is in its place check if we won the game + bool won = false; if(currentPlace() == correctPlace()) { - GameView::instance()->areAllPiecesOk(); + won = GameView::instance()->areAllPiecesOk(); + } + + // if we didn't win set pieces that can be moved + if(!won) { + GameView::instance()->setMovingPieces(); } } else { @@ -89,3 +99,13 @@ void PuzzleItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { event->ignore(); } + +int PuzzleItem::moveCount() +{ + return moveCount_; +} + +void PuzzleItem::resetMoveCount() +{ + moveCount_ = 0; +}