本文整理汇总了C#中IHand.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# IHand.Cast方法的具体用法?C# IHand.Cast怎么用?C# IHand.Cast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHand
的用法示例。
在下文中一共展示了IHand.Cast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compare
/// <summary>
/// Compares the specified hand to determine if it is of the same type as this comparer.
/// </summary>
/// <param name="hand">The hand to be compared.</param>
/// <returns>
/// a tuple specifying information about the comparison.
/// <para>The first value returns the type of this comparer if the specified hand matches, otherwise it returns <see cref="Hands.HighCard"/>.</para>
/// <para>The second value indicates the high card of the hand if there was a match, otherwise it returns <see cref="Rank.Two"/>.</para>
/// </returns>
public Tuple<Hands, Rank> Compare(IHand hand)
{
Argument.IsNotNull(() => hand);
if (hand.Count < 5)
return Tuple.Create<Hands, Rank>(0, 0);
var suit = hand[0].Suit;
if (hand.Cast<Card>().Any(card => suit != card.Suit))
{
// Found a different suit, not a flush.
return Tuple.Create<Hands, Rank>(0, 0);
}
// High card will be the first card, since the hand is already sorted by rank.
return Tuple.Create(Hands.Flush, hand[0].Rank);
}