本文整理汇总了C#中Hand.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Hand.GetValue方法的具体用法?C# Hand.GetValue怎么用?C# Hand.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hand
的用法示例。
在下文中一共展示了Hand.GetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValue_ShouldReturnCorrectResult_ForTwoCards
public void GetValue_ShouldReturnCorrectResult_ForTwoCards(Ranks rank1, Ranks rank2, int expectedValue, Hand hand, Suits suit)
{
hand.AddCard(rank1.Of(suit));
hand.AddCard(rank2.Of(suit));
Assert.Equal(expectedValue, hand.GetValue());
}
示例2: Play_ShouldAddCardsUntil17
public void Play_ShouldAddCardsUntil17(LeveledDealerStrategy dealerStrategy,
Hand dealerHand,
[Frozen(As = typeof(IDeckCreator))] FullDeckCreator deckCreator,
EndlessCardsProvider cardsProvider)
{
dealerStrategy.Play(dealerHand, cardsProvider);
_outputHelper.WriteLine(string.Join(", ", dealerHand.Cards));
Assert.True(dealerHand.GetValue() >= 17);
}
示例3: GetValue_ShouldReturnCorrectResult_ForOneCard
public void GetValue_ShouldReturnCorrectResult_ForOneCard(Hand hand, Card card)
{
var expectedValue = BlackJack.CardValues[card.Rank];
if (card.Rank == Ace)
{
expectedValue += BlackJack.AceIncrement;
}
hand.AddCard(card);
Assert.Equal(expectedValue, hand.GetValue());
}
示例4: Deal
/// <summary>
/// Deals cards to the players, then the dealer.
/// </summary>
public void Deal()
{
_deck.Shuffle();
// Deal to all of the players.
foreach (var playerKV in _players)
{
var playerID = playerKV.Key;
var player = playerKV.Value;
// Deal two cards.
var hand = new Hand();
Deal(hand, 2);
player.Hands.Add(hand);
// Blackjack! You win! And can't do anything!
if (hand.GetValue() == 21)
{
hand.State = HandState.Blackjack;
}
// Show the player their hand.
PrintPlayersHands(playerID);
}
// Deal to dealer, and hide the hole card.
_dealerHand = new Hand();
Deal(_dealerHand, 2);
PrintDealer(true);
CheckInsurance();
ChangeState(State.PlayerTurn);
// What if everyone playing got a blackjack?!?!
CheckHands();
}