public void _09_is_at_X_equals_3_and_Y_equals_3_gets_placed_into_check_by_white_bishop_and_is_in_check() { _chessBoard.Add(_whiteKing, 3, 3); _chessBoard.Add(_blackBishop, 7, 1); _blackBishop.Move(6, 0); Assert.That(_whiteKing.IsInCheck); }
public void _02_making_a_legal_move_by_placing_the_black_bishop_on_X_equals_2_and_Y_eqauls_7_and_moving_to_X_equals_7_and_Y_eqauls_2_should_move_the_bishop() { _chessBoard.Add(_blackBishop, 2, 7); _blackBishop.Move(7, 2); Assert.That(_blackBishop.XCoordinate, Is.EqualTo(7)); Assert.That(_blackBishop.YCoordinate, Is.EqualTo(2)); Assert.That(_chessBoard.IsPieceAt(7, 2, _blackBishop), Is.True); }
public void DescribeSimpleMovements() { var bishop = new Bishop(Player.Black, "8h"); string moveDescription = bishop.Move("6f"); Assert.Equal("B8h-6f", moveDescription); }
public void Move_InvalidPosition_ReturnsStartingPosition(int columnPosition, int rowPosition) { IChessPiece bishop = new Bishop(0, 4, 4); bishop.Move(columnPosition, rowPosition); Assert.Equal(4, bishop.Position.ColumnPosition); Assert.Equal(4, bishop.Position.RowPosition); }
public void Move_ValidPosition_ReturnsNewPosition(int columnPosition, int rowPosition) { IChessPiece bishop = new Bishop(0, 4, 4); bishop.Move(columnPosition, rowPosition); Assert.Equal(bishop.Position.ColumnPosition, columnPosition); Assert.Equal(bishop.Position.RowPosition, rowPosition); }
public void _06_and_is_captured_by_a_white_bishop() { _chessBoard.Add(_blackQueen, 3, 7); _chessBoard.Add(_whiteBishop, 0, 4); _whiteBishop.Move(3, 7); Assert.That(_chessBoard.CapturedBlackPieces.Contains(_blackQueen)); Assert.That(_chessBoard.IsPieceAt(3, 7, _whiteBishop)); Assert.That(_whiteBishop.XCoordinate, Is.EqualTo(3)); Assert.That(_whiteBishop.YCoordinate, Is.EqualTo(7)); }
static void Main(string[] args) { Rook r = new Rook('a', 1); Console.WriteLine("Rook on a1"); Console.WriteLine("Move {0}{1} - {2}", 'b', 4, r.Move('b', 4)); Console.WriteLine("Move {0}{1} - {2}", 'f', 2, r.Move('f', 2)); Console.WriteLine("Move {0}{1} - {2}", 'b', 4, r.Move('c', 3)); Console.WriteLine("Move {0}{1} - {2}", 'a', 8, r.Move('a', 8)); Console.WriteLine("Move {0}{1} - {2}", 'b', 8, r.Move('b', 8)); Console.WriteLine("Move {0}{1} - {2}", 'b', 0, r.Move('b', 0)); Knight k = new Knight('d', 4); Console.WriteLine("Knight on d4"); Console.WriteLine("Move {0}{1} - {2}", 'e', 6, k.Move('e', 6)); Console.WriteLine("Move {0}{1} - {2}", 'f', 5, k.Move('f', 5)); Console.WriteLine("Move {0}{1} - {2}", 'b', 3, k.Move('b', 3)); Console.WriteLine("Move {0}{1} - {2}", 'b', 5, k.Move('b', 5)); Console.WriteLine("Move {0}{1} - {2}", 'c', 2, k.Move('c', 2)); Console.WriteLine("Move {0}{1} - {2}", 'b', 0, k.Move('b', 0)); Bishop b = new Bishop('d', 4); Console.WriteLine("Bishop on d4"); Console.WriteLine("Move {0}{1} - {2}", 'c', 3, b.Move('c', 3)); Console.WriteLine("Move {0}{1} - {2}", 'a', 1, b.Move('a', 1)); Console.WriteLine("Move {0}{1} - {2}", 'b', 3, b.Move('b', 3)); Console.WriteLine("Move {0}{1} - {2}", 'b', 5, b.Move('b', 5)); Console.WriteLine("Move {0}{1} - {2}", 'c', 2, b.Move('c', 2)); Console.WriteLine("Move {0}{1} - {2}", 'a', 8, b.Move('a', 8)); Queen q = new Queen('d', 4); Console.WriteLine("Queen on d4"); Console.WriteLine("Move {0}{1} - {2}", 'c', 3, q.Move('c', 3)); Console.WriteLine("Move {0}{1} - {2}", 'a', 1, q.Move('a', 1)); Console.WriteLine("Move {0}{1} - {2}", 'b', 3, q.Move('b', 3)); Console.WriteLine("Move {0}{1} - {2}", 'b', 5, q.Move('b', 5)); Console.WriteLine("Move {0}{1} - {2}", 'c', 2, q.Move('c', 2)); Console.WriteLine("Move {0}{1} - {2}", 'd', 8, q.Move('d', 8)); King kg = new King('h', 1); Console.WriteLine("King on h1"); Console.WriteLine("Move {0}{1} - {2}", 'g', 2, kg.Move('g', 2)); Console.WriteLine("Move {0}{1} - {2}", 'g', 1, kg.Move('g', 1)); Console.WriteLine("Move {0}{1} - {2}", 'c', 4, kg.Move('c', 4)); Console.WriteLine("Move {0}{1} - {2}", 'd', 5, kg.Move('d', 5)); Console.WriteLine("Move {0}{1} - {2}", 'd', 3, kg.Move('d', 3)); Console.WriteLine("Move {0}{1} - {2}", 'e', 5, kg.Move('e', 5)); Console.WriteLine("Move {0}{1} - {2}", 'e', 4, kg.Move('e', 4)); Console.WriteLine("Move {0}{1} - {2}", 'e', 3, kg.Move('e', 3)); }
public void BishopIsMoved() { var bishop = new Bishop(2, 2, PieceColor.White); var board = new Board(); Board.Occupy(board[2, 2], bishop); Assert.IsTrue(bishop.Move(3, 3, board, out _, false)); Assert.IsFalse(bishop.Move(7, 7, board, out _, false)); Assert.IsTrue(bishop.Move(1, 5, board, out _, false)); Assert.IsTrue(bishop.Move(2, 4, board, out _, false)); Assert.IsTrue(bishop.Move(0, 2, board, out _, false)); Assert.IsFalse(bishop.Move(1, 1, board, out _, false)); Assert.IsFalse(bishop.Move(0, 1, board, out _, false)); Assert.IsFalse(bishop.Move(7, 2, board, out _, false)); Assert.IsFalse(bishop.Move(0, 5, board, out _, false)); Assert.IsTrue(board[0, 2].OccupiedBy.Color == PieceColor.White); Assert.IsNull(board[2, 2].OccupiedBy); }
static void Main() { string figure = Console.ReadLine(); int x = Convert.ToInt32(Console.ReadLine()); int y = Convert.ToInt32(Console.ReadLine()); int x1 = Convert.ToInt32(Console.ReadLine()); int y1 = Convert.ToInt32(Console.ReadLine()); switch (figure) { case "K": King king = new King(x, y); Console.WriteLine($"King: {king.Move(x1, y1)}"); break; case "Q": Queen queen = new Queen(x, y); Console.WriteLine($"Queen: {queen.Move(x1, y1)}"); break; case "B": Bishop bishop = new Bishop(x, y); Console.WriteLine($"Bishop: {bishop.Move(x1, y1)}"); break; case "N": Knight knight = new Knight(x, y); Console.WriteLine($"Knight: {knight.Move(x1, y1)}"); break; case "R": Rook rook = new Rook(x, y); Console.WriteLine($"Rook: {rook.Move(x1, y1)}"); break; default: Console.WriteLine("Unknown piece code. Try again."); break; } }
static void Main(string[] args) { string figure = Console.ReadLine(); int x1 = int.Parse(Console.ReadLine()); int y1 = int.Parse(Console.ReadLine()); int x2 = int.Parse(Console.ReadLine()); int y2 = int.Parse(Console.ReadLine()); Figure myFigure; switch (figure) { case "K": myFigure = new King(x1, y1); break; case "N": myFigure = new Knight(x1, y1); break; case "Q": myFigure = new Queen(x1, y1); break; case "R": myFigure = new Rook(x1, y1); break; case "B": myFigure = new Bishop(x1, y1); break; default: return; } Console.WriteLine(myFigure.Move(x2, y2) ? "Yes" : "No"); }
public bool CanMove(string move) { //pt ce piesa se aplica mutarea var startX = Int32.Parse(move[1].ToString()) - 1; //Console.WriteLine("startx board: " + startX); var startY = move[0] - 'a'; //Console.WriteLine("starty board: " + startY); var endY = move[3] - 'a'; //Console.WriteLine("Endy board: " + endY); var endX = Int32.Parse(move[4].ToString()) - 1; //Console.WriteLine("Endx board: " + endX); if (TablaSah[startX, startY] == null) { //Console.WriteLine("Nu exista piesa pe aceasta pozitie"); return(false); } else { if (TablaSah[startX, startY].Name == "K") { Piece king = new King(); return(king.Move(TablaSah, move)); } if (TablaSah[startX, startY].Name == "Q") { Piece queen = new Queen(); if (queen.Move(TablaSah, move) == true && queen.CheckIfMove(TablaSah, move) == false) { return(true); } else { return(false); } } if (TablaSah[startX, startY].Name == "B") { Piece bishop = new Bishop(); if (bishop.Move(TablaSah, move) == true && bishop.CheckIfMove(TablaSah, move) == false) { return(true); } else { return(false); } } if (TablaSah[startX, startY].Name == "N") { Piece knight = new Knight(); if (knight.Move(TablaSah, move) == true && knight.CheckIfMove(TablaSah, move) == false) { return(true); } else { return(false); } } if (TablaSah[startX, startY].Name == "P") { Piece pawn = new Pawn(); if (pawn.Move(TablaSah, move) == true && pawn.CheckIfMove(TablaSah, move) == false) { return(true); } else { return(false); } } if (TablaSah[startX, startY].Name == "R") { Piece rook = new Rook(); if (rook.Move(TablaSah, move) == true && rook.CheckIfMove(TablaSah, move) == false) { return(true); } else { return(false); } } } return(false); }
public void Bishop_WhenMoveNonDiagonally_ShouldThrowInvalidMoveExcetion(char file, char rank) { mockNewSquare.Setup(s => s.Position).Returns((file, rank)); Assert.Throws <InvalidMoveException>(() => bishop.Move(mockNewSquare.Object)); }
public bool TestMoveBishop(string fromPostiton, string toPosition, bool isWhite) { var bishop = new Bishop(isWhite); return(bishop.Move(fromPostiton, toPosition, isWhite)); }