Ejemplo n.º 1
0
        public override void AssignCard(Card card)
        {
            base.AssignCard(card);

            if (this.Hand.HandStatus == BlackJackHand.HandStatusTypes.None && this.Hand.HandValue >= GlobalSettings.DEALER_LIMIT)
            {
                this.Hand.Stand();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Private method to add cards to list.
 /// </summary>
 private void PrepareDeck()
 {
     foreach (int intSuite in Enum.GetValues(typeof(Card.CardSuites)))
     {
         foreach (int intRank in Enum.GetValues(typeof(Card.CardRanks)))
         {
             Card objCard = new Card((Card.CardSuites)intSuite, (Card.CardRanks)intRank);
             Cards.Add(objCard);
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Receives a card from dealer. Called when dealing two initial cards.
 /// </summary>
 /// <param name="card">Card delt to this player.</param>
 public virtual void AssignCard(Card card)
 {
     Hand.AddCard(card);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Add card to deck.
        /// </summary>
        /// <param name="card">Card to be added to deck.</param>
        /// <exception cref="InvalidGameActionException">Thrown when hand is busted and player tries to add more cards to it.</exception>
        public void AddCard(Card card)
        {
            if (HandStatus != HandStatusTypes.Busted)
            {
                this.lstCards.Add(card);
                ReCalculateHandValue();

                //Check whether split is allowed or not.
                if (this.lstCards.Count == 2)
                {
                    this.IsSplittingAllowed = (!isSplittedHand) && (this.lstCards[0].GetBlackJackValue() == this.lstCards[1].GetBlackJackValue());
                }

                if (HandValue == GlobalSettings.BLACK_JACK_VALUE)
                {
                    HandStatus = HandStatusTypes.BlackJack;

                    if (BlackJacked != null)
                    {
                        BlackJacked(this);
                    }
                }
                else if (HandValue > GlobalSettings.BLACK_JACK_VALUE)
                {
                    HandStatus = HandStatusTypes.Busted;

                    if (HandBusted != null)
                    {
                        HandBusted(this);
                    }
                }
                else if (HandValue >= GlobalSettings.DEALER_LIMIT)
                {
                    if (DealerLimitReached != null)
                    {
                        DealerLimitReached(this);
                    }
                }
            }
            else
            {
                throw new Exceptions.InvalidGameActionException("Card can't be added to a busted jack.");
            }
        }