示例#1
0
void CheckerBoard::initCheckers()
{
    for(int i=0; i<3; ++i)
        for(int j=0; j<8; ++j)
        {
            if((i+j)%2==0)
                addChecker(new Checker(Checker::WHITE),j,7-i);
        }

    for(int i=0; i<3; ++i)
        for(int j=0; j<8; ++j)
        {
            if((i+j)%2==1)
                addChecker(new Checker(Checker::BLACK),j,i);
        }
}
示例#2
0
void Point::dropEvent(QDropEvent * event) {
  if (event->mimeData()->hasFormat("application/x-backgammon-checkerdrop")) {
    int thisCheckersColor = ((Checker*) event->source())->getMyColor();
    if ((getCheckersNo() < 2) || (thisCheckersColor == checkersColor())) {
      event->acceptProposedAction();
      Checker *thisChecker = (Checker*) event->source();
      thisChecker->getMyPlace()->removeChecker();
      if ((getCheckersNo() == 1) && (thisCheckersColor != checkersColor())) { //hit
	emit killedChecker(topChecker());
	removeChecker();
      }
      addChecker(thisChecker);
    } else
      event->ignore();
  } else
    event->ignore();
}