Example #1
0
        private void setNewGame()
        {
            try
            {
                objBetterHandPlayer = null;
                lblYourRanking.ResetText();
                lblComRanking.ResetText();

                pnlYou.Controls.Clear();
                pnlCom.Controls.Clear();


                objPokerGame = new PokerGame();

                objPokerGame.BettingDone         += Player_BettingDone;
                objPokerGame.FoldDone            += objPokerGame_FoldDone;
                objPokerGame.BettingTurnFinished += objPokerGame_BettingTurnFinished;
                objPokerGame.GameEnd             += objPokerGame_GameEnd;
                objPokerGame.PuAnteFailed        += objPokerGame_PuAnteFailed;

                objPlayerYou.NoMoreMoney += Player_NoMoreMoney;
                objPlayerCom.NoMoreMoney += Player_NoMoreMoney;

                objPokerGame.AddPlayer(objPlayerYou);
                objPokerGame.AddPlayer(objPlayerCom);

                ShowPlayerImages();
                SetControls(false);

                foreach (Player player in objPokerGame.Players)
                {
                    objPokerGame.PutAnte(player);
                }

                foreach (Player player in objPokerGame.Players)
                {
                    Card theCard = objPokerGame.Deck.DrawOneCard();
                    theCard.ChangeStatus(Status.FaceDown);
                    player.Hand.AddCard(theCard);
                }
                ShowCard(pnlYou, objPlayerYou.Hand, objPlayerYou.Hand.Count - 1);
                ShowCard(pnlCom, objPlayerCom.Hand, objPlayerCom.Hand.Count - 1);

                DrawACardToEachPlayers();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }