示例#1
0
        private static void StartServer()
        {
            var server = new Server();
            var board = new Board(new ComputerPlayer(), new NetworkPlayer(server));

            int c = 0;
            while (board.Players.Values.Any(i => !i.IsReady))
            {
                if (++c % 1000 == 0)
                    Console.WriteLine("Waiting...");
                System.Threading.Thread.Sleep(1);
            }

            board.Start();
        }
示例#2
0
        private static Player GetPlayer(PlayerType playerType, string config)
        {
            switch (playerType)
            {
                case PlayerType.Human: return new HumanPlayer();
                case PlayerType.Computer: return new ComputerPlayer((AILevel)Enum.Parse(typeof(AILevel), config));
                case PlayerType.Network:
                    ChessConnection cnn;
                    if (string.IsNullOrEmpty(config))
                        cnn = new Server();
                    else
                        cnn = new Client(System.Net.IPAddress.Parse(config));

                    return new NetworkPlayer(cnn);
            }

            throw new NotSupportedException(playerType.ToString());
        }