+
+void GameView::setMovingPieces()
+{
+ if(pieces_.isEmpty()) {
+ qDebug() << "Empty list @ GameView::setMovingPieces";
+ return;
+ }
+
+ QPointF point = QPointF();
+ for(int i = 0; i < pieces_.count(); ++i) {
+ point = pieces_.at(i)->currentPlace();
+
+ // Is piece on the left side of the empty space
+ if(emptyPlace_.y() == point.y() && point.x() + horizontalStep_ == emptyPlace_.x()) {
+ pieces_.at(i)->setMovable(true);
+ }
+
+ // Is piece on the right side of the empty space
+ else if(emptyPlace_.y() == point.y() && point.x() - horizontalStep_ == emptyPlace_.x()) {
+ pieces_.at(i)->setMovable(true);
+ }
+
+ // Is piece below the empty space
+ else if(emptyPlace_.x() == point.x() && point.y() - verticalStep_ == emptyPlace_.y()) {
+ pieces_.at(i)->setMovable(true);
+ }
+
+ // Is piece on top of the empty space
+ else if(emptyPlace_.x() == point.x() && point.y() + verticalStep_ == emptyPlace_.y()) {
+ pieces_.at(i)->setMovable(true);
+ }
+
+ // The piece is somewhere else
+ else {
+ pieces_.at(i)->setMovable(false);
+ }
+ }
+}