Esempio n. 1
0
        private static IPlayer CreatePlayer(int playerNumber, List <SupportedPlayer> supportedPlayers)
        {
            Console.WriteLine("\n" + "Select Player" + playerNumber + " type:");
            foreach (SupportedPlayer supportedPlayer in supportedPlayers)
            {
                if (supportedPlayer == SupportedPlayer.Null)
                {
                    continue;
                }
                Console.WriteLine((int)supportedPlayer + " - " + supportedPlayer.ToString());
            }

            int selectedPlayerType = -1;

            while (!Int32.TryParse(Console.ReadLine(), out selectedPlayerType) || selectedPlayerType < 0 || selectedPlayerType >= supportedPlayers.Count)
            {
                Console.WriteLine("Please, select an admissible value.");
            }

            string playerName = "";

            if (selectedPlayerType == (int)SupportedPlayer.HumanPlayer)
            {
                Console.WriteLine("What is your name?");
                playerName = Console.ReadLine();
            }

            return(Player.CreatePlayer((SupportedPlayer)selectedPlayerType, playerName));
        }
Esempio n. 2
0
 static void SetupPlayers()
 {
     Player1 = Player.CreatePlayer();
     Player2 = Player.CreatePlayer();
 }