Beispiel #1
0
bool GameStartLayer::canMove(int moveid, int row, int col, int killid)
{
	Stone *s = _s[moveid];
	switch (s->_proper._type)
	{
	case Stone::ROOK:
		return canMoveRook(moveid, row, col);

	case Stone::HORSE:
		return canMoveHorse(moveid, row, col);

	case Stone::CANNON:
		return canMoveCannon(moveid, row, col, killid);

	case Stone::PAWN:
		return canMovePawn(moveid, row, col);

	case Stone::KING:
		return canMoveKing(moveid, row, col, killid);

	case Stone::GUARD:
		return canMoveGuard(moveid, row, col);

	case Stone::ELEPH:
		return canMoveEleph(moveid, row, col);
		break;
	}

	return false;
}
Beispiel #2
0
//! Checks if the player with the color color is check mate.
bool Board::checkMate(Color color)
{
	// Find out the piece(s) that are checking
	Piece* checker = NULL;
	int checkers = 0;
	checker = getCheckers(color, checkers);
	if(checkers != 0)
	{
		// Is there any move white can do?
		// 1.) Can he move the king out of check?
		// 2.) Can he capture the checker?
		// 3.) Can he go between the checking line?

		// Impossible to capture or intersect two checking pieces
		if(!canMoveKing(color) && checkers >= 2)
			return true;

		return !canMoveKing(color) && !canMoveTo(color, checker->getPos().x, checker->getPos().y) && !canIntersectChecker(color, checker);
	}
	else 
		return false;
}