Exemplo n.º 1
0
bool StoneHandler::removeStone(int x, int y, bool hide)
{
	if (!hasStone(x, y))
		return false;
	
	if (!hide)
	{
    // We delete the killed stones only if we want to update the board (i.e. : not if we are browsing the game)
    if (boardHandler->getDisplay_incoming_move())             //SL added eb 9
      if (!stones->remove(Matrix::coordsToKey(x, y)))
	    {
			   qWarning("   ***   Key for stone %d, %d not found!   ***", x, y);
			   return false;
		   }
	}
	else
	{
		Stone *s;
		if ((s = stones->find(Matrix::coordsToKey(x, y))) == NULL)
		{
			qWarning("   ***   Key for stone %d, %d not found!   ***", x, y);
			return false;
		}
		s->hide();
	}
	
	return true;
}
Exemplo n.º 2
0
bool StoneHandler::markSekiGroup(int x, int y, int &caps, StoneColor &col, bool &seki)
{
	if (hasStone(x, y) != 1)
		return false;
	
	Stone *s = getStoneAt(x, y);
	CHECK_PTR(s);
	col = s->getColor();
	
	if (!s->isSeki())
		seki = true;
	
	Group *g = assembleGroup(s, NULL);        //SL added eb 8
	CHECK_PTR(g);
	
	// Mark stones of this group as seki
	QListIterator<Stone *> it(*g);
	while (it.hasNext())
	{
		Stone *s = it.next();
		CHECK_PTR(s);
		if (seki && s->isDead())
			caps ++;
		s->setSeki(seki);
		if (seki)
		{
			s->togglePixmap(boardHandler->board->getImageHandler()->getGhostPixmaps(),
					false);
		}	
		else
		{
			s->togglePixmap(boardHandler->board->getImageHandler()->getStonePixmaps(),
					true);
		}
	}
	
	delete g;
	return true;
}
Exemplo n.º 3
0
bool StoneHandler::removeDeadGroup(int x, int y, int &caps, StoneColor &col, bool &dead)
{
	if (hasStone(x, y) != 1)
		return false;
	
	Stone *s = getStoneAt(x, y);
	CHECK_PTR(s);
	col = s->getColor();
	
	if (!s->isDead())
		dead = true;
	
	Group *g = assembleGroup(s, NULL);        //SL added eb 8
	CHECK_PTR(g);
	
	caps = g->count();
	
	// Mark stones of this group as dead or alive again
	QListIterator<Stone *> it(*g);
	while (it.hasNext())
	{
		Stone *s = it.next();
		CHECK_PTR(s);
		s->setDead(dead);
		if (dead)
		{
			s->togglePixmap(boardHandler->board->getImageHandler()->getGhostPixmaps(),
					false);
		}
		else
		{
			s->togglePixmap(boardHandler->board->getImageHandler()->getStonePixmaps(),
					true);
		}
	}
	
	delete g;
	return true;
}
Exemplo n.º 4
0
bool StoneHandler::markSekiGroup(int x, int y, int &caps, StoneColor &col, bool &seki)
{
	if (hasStone(x, y) != 1)
		return false;
	
	Stone *s = getStoneAt(x, y);
	CHECK_PTR(s);
	col = s->getColor();
	
	if (!s->isSeki())
		seki = true;
	
	Group *g = assembleGroup(s, NULL);        //SL added eb 8
	CHECK_PTR(g);
	
	// Mark stones of this group as seki
	QListIterator<Stone> it(*g);
	for (; it.current(); ++it)
	{
		s = it.current();
		CHECK_PTR(s);
		if (seki && s->isDead())
			caps ++;
		s->setSeki(seki);
		if (seki)
		{
			s->setSequence(boardHandler->board->getImageHandler()->getGhostPixmaps());
			s->shadow->hide();
		}	
		else
		{
			s->setSequence(boardHandler->board->getImageHandler()->getStonePixmaps());
			s->shadow->show();
		}
	}
	
	delete g;
	return true;
}
Exemplo n.º 5
0
bool StoneHandler::removeDeadGroup(int x, int y, int &caps, StoneColor &col, bool &dead)
{
	if (hasStone(x, y) != 1)
		return false;
	
	Stone *s = getStoneAt(x, y);
	CHECK_PTR(s);
	col = s->getColor();
	
	if (!s->isDead())
		dead = true;
	
	Group *g = assembleGroup(s, NULL);        //SL added eb 8
	CHECK_PTR(g);
	
	caps = g->count();
	
	// Mark stones of this group as dead or alive again
	QListIterator<Stone> it(*g);
	for (; it.current(); ++it)
	{
		s = it.current();
		CHECK_PTR(s);
		s->setDead(dead);
		if (dead)
		{
			s->setSequence(boardHandler->board->getImageHandler()->getGhostPixmaps());
			s->shadow->hide();
		}
		else
		{
			s->setSequence(boardHandler->board->getImageHandler()->getStonePixmaps());
			s->shadow->show();
		}
	}
	
	delete g;
	return true;
}