Exemple #1
0
        /// <summary>
        /// Plays a single hand.  This may be called multiple times if a hand is split.
        /// </summary>
        /// <param name="table">The Table object to use to request cards</param>
        /// <param name="CurrentHand">Hand to play</param>
        public void PlayHand(Hand CurrentHand)
        {
            while (CurrentHand.Value <= 21 && !CurrentHand.DoubledDown)
            {
                PlayAction Action = this.DecideAction(_Table.UpCard, CurrentHand);
                switch (Action)
                {
                case PlayAction.Split:
                    _Table.Split(CurrentHand, this, Chips.RemoveChips(CurrentHand.Bet.Value));
                    Track.Splits++;
                    break;

                case PlayAction.DoubleDown:
                    _Table.DoubleDown(CurrentHand, Chips.RemoveChips(CurrentHand.Bet.Value));
                    Track.Doubles++;
                    break;

                case PlayAction.Hit:
                    _Table.Hit(CurrentHand);
                    Track.Hits++;
                    break;

                case PlayAction.Stand:
                    Track.Stands++;
                    return;
                }
            }
            if (CurrentHand.Value > 21)
            {
                Track.Busted++;
            }                                                   // Wah wah waaaah.
        }
Exemple #2
0
 /// <summary>
 /// Called by the table to play insurance bets.  This calls DecideInsurance(), implemented in child classes.
 /// </summary>
 /// <returns>Returns a ChipStack with an insurance bet, otherwise null.</returns>
 public ChipStack PlayInsurance()
 {
     if (DecideInsurance())
     {
         ChipStack insurance = Chips.RemoveChips((int)(Hands[0].Bet.Value * 0.5));
         return(insurance);
     }
     return(null);
 }
Exemple #3
0
        /// <summary>
        /// Used by the table object to elicit an ante from the player.
        /// The player will return cash if the player has enough.
        /// Default action is to bid only the table minimum.  This can be overridden to send more money.
        /// </summary>
        /// <param name="sender">Calling object</param>
        /// <param name="Minimum">Minimum buy-in for the table</param>
        /// <returns></returns>
        public virtual ChipStack RequestAnte()
        {
            if (Chips.Value < _Table.Rules.MinimumBet)
            {
                return(null);
            }
            int Amount = DecideAnte();

            if (Amount > Chips.Value)
            {
                throw new Exception("Player object decided on an ante too large for available funds");
            }
            if (!_Table.Rules.CheckBet(Amount))
            {
                throw new Exception("Player decided on an ante too large or small for the table");
            }
            if (Amount == 0)
            {
                return(null);
            }
            return(Chips.RemoveChips(Amount));
        }