コード例 #1
0
		private Card Hit(Player player)
		{
			var card = _deck.DealCard();
			player.Hand.Add(card);

			return card;
		}
コード例 #2
0
		private void DealCards(Player player, int numCards)
		{
			for (var i = 0; i < numCards; i++)
			{
				var card = _deck.DealCard();
				player.Hand.Add(card);
			}
		}
コード例 #3
0
		private string DisplayPlayerCardAndScore(Player player, Card card)
		{
			return string.Format("{0} (Current score for {1}: {2})", card.DisplayName, player.Name, GetPlayerScore(player));
		}
コード例 #4
0
		private int GetPlayerScore(Player player)
		{
			var score = player.Hand.Sum(card => card.NumericalValue);
			return score;
		}
コード例 #5
0
		// constructor
		private BlackjackGame(string player1Name, string player2Name)
		{
			_deck = new Deck();
			You = new Player(player1Name);
			Them = new Player(player2Name);
		}
コード例 #6
0
		// constructor
		private PokerGame(string player1Name, string player2Name)
		{
			_deck = new Deck();
			_handRankings = new Dictionary<int, string>
			{
				{10, "Royal Flush"},
				{9, "Straight Flush"},
				{8, "Four-of-a-Kind"},
				{7, "Full House"},
				{6, "Flush"},
				{5, "Straight"},
				{4, "Three-of-a-Kind"},
				{3, "Two Pair"},
				{2, "Pair"},
				{1, "Nothing!"}
			};
			You = new Player(player1Name);
			Them = new Player(player2Name);
		}
コード例 #7
0
		private static void PrintHand(Player player)
		{
			Console.WriteLine("\nCurrent hand for: {0}", player.Name);
			var orderedHand = player.Hand.OrderByDescending(c => c.Rank);

			foreach (var card in orderedHand)
			{
				Console.WriteLine(card.DisplayName);
			}
		}