Beispiel #1
0
        private void HitStayBust(ref Card[] Cards, ref int index,
            ref CardHand myHand, ref CardHand dealerHand, int maxPlayers,
            int mySeat, bool doubled)
        {
            int stayAt = System.Convert.ToInt32(txtStayAt.Text, 10);
            bool dealerTen = System.Convert.ToBoolean(chkDealerTen.Checked);
            bool agg456 = System.Convert.ToBoolean(chk456.Checked);

            for (int dealto = 0; dealto < maxPlayers + 1; dealto++)
            {
                if (dealto == mySeat)
                {
                    if (dealerTen && dealerHand.Showing == 10)
                    {
                        stayAt = 16;
                    }
                    else if (agg456 && (dealerHand.Showing == 4 ||
                        dealerHand.Showing == 5 ||
                        dealerHand.Showing == 6))
                    {
                        stayAt = 12;
                    }
                    else
                    {
                        stayAt = stayAt;//normal
                    }

                    //take some cards (or not)
                    while (myHand.Total < stayAt)
                    {
                        myHand.AddCard(Cards[index]);
                        Cards[index].Dealt = true;
                        CountCard(Cards[index].Value);
                        index++;
                        if (doubled)
                            break;//double-down only gets one card
                    }
                }
                else if (dealto == maxPlayers)//the Dealer
                {
                    while (dealerHand.Total < 17)
                    {
                        dealerHand.AddCard(Cards[index]);
                        Cards[index].Dealt = true;
                        CountCard(Cards[index].Value);
                        index++;
                    }
                }
                else
                {
                    Random rand = new Random();
                    int burn = rand.Next(0, 3);
                    for (int b = 0; b < burn; b++)
                    {
                        Cards[index].Dealt = true;
                        CountCard(Cards[index].Value);
                        index++;
                    }
                }

            }
        }