Example #1
0
		private static bool Soft17(HandStruct hand)
		{
			if (hand.totalcards > 2 || hand.bestscore != 17)
				return false;
			if (hand.card[0] % 13 == 0 || hand.card[1] % 13 == 0)
				return true;
			return false;
		}
Example #2
0
		private static bool CheckForBlackJack(HandStruct hand)
		{
			return (CardValue(hand.card[0], true) + CardValue(hand.card[1], true)) == 21 ? true : false;
		}
Example #3
0
		private static bool DealerMustHit(HandStruct hand, bool DealerHitsSoft17, out string message)
		{
			if (hand.totalcards > 10)
			{
				message = "Dealer must stand with eleven cards.";
				return false;
			}
			if (hand.bestscore > 16)
			{
				if (Soft17(hand) && DealerHitsSoft17)
				{
					message = "Dealer must hit soft 17.";
					return true;
				}
				else
				{
					if (hand.bestscore > 21)
						message = "Dealer busts.";
					else if (hand.bestscore == 21)
						message = "Dealer stands at 21.";
					else
						message = "Dealer stands.";
					return false;
				}
			}
			message = DealerHitMessage();
			return true;
		}
Example #4
0
		private static HandStruct EvalHand(HandStruct hand)
		{
			hand.bestscore = 0;
			hand.altscore = 0;
			bool AceFound = false;
			for (int c = 0; c < hand.totalcards; c++)
			{
				if ((hand.card[c] % 13) == 0)
					AceFound = true;
				hand.bestscore += CardValue(hand.card[c], false);
			}
			if (AceFound)
			{
				hand.altscore = hand.bestscore;
				hand.bestscore = 0;
				int Ace = 0;
				for (int c = 0; c < hand.totalcards; c++)
				{
					if ((hand.card[c] % 13) == 0)
						Ace++;
					if (Ace == 1)
						hand.bestscore += CardValue(hand.card[c], true);
					else
						hand.bestscore += CardValue(hand.card[c], false);
				}
				if (hand.bestscore > 21)
				{
					hand.bestscore = hand.altscore;
					hand.altscore = 0;
				}
			}
			return hand;
		}