本文整理汇总了C#中Hand.Lose方法的典型用法代码示例。如果您正苦于以下问题:C# Hand.Lose方法的具体用法?C# Hand.Lose怎么用?C# Hand.Lose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hand
的用法示例。
在下文中一共展示了Hand.Lose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHandResult
/// <summary>
/// Get the game result. This returns an EndResult value
/// </summary>
/// <returns></returns>
public EndResult GetHandResult(Hand playerHand)
{
EndResult endState;
var dealerHand = Dealer.Hands[0];
// Check for blackjack
if (playerHand.NumCards == 2 && playerHand.HasBlackJack() && dealerHand.NumCards == 2 &&
dealerHand.HasBlackJack())
{
endState = EndResult.Push;
playerHand.Push();
}
else if (playerHand.NumCards == 2 && playerHand.HasBlackJack())
{
endState = EndResult.PlayerBlackJack;
playerHand.WinBlackjack();
}
else if (dealerHand.NumCards == 2 && dealerHand.HasBlackJack())
{
endState = EndResult.DealerBlackJack;
playerHand.Lose();
}
// Check if the dealer has bust
else if (dealerHand.HasBust())
{
endState = EndResult.DealerBust;
playerHand.Win();
}
else if (dealerHand.CompareFaceValue(playerHand) > 0)
{
//dealer wins
endState = EndResult.DealerWin;
playerHand.Lose();
}
else if (dealerHand.CompareFaceValue(playerHand) == 0)
{
// push
endState = EndResult.Push;
playerHand.Push();
}
// Check if the dealer has bust
else if (playerHand.HasBust())
{
endState = EndResult.PlayerBust;
playerHand.Lose();
}
else
{
// player wins
endState = EndResult.PlayerWin;
playerHand.Win();
}
return endState;
}