Ejemplo n.º 1
0
        public void Test_FirstMoveDoneHandler_ReturnMovesThatAllowsToBeat()
        {
            BoardIndex e3    = BoardIndex.Parse("e3");
            BoardIndex d4    = BoardIndex.Parse("d4");
            BoardIndex c5    = BoardIndex.Parse("c5");
            BoardIndex b6    = BoardIndex.Parse("b6");
            BoardIndex a7    = BoardIndex.Parse("a7");
            Checker    white = new Checker(PlayerType.White)
            {
                IsQueen = false
            };
            Checker black1 = new Checker(PlayerType.Black)
            {
                IsQueen = false
            };

            board[e3.Row, e3.Col] = white;
            board[d4.Row, d4.Col] = black1;
            board[b6.Row, b6.Col] = black1;
            FirstMoveDoneHandler firstMoveDoneHandler = new FirstMoveDoneHandler(board);
            var moves = firstMoveDoneHandler.GetMoves(c5, new List <BoardIndex> {
                e3, c5
            });

            Assert.AreEqual(new List <BoardIndex>()
            {
                a7
            }, moves);
        }
Ejemplo n.º 2
0
            public List <BoardIndex> GetPossibleMoves(BoardIndex begin)
            {
                FirstMoveDoneHandler firstMoveDoneHandler = new FirstMoveDoneHandler(board);
                CannotBeatHandler    cannotBeatHandler    = new CannotBeatHandler(board);
                BeatHandler          beatHandler          = new BeatHandler(board);
                MoveHandler          moveHandler          = new MoveHandler(board);

                firstMoveDoneHandler.SetNext(cannotBeatHandler).SetNext(beatHandler).SetNext(moveHandler);
                return(firstMoveDoneHandler.GetMoves(begin, new List <BoardIndex>(builtMoves)));
            }
Ejemplo n.º 3
0
        public void Test_FirstMoveDoneHandler_ReturnEmptyMoves_When_CannotBeat_AfterMove()
        {
            BoardIndex e3    = BoardIndex.Parse("e3");
            BoardIndex d4    = BoardIndex.Parse("d4");
            BoardIndex c5    = BoardIndex.Parse("c5");
            BoardIndex b6    = BoardIndex.Parse("b6");
            Checker    white = new Checker(PlayerType.White)
            {
                IsQueen = false
            };
            Checker black = new Checker(PlayerType.Black)
            {
                IsQueen = false
            };

            board[e3.Row, e3.Col] = white;
            board[b6.Row, b6.Col] = black;
            FirstMoveDoneHandler firstMoveDoneHandler = new FirstMoveDoneHandler(board);
            var moves = firstMoveDoneHandler.GetMoves(c5, new List <BoardIndex> {
                e3, d4
            });

            Assert.AreEqual(new List <BoardIndex>(), moves);
        }