示例#1
0
void ChessBoard::ResolveCastleLineOfSight(bool bIsWhite)
{
	Player* opponentPlayer;
	Player* currPlayer;
	if (bIsWhite)
	{
		opponentPlayer = _BlackPlayer;
		currPlayer = _WhitePlayer;
	}
	else
	{
		opponentPlayer = _WhitePlayer;
		currPlayer = _BlackPlayer;
	}
	
	ChessSquare OpponentKingLoc = opponentPlayer->GetKingLocation();
	for (int i = 0; i < currPlayer->GetNumPiecesLeft(); i++)
	{
		ChessPiece* currPiece = currPlayer->GetPiece(i);
		if (pieceToText(currPiece) == 'R')
		{
			if (currPiece->HasLineToKing(OpponentKingLoc) )
			{
				currPlayer->AddToKingAttacking(currPiece);
			}
		}
	}
	opponentPlayer->ClearAttackingKingPieces();
	ChessSquare KingLoc = currPlayer->GetKingLocation();
	for (int i = 0; i < opponentPlayer->GetNumPiecesLeft(); i++)
	{
		ChessPiece* currPiece = opponentPlayer->GetPiece(i);
		
		if (currPiece->HasLineToKing( KingLoc) )
			opponentPlayer->AddToKingAttacking(currPiece);
	}
				
	
}
示例#2
0
void ChessBoard::ResolveLineOfSight(ChessPiece* movedPiece)
{
	Player* opponentPlayer;
	Player* currPlayer;
	if (movedPiece->isWhite())
	{
		opponentPlayer = _BlackPlayer;
		currPlayer = _WhitePlayer;
	}
	else
	{
		opponentPlayer = _WhitePlayer;
		currPlayer = _BlackPlayer;
	}
	//Will be handled here now lulz
	if (pieceToText(movedPiece) == 'K')
	{
		opponentPlayer->ClearAttackingKingPieces();
		ChessSquare KingLoc = currPlayer->GetKingLocation();
		for (int i = 0; i < opponentPlayer->GetNumPiecesLeft(); i++)
		{
			ChessPiece* currPiece = opponentPlayer->GetPiece(i);
			if (currPiece->HasLineToKing(KingLoc) )
				opponentPlayer->AddToKingAttacking(currPiece);
		}
		return;
	}
	
	ChessSquare KingLoc = opponentPlayer->GetKingLocation();
	
	if (!movedPiece->IsInKingArray() )
	{
		if (movedPiece->HasLineToKing(KingLoc) )
		{
			currPlayer->AddToKingAttacking(movedPiece);
		}
	}
	else 
	{
		if (movedPiece->HasLineToKing(KingLoc) )
		{
			//currPlayer->AddToKingAttacking(movedPiece);
		}
		else
			currPlayer->RemoveKingAttacking(movedPiece);
	}
	
}