Deal() static private méthode

static private Deal ( ) : string
Résultat string
Exemple #1
0
    private IEnumerator PlayRound()
    {
        if (!blackjack.playerStand)
        {
            blackjack.Deal(blackjack.deck.Last(), blackjack.playerCard, blackjack.playerCards);
            yield return(new WaitForEndOfFrame());

            blackjack.CheckForEnd();
            if (blackjack.isResetEnabled)
            {
                btn.interactable = false;
                yield break;
            }
        }
        if (blackjack.canDealerHit)
        {
            yield return(new WaitForSeconds(1.5f));

            blackjack.Deal(blackjack.deck.Last(), blackjack.dealerCard, blackjack.dealerCards);
            yield return(new WaitForEndOfFrame());

            blackjack.CheckForEnd();
            if (blackjack.isResetEnabled)
            {
                btn.interactable = false;
            }
            else
            {
                btn.interactable = true;
            }
        }
    }
Exemple #2
0
 public void Play(Blackjack game)
 {
     while (Hand.Total <= MaxHit)
     {
         game.Deal(this);
     }
 }
Exemple #3
0
 /// <summary>
 /// if the hit button is clicked then the following is executed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void hitBtn_click(object sender, EventArgs e)
 {
     //Checks to see whan phase it is in, so the correct information can be displayed
     if ((string)hitBtn.Tag == "BetPhase")
     {
         //Place bet based on user input
         try {
             if (newGame.Bet(Convert.ToInt32(betInput.Text)))
             {
                 //Checks to see if it is the first bet of the game
                 if (newGame.GetGameStatus() == false)
                 {
                     //Cannot 'Walk Away' on first bet
                     newGame.SetGameStatus(true);
                     btn_stand.Visible = true;
                 }
                 hitBtn.Tag  = "GamePhase"; //Changes phase
                 hitBtn.Text = "Hit";
                 UpdateUI();                // updates current ui
                 newGame.Deal();
                 //Updates display
                 DisplayHand("user");
                 lbl_player_score.Text = "Player Total\n" + newGame.GetPlayer().GetPlayerTotal();
                 lbl_dealer_score.Text = "Dealer Total\n" + newGame.GetDealer().GetCard()[1].GetValue(); // error when player gets blackjack
             }
             //If bet size is invalid, bet is not placed and text field is reset
             else
             {
                 betInput.Text = "";
             }
         }
         catch (Exception)
         {
             MessageBox.Show("there is an issue with the current bet");
         }
     }
     else
     {
         //User draws card
         newGame.GetPlayer().AddCard(newGame.GetDeck().DrawCard());
         if (newGame.GetPlayer().GetPlayerTotal() > 21)
         {
             //If user is going bust (over 21), checks to see if they Have any Aces that can have thier value counted as 1 instead of 11
             for (int index = 0; index < newGame.GetPlayer().GetCardAmmount(); index++)
             {
                 if (newGame.GetPlayer().GetCard()[index].GetRank() == "A" && newGame.GetPlayer().GetCard()[index].GetValue() == 11)
                 {
                     newGame.GetPlayer().GetCard()[index].SetValue(1);
                     break;
                 }
             }
         }
         //Updates all info
         newGame.GetPlayer().UpdateHand();
         DisplayHand("user");
         lbl_player_score.Text = "Player Total\n" + newGame.GetPlayer().GetPlayerTotal();
         System.Threading.Thread.Sleep(1);
         //If hand needs to be resolved without a dealer trun, goes straight to hand resolution (player blackjack, 5 card trick or bust)
         if (newGame.GetPlayer().GetCardAmmount() == 5 || newGame.GetPlayer().GetPlayerTotal() > 21)
         {
             newGame.HandOutcome();
         }
         else if (newGame.GetPlayer().GetPlayerTotal() == 21)
         {
             newGame.DealerHand();
         }
     }
 }