示例#1
0
 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());
 }
示例#2
0
        public void ShouldMove(Position newPosition)
        {
            var board = BoardBuilder.New().Build();

            board.ClearBoard();
            var rook = RookBuilder.New().WithColor(EColor.White).WithPosition(new Position(EColumn.D, ELine.Four)).WithBoard(board).Build();

            board.AddPiece(rook);
            var moved = rook.Move(newPosition);

            Assert.True(moved && rook.Position.Equals(newPosition) && rook.QuantityMove > 0);
        }
示例#3
0
        public void ShouldNotMoveWithPiecesOnBoard(Position positionPieceToAddBoard, EColor colorPieceToAddBoard, Position newPosition)
        {
            var board = BoardBuilder.New().Build();

            board.ClearBoard();
            var pieceToAddBoard = RookBuilder.New().WithPosition(positionPieceToAddBoard).WithColor(colorPieceToAddBoard).WithBoard(board).Build();

            board.AddPiece(pieceToAddBoard);
            var queen          = QueenBuilder.New().WithBoard(board).Build();
            var actualPosition = queen.Position;
            var notMoved       = !queen.Move(newPosition);

            Assert.True(notMoved && queen.Position.Equals(actualPosition) && queen.QuantityMove == 0);
        }
示例#4
0
        public void ShouldNotMoveWithPiecesOnBoard(Position positionPieceToAddBoard, EColor colorPieceToAddBoard, Position newPosition)
        {
            var actualPosition = new Position(EColumn.D, ELine.Four);
            var board          = BoardBuilder.New().Build();

            board.ClearBoard();
            var pieceToAddBoard = RookBuilder.New().WithPosition(positionPieceToAddBoard).WithColor(colorPieceToAddBoard).WithBoard(board).Build();

            board.AddPiece(pieceToAddBoard);
            var rook     = RookBuilder.New().WithColor(EColor.White).WithPosition(actualPosition).WithBoard(board).Build();
            var notMoved = !rook.Move(newPosition);

            Assert.True(notMoved && rook.Position.Equals(actualPosition) && rook.QuantityMove == 0);
        }
示例#5
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));
        }
示例#6
0
        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));
        }