Logo Search packages:      
Sourcecode: tagua version File versions  Download package

bool Board::dropOn ( int  pool,
int  index,
const QPoint &  point 
)

Executes a drop. This function id typically called by by a PiecePool

Definition at line 697 of file board.cpp.

References clearTags(), converter(), m_entity, and m_sprites.

Referenced by PiecePool::onMouseRelease().

                                                           {

  Point to = converter()->toLogical(point);
  if (!m_sprites.valid(to))
    return false;

  clearTags("validmove");

  switch(m_entity.lock()->validTurn(pool)) {

    case Moving: {
      DropUserMove m = m_entity.lock()->createDrop(pool, index, to);
      AbstractMove::Ptr mv = m_entity.lock()->testMove(m);
      if (mv)  {
          m_entity.lock()->executeMove(mv);
          return true;
      }
      break;
    }

    case Premoving: {
      DropUserMove m = m_entity.lock()->createDrop(pool, index, to);
      if (m_entity.lock()->testPremove(m)) {
        m_entity.lock()->addPremove(m);
        setPremove(m);
      }
      break;
    }

    default:
      break;
  }

  kDebug() << "invalid move";
  error(InvalidMove);
  return false;
}


Generated by  Doxygen 1.6.0   Back to index