Example #1
0
        // begin hand
        public void StartHand()
        {
            //declare objects and variables
            Deck cardDeck = new Deck();         // generate a new deck of cards
            pot = 0;                        // reset pot to $0

            Dealer.flopDeal = 0;

            // AI players ante up and reset values
            for (int x = 0; x < 4; x++)
            {
                pot = pot + ante;

                AIplayer[x].money = AIplayer[x].money - ante;
                /*
                AIplayer[x].aceHigh = false;
                AIplayer[x].bet = 0;
                AIplayer[x].betStatus = Player.betstats.none;
                AIplayer[x].handScore = 0;
                AIplayer[x].isRaising = false;
                AIplayer[x].raiseCount = 0;
                AIplayer[x].winHands = Player.winHand.none;
                AIplayer[x].winHandScore = 0;
                 */
            }

            pot = pot + ante;    //ante for main player
            mainPlayer.money = mainPlayer.money - ante;

            UpdateUI();

            // pick cards for main player
            for (int d = 0; d < 2; d++)
            {
                int n = 0;
                while (n == 0)
                {
                    int cardPick = random1.Next(0, 51);

                    if (!cardDeck.cards[cardPick].isPicked)
                    {
                        Card cardTemp = new Card();
                        cardTemp = cardDeck.cards[cardPick];
                        mainPlayer.playerHand[d] = cardTemp;
                        cardDeck.cards[cardPick].isPicked = true;
                        n++;
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            // pick cards for AI players
            for (int i = 0; i < 4; i++)
            {
                if (!AIplayer[i].isBust)
                {

                    for (int j = 0; j < 2; j++)
                    {
                        int n = 0;
                        while (n == 0)
                        {
                            int cardPick = random1.Next(0, 51);

                            if (!cardDeck.cards[cardPick].isPicked)
                            {
                                Card cardTemp = new Card();
                                cardTemp = cardDeck.cards[cardPick];
                                AIplayer[i].playerHand[j] = cardTemp;
                                cardDeck.cards[cardPick].isPicked = true;
                                n++;
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                }

                continue;
            }

            // pick cards for dealer
            for (int d = 0; d < 5; d++)
            {
                int n = 0;
                while (n == 0)
                {
                    int cardPick = random1.Next(0, 51);

                    if (!cardDeck.cards[cardPick].isPicked)
                    {
                        Card cardTemp = new Card();
                        cardTemp = cardDeck.cards[cardPick];
                        Dealer.dealerHand[d] = cardTemp;
                        cardDeck.cards[cardPick].isPicked = true;
                        n++;
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            currentBet = 0;
            //int playerNum = 0;
            betRound = 1;
            firstBet = true;

            PlayHand();
        }
Example #2
0
        // begin hand
        public void StartHand()
        {
            //declare objects and variables
            Deck cardDeck = new Deck();         // generate a new deck of cards
            pot = 0;                        // reset pot to $0

            Dealer.flopDeal = 0;

            // AI players ante up and reset values
            for (int x = 0; x < 4; x++)
            {
                if (!AIplayer[x].isBust)
                {
                    pot = pot + ante;

                    AIplayer[x].money = AIplayer[x].money - ante;

                    if (AIplayer[x].money < 0)
                    {
                        AIplayer[x].money = 0;
                        AIplayer[x].isBust = true;
                    }
                }

            }

            pot = pot + ante;    //ante for main player
            mainPlayer.money = mainPlayer.money - ante;

            if (mainPlayer.money < 0)
            {
                mainPlayer.money = 0;
                EndGame();
                return;
            }

            UpdateUI();

            // pick cards for main player
            for (int d = 0; d < 2; d++)
            {
                int n = 0;
                while (n == 0)
                {
                    int cardPick = random1.Next(0, 51);

                    if (!cardDeck.cards[cardPick].isPicked)
                    {
                        Card cardTemp = new Card();
                        cardTemp = cardDeck.cards[cardPick];
                        mainPlayer.playerHand[d] = cardTemp;
                        cardDeck.cards[cardPick].isPicked = true;
                        n++;
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            // pick cards for AI players
            for (int i = 0; i < 4; i++)
            {
                if (!AIplayer[i].isBust)
                {

                    for (int j = 0; j < 2; j++)
                    {
                        int n = 0;
                        while (n == 0)
                        {
                            int cardPick = random1.Next(0, 51);

                            if (!cardDeck.cards[cardPick].isPicked)
                            {
                                Card cardTemp = new Card();
                                cardTemp = cardDeck.cards[cardPick];
                                AIplayer[i].playerHand[j] = cardTemp;
                                cardDeck.cards[cardPick].isPicked = true;
                                n++;
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                }

                continue;
            }

            // pick cards for dealer
            for (int d = 0; d < 5; d++)
            {
                int n = 0;
                while (n == 0)
                {
                    int cardPick = random1.Next(0, 51);

                    if (!cardDeck.cards[cardPick].isPicked)
                    {
                        Card cardTemp = new Card();
                        cardTemp = cardDeck.cards[cardPick];
                        Dealer.dealerHand[d] = cardTemp;
                        cardDeck.cards[cardPick].isPicked = true;
                        n++;
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            currentBet = 0;
            betRound = 1;
            firstBet = true;
            callCount = 0;
            AIfoldCount = 0;
            finishedAIBetRound = false;
            finishedHand = false;
            nextBetRound = false;
            isChecked = false;
            isRaised = false;

            ResetAllPlayers();

            PlayHand();
        }