private void OrganizePieces() { Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.A, ELine.Two)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.B, ELine.Two)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.C, ELine.Two)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.D, ELine.Two)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.E, ELine.Two)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.F, ELine.Two)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.G, ELine.Two)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.H, ELine.Two)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(RookBuilder.New().WithPosition(new Position(EColumn.A, ELine.One)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(KnightBuilder.New().WithPosition(new Position(EColumn.B, ELine.One)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(BishopBuilder.New().WithPosition(new Position(EColumn.C, ELine.One)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(QueenBuilder.New().WithPosition(new Position(EColumn.D, ELine.One)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(KingBuilder.New().WithPosition(new Position(EColumn.E, ELine.One)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(BishopBuilder.New().WithPosition(new Position(EColumn.F, ELine.One)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(KnightBuilder.New().WithPosition(new Position(EColumn.G, ELine.One)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(RookBuilder.New().WithPosition(new Position(EColumn.H, ELine.One)).WithColor(EColor.White).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.A, ELine.Seven)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.B, ELine.Seven)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.C, ELine.Seven)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.D, ELine.Seven)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.E, ELine.Seven)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.F, ELine.Seven)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.G, ELine.Seven)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(PawnBuilder.New().WithGameplay(this).WithPosition(new Position(EColumn.H, ELine.Seven)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(RookBuilder.New().WithPosition(new Position(EColumn.A, ELine.Eight)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(KnightBuilder.New().WithPosition(new Position(EColumn.B, ELine.Eight)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(BishopBuilder.New().WithPosition(new Position(EColumn.C, ELine.Eight)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(QueenBuilder.New().WithPosition(new Position(EColumn.D, ELine.Eight)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(KingBuilder.New().WithPosition(new Position(EColumn.E, ELine.Eight)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(BishopBuilder.New().WithPosition(new Position(EColumn.F, ELine.Eight)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(KnightBuilder.New().WithPosition(new Position(EColumn.G, ELine.Eight)).WithColor(EColor.Black).WithBoard(Board).Build()); Board.AddPiece(RookBuilder.New().WithPosition(new Position(EColumn.H, ELine.Eight)).WithColor(EColor.Black).WithBoard(Board).Build()); }
public void ShouldMove(Position newPosition) { var board = BoardBuilder.New().Build(); board.ClearBoard(); var king = KingBuilder.New().WithBoard(board).Build(); board.AddPiece(king); var moved = king.Move(newPosition); Assert.True(moved && king.Position.Equals(newPosition) && king.QuantityMove > 0); }
public void ShouldNotMove(Position newPosition) { var board = BoardBuilder.New().Build(); board.ClearBoard(); var king = KingBuilder.New().WithBoard(board).Build(); var actualPosition = king.Position; board.AddPiece(king); var notMoved = !king.Move(newPosition); Assert.True(notMoved && king.Position.Equals(actualPosition) && king.QuantityMove == 0); }
public void ShouldMoveWithPiecesOnBoard(Position positionPieceToAddBoard, EColor colorPieceToAddBoard, Position newPosition) { var board = BoardBuilder.New().Build(); board.ClearBoard(); var pieceToAddBoard = KingBuilder.New().WithPosition(positionPieceToAddBoard).WithColor(colorPieceToAddBoard).WithBoard(board).Build(); board.AddPiece(pieceToAddBoard); var king = KingBuilder.New().WithBoard(board).Build(); var moved = king.Move(newPosition); Assert.True(moved && king.Position.Equals(newPosition) && king.QuantityMove > 0); }
public void ShouldCastling(Position posFirstRook, Position posLastRook, EColor color, Position newPosition, Position initialPosKing, Position expectedPosFirstRook, Position expectedPosLastRook) { var board = BoardBuilder.New().Build(); board.ClearBoard(); var king = KingBuilder.New().WithPosition(initialPosKing).WithColor(color).WithBoard(board).Build(); board.AddPiece(king); var firstRook = RookBuilder.New().WithPosition(posFirstRook).WithColor(color).WithBoard(board).Build(); board.AddPiece(firstRook); var lastRook = RookBuilder.New().WithPosition(posLastRook).WithColor(color).WithBoard(board).Build(); board.AddPiece(lastRook); var moved = king.Move(newPosition); Assert.True(moved && king.Position.Equals(newPosition) && firstRook.Position.Equals(expectedPosFirstRook) && lastRook.Position.Equals(expectedPosLastRook)); }
public void ShouldNotCastlingWhenHasPieceOnWay(Position newPosition, Position positionPieceOnWay, EColor colorPieceOnWay) { var board = BoardBuilder.New().Build(); board.ClearBoard(); var pieceOnWay = KingBuilder.New().WithPosition(positionPieceOnWay).WithColor(colorPieceOnWay).Build(); board.AddPiece(pieceOnWay); var iniPosKing = new Position(EColumn.E, ELine.One); var king = KingBuilder.New().WithPosition(iniPosKing).WithColor(EColor.White).Build(); board.AddPiece(king); var iniPosFirstRook = new Position(EColumn.A, ELine.One); var firstRook = RookBuilder.New().WithPosition(iniPosFirstRook).WithColor(EColor.White).Build(); board.AddPiece(firstRook); var iniPosLastRook = new Position(EColumn.H, ELine.One); var lastRook = RookBuilder.New().WithPosition(iniPosLastRook).WithColor(EColor.White).Build(); var notMoved = !king.Move(newPosition); Assert.True(notMoved && king.Position.Equals(iniPosKing) && firstRook.Position.Equals(iniPosFirstRook) && lastRook.Position.Equals(iniPosLastRook)); }