Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // Creating a new chessboard object belonging to the Chessboard class.
            Chessboard chessboard = new Chessboard();

            // Initialization of the chessboard drawing chessboard and loading pieces for both teams.
            chessboard.Init();

            /* Verify that game is still valid, making sure that none of the two teams has made checkmates against the opponent. */
            while (chessboard.CanIDoAnotherTurn)
            {
                if (!chessboard.CheckLastMoveColor)
                {
                    // Asking the user to make his move by entering valid coordinates.
                    do
                    {
                        UserMessage.WhatPieceYouWantMove(true);
                    } while (!chessboard.GetMoveCoordinates(true));
                }
                else
                {
                    do
                    {
                        UserMessage.WhatPieceYouWantMove(false);
                    } while (!chessboard.GetMoveCoordinates(false));
                }
            }

            // In the event that a user has made checkmates against the opponent, communicates the end of the game and the winner.
            UserMessage.UserWins(chessboard.GetCheckMate(false));
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void Init()
        {
            board = new Chessboard(this);
            board.Init();

            logger = new MemoryLogger();

            white = new Player("WEISS", "white", new Timer(this.view.timer_lbl_1));
            black = new Player("SCHWARZ", "black", new Timer(this.view.timer_lbl_2));
            white.timer.Start();

            ShowInfo("");
        }