当前位置: 首页>>代码示例>>C++>>正文


C++ Stone::visible方法代码示例

本文整理汇总了C++中Stone::visible方法的典型用法代码示例。如果您正苦于以下问题:C++ Stone::visible方法的具体用法?C++ Stone::visible怎么用?C++ Stone::visible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stone的用法示例。


在下文中一共展示了Stone::visible方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkNeighbourLiberty

void StoneHandler::checkNeighbourLiberty(int x, int y, QValueList<int> &libCounted, int &liberties, Matrix *m)    //SL added eb 8
{
	if (!x || !y)
		return;
	
	Stone *s;
//  CHECK_PTR(m); // SL added eb 8

  if (m==NULL) //added eb 8 -> we don't have a matrix passed here, so we check on the board
  {
	  if (x <= boardHandler->board->getBoardSize() && y <= boardHandler->board->getBoardSize() && x >= 0 && y >= 0 &&
		  !libCounted.contains(100*x + y) &&
  		((s = stones->find(Matrix::coordsToKey(x, y))) == NULL ||
	  	!s->visible()))
	  {
		  libCounted.append(100*x + y);
		  liberties ++;
	  }
  }  
  else                                      
  {
    if (x <= boardHandler->board->getBoardSize() && y <= boardHandler->board->getBoardSize() && x >= 0 && y >= 0 &&
	    !libCounted.contains(100*x + y) &&
	    (m->at(x - 1, y - 1) == stoneNone ))         // ?? check stoneErase ?
	  {
		  libCounted.append(100*x + y);
		  liberties ++;
	  }            // end add eb 8
  }
}
开发者ID:rd8,项目名称:qGo,代码行数:30,代码来源:stonehandler.cpp

示例2: checkNeighbour

Group* StoneHandler::checkNeighbour(int x, int y, StoneColor color, Group *group, Matrix *m) //SL added eb 8
{
//	CHECK_PTR(group);
//	CHECK_PTR(m); //added eb 8
  bool visible = false ;
  int size = boardHandler->board->getBoardSize();     //end add eb 8

  Stone *tmp = stones->find(Matrix::coordsToKey(x, y));
  
  // Okay, this is dirty and synthetic :
  // Because we use this function where the matrix can be NULL, we need to check this
  // Furthermore, since this has been added after the first code, we keep the 'stone->visible' test where one should only use the 'matrix' code
  if (m != NULL && x-1 >= 0 && x-1 < size && y-1 >= 0 && y-1 < size) //SL added eb 8
   visible = (m->at(x - 1, y - 1) != stoneNone); //SL added eb 9 We do this in order not to pass a null matrix to the matrix->at function (seen in handicap games)

  // again we priviledge matrix over stone visibility (we might be browsing a game)
	if (tmp != NULL && tmp->getColor() == color && (tmp->visible()|| visible)) //SL added eb 8
	{
		if (!group->contains(tmp))
		{
			group->append(tmp);
			tmp->checked = true;
		}
	}
	return group;
}
开发者ID:rd8,项目名称:qGo,代码行数:26,代码来源:stonehandler.cpp

示例3: hasStone

//  0 : no stone
// -1 : hidden
//  1 : shown
int StoneHandler::hasStone(int x, int y)
{
	Stone *s;
	
	if ((s = stones->find(Matrix::coordsToKey(x, y))) == NULL)
		return 0;
	
	if (s->visible())
		return 1;
	
	return -1;
}
开发者ID:rd8,项目名称:qGo,代码行数:15,代码来源:stonehandler.cpp

示例4: updateAll

bool StoneHandler::updateAll(Matrix *m, bool toDraw)
{
	// qDebug("StoneHandler::updateAll(Matrix *m) - toDraw = %d", toDraw);
	
	CHECK_PTR(m);
	
	// m->debug();
	
	Stone *stone;
	bool modified = false, fake = false;
	short data;
	
	/*
	* Synchronize the matrix with the stonehandler data and
	* update the canvas.
	* This is usually called when navigating through the tree.
	*/
	
	for (int y=1; y<=boardHandler->board->getBoardSize(); y++)
	{
		for (int x=1; x<=boardHandler->board->getBoardSize(); x++)
		{
			// Extract the data for the stone from the matrix
			data = abs(m->at(x-1, y-1) % 10);
			switch (data)
			{
			case stoneBlack:
				if ((stone = stones->find(Matrix::coordsToKey(x, y))) == NULL)
				{
					addStone(boardHandler->board->addStoneSprite(stoneBlack, x, y, fake), true, false);
					modified = true;
					break;
				}
				else if (!stone->visible())
				{
					stone->show();
					modified = true;
				}
				
				if (stone->getColor() == stoneWhite)
				{
					stone->setColor(stoneBlack);
					modified = true;
				}
				
				break;
				
			case stoneWhite:
				if ((stone = stones->find(Matrix::coordsToKey(x, y))) == NULL)
				{
					addStone(boardHandler->board->addStoneSprite(stoneWhite, x, y, fake), true, false);
					modified = true;
					break;
				}
				else if (!stone->visible())
				{
					stone->show();
					modified = true;
				}
				
				if (stone->getColor() == stoneBlack)
				{
					stone->setColor(stoneWhite);
					modified = true;
				}
				
				break;
				
			case stoneNone:
			case stoneErase:
				if ((stone = stones->find(Matrix::coordsToKey(x, y))) != NULL &&
					stone->visible())
				{
					stone->hide();
					modified = true;
				}
				break;
				
			default:
				qWarning("Bad matrix data <%d> at %d/%d in StoneHandler::updateAll(Matrix *m) !",
					data, x, y);
			}
			
			// Skip mark drawing when reading sgf
			if (!toDraw)
				continue;
			
			// Extract the mark data from the matrix
			data = abs(m->at(x-1, y-1) / 10);
			switch (data)
			{
			case markSquare:
				modified = true;
				boardHandler->board->setMark(x, y, markSquare, false);
				break;
				
			case markCircle:
				modified = true;
				boardHandler->board->setMark(x, y, markCircle, false);
				break;
//.........这里部分代码省略.........
开发者ID:rd8,项目名称:qGo,代码行数:101,代码来源:stonehandler.cpp


注:本文中的Stone::visible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。