Ejemplo n.º 1
0
        public static void Main()
        {
            // mozna sobie cos posprawdzac
            Console.WriteLine("Checkers");
            int[,] array = { { 2, 0, 2, 0, 2, 0, 2, 0 },
                             { 0, 2, 0, 2, 0, 2, 0, 2 },
                             { 2, 0, 2, 0, 2, 0, 2, 0 },
                             { 0, 0, 0, 0, 0, 0, 0, 0 },
                             { 0, 0, 0, 0, 0, 0, 0, 0 },
                             { 1, 0, 1, 0, 1, 0, 1, 0 },
                             { 0, 1, 0, 1, 0, 1, 0, 1 },
                             { 1, 0, 1, 0, 1, 0, 1, 0 }, };
            var myBoard  = new CheckerBoard();
            var myPlayer = new Player(Color.BLACK, myBoard);

            if (myBoard[2, 2] == null)
            {
                Console.WriteLine("NULL REFERENCE");
            }
            else
            {
                Console.WriteLine("IsCorrectPiece: " + myPlayer.IsCorrectPiece(myBoard[2, 2]));
            }
            myBoard.DrawBoard(myPlayer);

            Console.WriteLine("CanAttack: " + myBoard[4, 2].CanAttack(myBoard));
            Position dest;
            Piece    myPiece;

            myPlayer.Input(out myPiece, out dest, myBoard);
            myPiece.Move(myBoard, dest);
            myBoard.DrawBoard(myPlayer);
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public void Input(out Piece piece, out Position destination, CheckerBoard board)
        {
            board.DrawBoard(null);
            piece       = null;
            destination = new Position(-1, -1);
            bool attackPossible = IsPossibleAttack(board);

            if (pieces.Count == 0)
            {
                return;
            }
            while (true)
            {
                Console.WriteLine("Select piece !!!");
                piece = SelectPiece(board);
                Console.WriteLine("Select destination !!!");
                destination = SelectDestination(board);

                if (attackPossible)
                {
                    if (piece.IsCorrectDestination(true, destination, board))
                    {
                        break;
                    }
                    Console.WriteLine("You have to atack !!!");
                }
                else
                {
                    if (piece.IsCorrectDestination(false, destination, board))
                    {
                        break;
                    }
                    Console.WriteLine("Can't move your piece to this position !!!");
                }
            }
            //zwraca pionek
            //i poprawny cel w sensie ze jest puste pole
        }