Exemple #1
0
        public void TestMovePieceLegal()
        {
            var states = new State();

            PieceMove.MovePieceLegal(states, 7, 7, 4, 7);//user
            Debug.WriteLine(states.ToString());

            states = (AlphaBetaSearch.DoSearch(states, 1));
            Debug.WriteLine(states.ToString());

            PieceMove.MovePieceLegal(states, 0, 9, 1, 9);//user
            Debug.WriteLine(states.ToString());

            Assert.AreEqual(30, states.GetPieceList().Count);

            var piece = PieceFactory.GetPiece(23, 1, 9);

            Assert.AreEqual(typeof(Rook), piece.GetType());
            Assert.AreEqual("R", piece.ToString());

            Assert.AreEqual("R", states.GetPieceList()[82].ToString());
        }
Exemple #2
0
        private Move.MoveStatus HandleUserMove(State state, int fromX, int fromY, int toX, int toY)
        {
            var move = Move.MoveStatus.NoError;

            var fromK = Utility.GetOneDimention(fromX, fromY);
            var piece = CurrentState.GetPieceList().Get(fromK);

            if (piece.GetSide() == State.EmptySpace)
            {
                move = Move.MoveStatus.WrongPiece;
            }
            else if (piece.GetSide() != State.UserTurn)
            {
                move = Move.MoveStatus.WrongPiece;
            }
            else if (!PieceMove.MovePieceLegal(state, fromX, fromY, toX, toY))
            {
                move = Move.MoveStatus.Illegal;
            }
            PieceMove.MovePiece(state, fromX, fromY, toX, toY);
            return(move);
        }