Beispiel #1
0
 public void SplitHandCPU(Table table)
 {
     for (var hand = 0; hand <= PlayerHands.Count - 1; hand++)
     {
         if (PlayerHands[hand].IsPair && !PlayerHands[hand].IsSplit && PlayerBank > PlayerHands[hand].BetOnHand)
         {
             PlayerHands[hand].ShowHand(this);
             Console.WriteLine($"{PlayerName} Would you like to split this hand? Enter Y or N: ");
             if (PlayerHands[hand].Cards.ElementAt(0).Rank == Rank.Ace || PlayerHands[hand].Cards.ElementAt(0).Rank == Rank.Eight)
             {
                 Console.WriteLine("Y");
                 var splitHand = new Hand();
                 splitHand.SplitHandBet(this, PlayerHands[hand].BetOnHand);
                 splitHand.AddCard(PlayerHands[hand].Cards.ElementAt(1));
                 PlayerHands[hand].Cards.Remove(PlayerHands[hand].Cards.ElementAt(1));
                 splitHand.AddCard(table.Shoe.TakeCard());
                 PlayerHands.Add(splitHand);
                 PlayerHands[hand].Cards.Add(table.Shoe.TakeCard());
                 PlayerHands[hand].IsSplit = true;
                 break;
             }
             Console.WriteLine("N");
         }
     }
 }
Beispiel #2
0
 public void DealToPlayers()
 {
     Cards.BurnCard();
     foreach (Player p in Players)
     {
         Hand h = Cards.CreateHand();
         p.GiveHand(h);
         PlayerHands.Add(p.Name, h);
     }
 }
Beispiel #3
0
        public Hand AddPlayerHand(Player player)
        {
            var newHand = new Hand()
            {
                Player = player
            };

            PlayerHands.Add(newHand);
            return(newHand);
        }
Beispiel #4
0
        /// <summary>
        /// Split
        /// </summary>
        public static void Split()
        {
            PlayerHands.Add(new BlackjackHand(PlayerHands[0].Bet));

            PlayerFunds -= PlayerHands[0].Bet;

            PlayerHands[1].AddCard(PlayerHands[0].GetCard(0));
            PlayerHands[0].RemoveCardAt(0);

            PlayerHands[0].AddCard(_deck.DealOneCard());
            PlayerHands[1].AddCard(_deck.DealOneCard());
        }
Beispiel #5
0
        /// <summary>
        /// Draw from the deck with specified amount . Added only to the first hand
        /// </summary>
        /// <param name="deck"></param>
        /// <param name="amt"></param>
        public void Draw(IDeck deck, int amt)
        {
            for (var i = 0; i < amt; i++)
            {
                var drawnCard = deck.Deal();

                if (PlayerHands.Count == 0)
                {
                    var hand = new Hand();
                    PlayerHands.Add(hand);
                }

                PlayerHands[0].AddCard(deck.Deal());
            }
        }