private bool CanSmallRoque(Board board) { if (HasMoved) { return(false); } var rook = board.GetPiece(new PiecePosition('H', _initialeLine)); if (rook.HasMoved) { return(false); } for (char col = 'F'; col <= 'G'; col++) { var piecePosition = new PiecePosition(col, _initialeLine); if (board.GetPiece(piecePosition) != null || board.IsPositionThreatened(piecePosition, Color)) { return(false); } } return(true); }
public void Play(Board board) { Console.WriteLine("ShowMoves [position]; Move [initial_position] [destination_position]; IsThreatened [position]; EXIT"); Console.Write("->"); var instruction = Console.ReadLine().Split(' '); switch (instruction[0].ToLower()) { case "sm": var possibleMoves = board.GetPossiblePiecePositions(GetPositionInInstruction(instruction, 1)); _renderBoard(board, possibleMoves); Play(board); break; case "m": var fromPosition = GetPositionInInstruction(instruction, 1); var toPosition = GetPositionInInstruction(instruction, 2); if (!board.Move(this, fromPosition, toPosition)) { Play(board); } break; case "it": if (board.IsPositionThreatened(GetPositionInInstruction(instruction, 1), Color)) { Console.WriteLine("This Position is threatened"); } else { Console.WriteLine("This Position is not threatened"); } Play(board); break; case "exit": Environment.Exit(0); break; default: Play(board); break; } }
internal List <PiecePosition> GetPossiblePiecePositionsWithoutRoque(PiecePosition position, Board board) { return(new List <PiecePosition> { new PiecePosition((char)(position.Column - 1), position.Line - 1), new PiecePosition((char)(position.Column - 1), position.Line), new PiecePosition((char)(position.Column - 1), position.Line + 1), new PiecePosition(position.Column, position.Line + 1), new PiecePosition(position.Column, position.Line - 1), new PiecePosition((char)(position.Column + 1), position.Line - 1), new PiecePosition((char)(position.Column + 1), position.Line), new PiecePosition((char)(position.Column + 1), position.Line + 1) } .Where(x => IsInBoard(x) && !IsOccupiedBySameColorPiece(board, x) && !board.IsPositionThreatened(x, Color)) .ToList()); }