Esempio n. 1
0
    public void DrawCardClick()
    {
        MasterDeck.DrawCard(playerHand, true, 1);

        if (playerHand.HandValues[1] == 21 || playerHand.HandValues[0] == 21)
        {
            StandClick();
        }
        else if (playerHand.HandValues[0] > 21)
        {
            StartCoroutine(GameOverText(0));
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Gets a random deck of cards from the master Deck. This will also remove
    /// those cards from the master deck. There is also a possibility that the
    /// master deck will run out of cards. In this case, this function will only
    /// return the remaining cards in the deck. This function also goes ahead and
    /// shuffles the cards before they are returned.
    /// </summary>
    /// <param name="size">The size of the deck to create. Defaults to 10.</param>
    /// <returns>A new Deck of cards.</returns>
    public static Deck GetRandomDeck(int size = 10)
    {
        lock (padLock)
        {
            MasterDeck master  = MasterDeck.GetInstance();
            Deck       newDeck = new Deck();

            while (newDeck.Size() < size && master.Size() > 0)
            {
                newDeck.AddCard(master.DrawCard());
            }

            newDeck.Shuffle();

            return(newDeck);
        }
    }
Esempio n. 3
0
 public IEnumerator DealerDraw()
 {
     //checks if dealer has blackjack
     if (dealerHand.HandValues[1] == 21)
     {
         CheckScore(playerHand.HandValues, dealerHand.HandValues);
     }
     else
     {
         while (dealerHand.HandValues[0] <= 17 && !(dealerHand.HandValues[1] > 17 && dealerHand.HandValues[1] < 21))
         {
             MasterDeck.DrawCard(dealerHand, false, 1);
             while (AnimPlaying)
             {
                 yield return(null);
             }
         }
     }
     CheckScore(playerHand.HandValues, dealerHand.HandValues);
 }