Beispiel #1
0
        static void Main(string[] args)
        {
            DisplayUtilities.Intro();

            Player player1 = new Player();

            player1.getBasicInfo();

            bool   isFirst = player1.gameColor == GameColor.White;
            Player player2 = new Player();

            player2.getBasicInfo(isFirst ? GameColor.Black : GameColor.White);

            List <Player> players = new List <Player>();

            if (player1.gameColor == GameColor.White)
            {
                players.Add(player1);
                players.Add(player2);
            }
            else
            {
                players.Add(player2);
                players.Add(player1);
            }

            ChessGame game = new ChessGame(players);

            game.Start();
        }
Beispiel #2
0
        public void Start()
        {
            DisplayUtilities.Intro();

            this.gameState = GameState.Active;
            while (this.gameState == GameState.Active)
            {
                DisplayUtilities.PrintChessBoard(chessBoard);
                DisplayUtilities.PromptPlayerMove(currentPlayer);

                string command = Console.ReadLine();
                if (command == "q")
                {
                    gameState = GameState.Ended;
                    break;
                }
                var locations  = command.Split(new char[] { ' ' });
                var moveResult = this.Move(currentPlayer, new Location(locations[0]), new Location(locations[2]));
                if (moveResult != MoveResult.Invalid)
                {
                    UpdateCurrentPlayer();
                }
                else
                {
                    Console.WriteLine($"Invalid Move by {currentPlayer.gameName}. Please retry.");
                }
            }

            Console.ReadKey();
        }