Esempio n. 1
0
        public void ShouldKillWhitePawnToRightEnPassant()
        {
            var board    = BoardBuilder.New().Build();
            var gameplay = GameplayBuilder.New().WithBoard(board).Build();

            gameplay.StartGame();
            //Movimenta uma peça qualquer
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.A, ELine.Two)), new Position(EColumn.A, ELine.Four));
            //Movimenta o peão que irá comer
            var enemyPawn = gameplay.GetPieceFromPosition(new Position(EColumn.E, ELine.Seven));

            gameplay.PlayerMove(enemyPawn, new Position(EColumn.E, ELine.Five));
            //Movimenta uma peça qualquer
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.A, ELine.Four)), new Position(EColumn.A, ELine.Five));
            //Movimenta o peão que irá comer
            gameplay.PlayerMove(enemyPawn, new Position(EColumn.E, ELine.Four));
            //Movimenta o peão que será comido
            var pawn = gameplay.GetPieceFromPosition(new Position(EColumn.F, ELine.Two));

            gameplay.PlayerMove(pawn, new Position(EColumn.F, ELine.Four));
            //Faz o En Passant
            var posToKillEnemyPawn = new Position(EColumn.F, ELine.Three);
            var moved = gameplay.PlayerMove(enemyPawn, posToKillEnemyPawn);

            Assert.True(moved && enemyPawn.Position.Equals(posToKillEnemyPawn) && board.DeadPieces.Any(p => p == pawn));
        }
Esempio n. 2
0
        public void ShouldNoKillEnPassantWhenPawnMovedTwice()
        {
            var board    = BoardBuilder.New().Build();
            var gameplay = GameplayBuilder.New().WithBoard(board).Build();

            gameplay.StartGame();
            //Movimenta o peão que irá comer
            var enemyPawn = gameplay.GetPieceFromPosition(new Position(EColumn.D, ELine.Two));

            gameplay.PlayerMove(enemyPawn, new Position(EColumn.D, ELine.Four));
            //Movimenta uma peça qualquer
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.H, ELine.Seven)), new Position(EColumn.H, ELine.Five));
            //Movimenta o peão que irá comer
            gameplay.PlayerMove(enemyPawn, new Position(EColumn.D, ELine.Five));
            //Movimenta o peão que será comido
            var pawn = gameplay.GetPieceFromPosition(new Position(EColumn.E, ELine.Seven));

            gameplay.PlayerMove(pawn, new Position(EColumn.E, ELine.Six));
            //Movimenta uma peça qualquer
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.A, ELine.Two)), new Position(EColumn.A, ELine.Three));
            //Movimenta uma peça qualquer
            gameplay.PlayerMove(pawn, new Position(EColumn.E, ELine.Six));
            //Faz o En Passant
            var posBeforeEnPasasnt = enemyPawn.Position;
            var notMoved           = !gameplay.PlayerMove(enemyPawn, new Position(EColumn.E, ELine.Six));

            Assert.True(notMoved && enemyPawn.Position.Equals(posBeforeEnPasasnt) && !board.DeadPieces.Any(p => p == pawn));
        }
Esempio n. 3
0
        public void ShouldDefinePlayerOneToRound()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();
            Assert.Equal(gameplay.PlayerRound, gameplay.PlayerOne);
        }
Esempio n. 4
0
        public void ShouldNotMoveWhenGameIsNotStarted()
        {
            var gameplay    = GameplayBuilder.New().Build();
            var newPosition = new Position(EColumn.C, ELine.Four);
            var notMoved    = !gameplay.PlayerMove(null, newPosition);

            Assert.True(notMoved);
        }
Esempio n. 5
0
        public void ShouldIncrementRound()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            var pawn = gameplay.GetPieceFromPosition(new Position(EColumn.C, ELine.Two));

            gameplay.PlayerMove(pawn, new Position(EColumn.C, ELine.Four));

            Assert.True(gameplay.Round == 2);
        }
Esempio n. 6
0
        public void ShouldDefinePlayerTwoToRound()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            var pawn = gameplay.GetPieceFromPosition(new Position(EColumn.C, ELine.Two));

            gameplay.PlayerMove(pawn, new Position(EColumn.C, ELine.Four));

            Assert.Equal(gameplay.PlayerRound, gameplay.PlayerTwo);
        }
Esempio n. 7
0
        public void ShouldNotMoveWhenNewPositionIsInvalid()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            var pawn           = gameplay.GetPieceFromPosition(new Position(EColumn.E, ELine.Two));
            var actualPosition = pawn.Position;
            var notMoved       = !gameplay.PlayerMove(pawn, new Position(EColumn.E, ELine.Five));

            Assert.True(notMoved && pawn.Position.Equals(actualPosition) && gameplay.PlayerRound == gameplay.PlayerOne && gameplay.Round == 1);
        }
Esempio n. 8
0
        public void ShouldPlayerOneMakeHisMove()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            var pawn        = gameplay.GetPieceFromPosition(new Position(EColumn.C, ELine.Two));
            var newPosition = new Position(EColumn.C, ELine.Four);
            var moved       = gameplay.PlayerMove(pawn, newPosition);

            Assert.True(moved && pawn.Position.Equals(newPosition));
        }
Esempio n. 9
0
        public void ShouldPlayerOneNotMoveBlackPiece()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            var actualPosition = new Position(EColumn.C, ELine.Seven);
            var pawn           = gameplay.GetPieceFromPosition(actualPosition);
            var notMoved       = !gameplay.PlayerMove(pawn, new Position(EColumn.C, ELine.Six));

            Assert.True(notMoved && pawn.Position.Equals(actualPosition));
        }
Esempio n. 10
0
        public void ShouldBlackKingInCheck()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.E, ELine.Two)), new Position(EColumn.E, ELine.Four));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.D, ELine.Seven)), new Position(EColumn.D, ELine.Six));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.F, ELine.One)), new Position(EColumn.B, ELine.Five));
            var king = (King)gameplay.GetPieceFromPosition(new Position(EColumn.E, ELine.Eight));

            Assert.True(gameplay.IsCheck(king) && !gameplay.IsCheckmate(king));
        }
Esempio n. 11
0
        public void ShouldNotMoveWhenKingWillBeInCheck()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.E, ELine.Two)), new Position(EColumn.E, ELine.Four));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.A, ELine.Seven)), new Position(EColumn.A, ELine.Six));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.D, ELine.One)), new Position(EColumn.H, ELine.Five));
            var pawn           = gameplay.GetPieceFromPosition(new Position(EColumn.F, ELine.Seven));
            var actualPosition = pawn.Position;
            var notMoved       = !gameplay.PlayerMove(pawn, new Position(EColumn.F, ELine.Six));
            var king           = (King)gameplay.GetPieceFromPosition(new Position(EColumn.E, ELine.Eight));

            Assert.True(notMoved && !gameplay.IsCheck(king) && pawn.Position.Equals(actualPosition));
        }
Esempio n. 12
0
        public void ShouldPlayerTwoNotMoveWhitePiece()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            var pawn = gameplay.GetPieceFromPosition(new Position(EColumn.C, ELine.Two));

            gameplay.PlayerMove(pawn, new Position(EColumn.C, ELine.Three));

            var actualPosition = new Position(EColumn.G, ELine.One);
            var knight         = gameplay.GetPieceFromPosition(actualPosition);
            var notMoved       = !gameplay.PlayerMove(knight, new Position(EColumn.F, ELine.Three));

            Assert.True(notMoved && knight.Position.Equals(actualPosition));
        }
Esempio n. 13
0
        public void ShouldNotMoveWhenHasKingInCheckmate()
        {
            var gameplay = GameplayBuilder.New().Build();

            gameplay.StartGame();

            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.E, ELine.Two)), new Position(EColumn.E, ELine.Four));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.F, ELine.Seven)), new Position(EColumn.F, ELine.Six));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.F, ELine.One)), new Position(EColumn.C, ELine.Four));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.G, ELine.Eight)), new Position(EColumn.H, ELine.Six));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.D, ELine.One)), new Position(EColumn.H, ELine.Five));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.H, ELine.Six)), new Position(EColumn.F, ELine.Seven));
            gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.H, ELine.Five)), new Position(EColumn.F, ELine.Seven));
            var notMoved = !gameplay.PlayerMove(gameplay.GetPieceFromPosition(new Position(EColumn.A, ELine.Seven)), new Position(EColumn.A, ELine.Six));

            Assert.True(notMoved);
        }
Esempio n. 14
0
        public void ShouldGetNullWhenInstanceIsPawn()
        {
            var bishop   = new Bishop(new Position(EColumn.H, ELine.Seven), EColor.White, _board);
            var pawn     = new Pawn(new Position(EColumn.A, ELine.One), EColor.White, _board, GameplayBuilder.New().Build());
            var newPiece = Utils.GetBuildedPieceFromAnother(pawn, bishop.Position, pawn.Color, _board);

            Assert.Null(newPiece);
        }
Esempio n. 15
0
        public void ShouldGetNewInstanceOfAnotherPiece(Piece piece)
        {
            var pawn     = new Pawn(new Position(EColumn.H, ELine.Seven), EColor.White, _board, GameplayBuilder.New().Build());
            var newPiece = Utils.GetBuildedPieceFromAnother(piece, pawn.Position, piece.Color, _board);

            Assert.True(newPiece != null && newPiece.GetType() == piece.GetType() && newPiece != piece && newPiece.Position.Equals(pawn.Position) && newPiece.Color == piece.Color);
        }