Esempio n. 1
0
        static void Main()
        {
            Console.WriteLine("==-== BlackJack ==-==");
            Console.WriteLine();

            uint playerCount       = GetPlayerCount();
            bool humanParticipates = ConsoleInteractions.Confirm("Will you particiate in game? [y/n]: ");

            var players = new List <AbstractPlayer>();

            uint nonHumanplayers;

            if (humanParticipates)
            {
                players.Add(new HumanPlayer(InitialMoney));
                nonHumanplayers = playerCount - 1;
            }

            else
            {
                nonHumanplayers = playerCount;
            }

            var random = new Random();

            for (int i = 0; i < nonHumanplayers; i++)
            {
                // Can possibly support more bots
                switch (random.Next(1, 3))
                {
                case 1:
                    int number = players.OfType <SameAsDealerBotPlayer>().Count();
                    players.Add(new SameAsDealerBotPlayer(InitialMoney, $"Same-as-dealer bot{(number == 0 ? "" : $" #{number + 1}")}"));
                    break;
Esempio n. 2
0
        static void PlayGame()
        {
            Console.WriteLine("==-== BlackJack ==-==");
            Console.WriteLine();

            uint playerCount       = GetPlayerCount();
            bool humanParticipates = ConsoleInteractions.Confirm("Will you particiate in game? [y/n]: ");

            var players = new List <AbstractPlayer>();

            uint nonHumanplayers;

            if (humanParticipates)
            {
                var humanPlayer = Container.Resolve <AbstractPlayer>("HumanPlayer");
                players.Add(humanPlayer);
                nonHumanplayers = playerCount - 1;
            }

            else
            {
                nonHumanplayers = playerCount;
            }

            var random = new Random();

            for (int i = 0; i < nonHumanplayers; i++)
            {
                int            count;
                string         name;
                AbstractPlayer player;
                // Can possibly support more bots
                switch (random.Next(1, 3))
                {
                case 1:
                    count = players.OfType <SameAsDealerBotPlayer>().Count();
                    name  = $"Same-as-dealer bot{(count == 0 ? "" : $" #{count + 1}")}";
                    Container.RegisterInstance("BotName", name);
                    player = Container.Resolve <AbstractPlayer>("SameAsDealerBotPlayer");
                    players.Add(player);
                    break;