コード例 #1
0
        /// <summary>
        /// Calculates the value represented by a specified hand.
        /// </summary>
        /// <param name="hand">The hand for which to calculate the value.</param>
        /// <param name="game">The associated game.</param>
        /// <param name="value">Will contain the hand's value. If the hand has two
        /// possible values due to it containing an ace, this will be the lower
        /// value.</param>
        /// <param name="considerAce">Whether or not an ace can be considered to
        /// make the hand have an alternative value.</param>
        private static void CalulateValue(Hand hand, CardsFramework.CardsGame game,
            out int value, out bool considerAce)
        {
            value = 0;
            considerAce = false;

            for (int cardIndex = 0; cardIndex < hand.Count; cardIndex++)
            {
                value += game.CardValue(hand[cardIndex]);

                if (hand[cardIndex].Value == CardValue.Ace)
                {
                    considerAce = true;
                }
            }

            if (considerAce && value + 10 > 21)
            {
                considerAce = false;
            }
        }
コード例 #2
0
 /// <summary>
 /// Creates a new blackjack player instance.
 /// </summary>
 /// <param name="name">The player's name.</param>
 /// <param name="game">The game associated with the player.</param>
 public BlackjackPlayer(string name, CardsFramework.CardsGame game)
     : base(name, game)
 {
     Balance = 500;
     CurrentHandType = HandTypes.First;
 }