Пример #1
0
 private void GiveCard(Croupier player, int countCard)
 {
     for (int i = 0; i < countCard; i++)
     {
         player.TakeCard(_deck.GetCard());
     }
 }
Пример #2
0
 private void InitRound(Croupier croupier, Player gamer)
 {
     PrintInfo.PrintScore(gamer.Win, gamer.Loss);
     GiveCard(gamer, 2);
     GiveCard(croupier, 1);
     ShowPlayersCards(croupier, gamer);
 }
Пример #3
0
        private int PlayerSpot(Croupier player)
        {
            int spot = 0;

            for (int i = 0; i < player.PlayerCards.Count; i++)
            {
                spot += player.PlayerCards[i].Point;
            }
            return(spot);
        }
Пример #4
0
        private void ShowPlayersCards(Croupier croupier, Player gamer)
        {
            PrintInfo.PrintOtherMes(TypeMessage.CardCroupier);
            PrintInfo.PrintCards(croupier.PlayerCards);
            PrintInfo.PrintSpot(PlayerSpot(croupier));

            PrintInfo.PrintOtherMes(TypeMessage.CardPlayer);
            PrintInfo.PrintCards(gamer.PlayerCards);
            PrintInfo.PrintSpot(PlayerSpot(gamer));
        }
Пример #5
0
        /// <summary>Ajoute le croupier au salon de jeu.</summary>
        /// <param name="croupier">Croupier à ajouter.</param>
        public void AjouterCroupier(Croupier croupier)
        {
            ControlParticipant ctrl = croupier.Control;

            ctrl.Location = new Point(12, 12);

            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(delegate { Controls.Add(ctrl); }));
            }
            else
            {
                Controls.Add(ctrl);
            }
        }
Пример #6
0
        public static void InitMenu(Deck deck, Game game, Croupier croupier, Player gamer)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            ConsoleKeyInfo cki;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("\t\t\t\t Меню");
                Console.WriteLine("\t\t\t F1  - Показать карты");
                Console.WriteLine("\t\t\t F2  - Тасовать карты");
                Console.WriteLine("\t\t\t F3  - Сбросить счет игры");
                Console.WriteLine("\t\t\t F4  - Начать раунд");
                Console.WriteLine("\t\t\t F10 - Выход");
                cki = WorkKey.GetPressKey();
                Console.Clear();
                if (WorkKey.CompareKey(cki, ConsoleKey.F1))
                {
                    ShowAllDeck(deck);
                }
                if (WorkKey.CompareKey(cki, ConsoleKey.F2))
                {
                    Shuffle(deck);
                    Console.WriteLine("Колода потасована");
                }
                if (WorkKey.CompareKey(cki, ConsoleKey.F3))
                {
                    ClearScore(game, gamer);
                    Console.WriteLine("Счет сброшен");
                }
                if (WorkKey.CompareKey(cki, ConsoleKey.F4))
                {
                    StartRound(deck, game);
                }
                if (WorkKey.CompareKey(cki, ConsoleKey.F10))
                {
                    break;
                }
                else
                {
                    Console.ReadKey();
                }
            }
        }
Пример #7
0
 public Game(Croupier croupier, Player gamer, Deck deck)
 {
     this._croupier = croupier;
     this._gamer    = gamer;
     this._deck     = deck;
 }
Пример #8
0
        public void Play(APlayer player, float betValue, int numOfBets, uint numOfDecks = 8)
        {
            if (numOfBets <= 0)
            {
                Console.WriteLine("The number of bets must be positive integer. It will be set to 1");
            }

            ShufflingMachine shufMachine = new ShufflingMachine(numOfBets, numOfDecks * 13);
            Croupier         croupier    = new Croupier();

            for (int i = 0; i < numOfBets; i++)
            {
                shufMachine.Shuffle();
                player.ResetScore();

                croupier.InitSetScore(shufMachine.GetBlackjackCardWeight());
                croupier.IncreaseScore(shufMachine.GetBlackjackCardWeight());

                if (croupier.IsBlackjack())
                {
                    player.Lose(betValue);

                    continue;
                }

                player.IncreaseScore(shufMachine.GetBlackjackCardWeight());
                player.IncreaseScore(shufMachine.GetBlackjackCardWeight());

                if (player.IsBlackjack())
                {
                    player.WinBlackjack(betValue);

                    continue;
                }

                while (player.DoesHit(croupier.VisibleCardWeight) && !player.IsBust())
                {
                    player.IncreaseScore(shufMachine.GetBlackjackCardWeight());
                }

                if (player.IsBust())
                {
                    player.Lose(betValue);

                    continue;
                }

                while (croupier.Score < 17)
                {
                    croupier.IncreaseScore(shufMachine.GetBlackjackCardWeight());
                }

                if (croupier.IsBust())
                {
                    player.WinCasual(betValue);

                    continue;
                }

                if (croupier.Score > player.Score)
                {
                    player.Lose(betValue);
                }
                else if (croupier.Score < player.Score)
                {
                    player.WinCasual(betValue);
                }
            }
        }