예제 #1
0
        public string GameResult(Croupie croupie, Player player)
        {
            if (player.Sum > BlackJackConst)
            {
                return(croupie.Name);
            }

            if (croupie.Sum <= BlackJackConst && player.Sum <= BlackJackConst && croupie.Sum > player.Sum)
            {
                return(croupie.Name);
            }

            if (croupie.Sum <= BlackJackConst && player.Sum <= BlackJackConst && croupie.Sum < player.Sum)
            {
                return(player.Name);
            }

            if (croupie.Sum <= BlackJackConst && player.Sum <= BlackJackConst && croupie.Sum == player.Sum)
            {
                return(null);
            }

            if (croupie.Sum > BlackJackConst && player.Sum <= BlackJackConst)
            {
                return(player.Name);
            }

            return(null);
        }
예제 #2
0
 public void CroupiePlay(Croupie croupie, Deck deck)
 {
     if (croupie.Sum < CroupieScoreConst)
     {
         Extradition(croupie.Hand, croupie.Name, deck);
         croupie.Sum = Sum(croupie.Hand);
         CroupiePlay(croupie, deck);
     }
 }
예제 #3
0
 public void Init(ref Deck deck, ref Player player, ref Croupie croupie)
 {
     deck.Generate();
     deck.Shuffle();
     player.Sum  = 0;
     croupie.Sum = 0;
     deck.DeckList.Clear();
     player.Hand.Clear();
     croupie.Hand.Clear();
 }
예제 #4
0
        public void GameMethod()
        {
            Player  pl = new Player();
            Croupie cr = new Croupie();
            int     way;
            bool    check = false;

            Init();

            pl.Extradition();

            while (true) //игрок
            {
                Console.Write("Pls, select an action: \n1 - Take a card\n2 - Stop\n>");
                way = Convert.ToInt32(Console.ReadLine());


                if (way == 1)
                {
                    pl.Extradition();
                }

                if (way == 2)
                {
                    pl.Result();
                    check = true;
                }

                if (check)
                {
                    break;
                }
            }

            while (true) //крупье
            {
                if (Croupie.Sum < 17)
                {
                    cr.Extradition();
                }

                if (Croupie.Sum > 17)
                {
                    cr.Result();
                    Console.Write("Croupie score: {0}\n\n", Croupie.Sum);
                    break;
                }
            }

            GameResult();
        }