本文整理汇总了C#中IHand.SetRank方法的典型用法代码示例。如果您正苦于以下问题:C# IHand.SetRank方法的具体用法?C# IHand.SetRank怎么用?C# IHand.SetRank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHand
的用法示例。
在下文中一共展示了IHand.SetRank方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsHand
public bool IsHand(IHand hand)
{
Suit? suit = null;
Value? expectedCard = null;
int cardsChecked = 0;
foreach (var card in hand.GetCards().OrderBy(c => c.GetCardValue()))
{
if (!expectedCard.HasValue)
{
expectedCard = card.GetCardValue();
}
if (cardsChecked == 4 && expectedCard == Value.Six && card.GetCardValue() == Value.Ace)
{
hand.SetRank(Rank.StraightFlush);
return true;
}
if ((suit.HasValue && suit.Value != card.GetCardSuit())|| card.GetCardValue() != expectedCard)
{
return false;
}
suit = card.GetCardSuit();
expectedCard ++;
cardsChecked++;
}
hand.SetRank(Rank.StraightFlush);
return true;
}
示例2: IsHand
public bool IsHand(IHand hand)
{
var threeOfAKind = false;
var pair = false;
for (var i = Value.Two; i <= Value.Ace; i++)
{
IEnumerable<Card> cardsOfSameValue = hand.GetCards().Where(obj => obj.GetCardValue() == i);
if (cardsOfSameValue.Count() > 2 && !threeOfAKind)
{
threeOfAKind = true;
}
else if (cardsOfSameValue.Count() > 1 && !pair)
{
pair = true;
}
if (threeOfAKind && pair)
{
hand.SetRank(Rank.FullHouse);
return true;
}
}
return false;
}
示例3: IsHand
public bool IsHand(IHand hand)
{
for (var i = Value.Two; i <= Value.Ace; i ++)
{
var fourMatchCheck = hand.GetCards().Where(obj => obj.GetCardValue() == i);
if (fourMatchCheck.Count() == 4)
{
hand.SetRank(Rank.FourOfAKind);
return true;
}
}
return false;
}
示例4: IsHand
public bool IsHand(IHand hand)
{
for (var i = Value.Two; i <= Value.Ace; i++)
{
IEnumerable<Card> cardsOfSameValue = hand.GetCards().Where(obj => obj.GetCardValue() == i);
if (cardsOfSameValue.Count() == 3)
{
hand.SetRank(Rank.ThreeOfAKind);
return true;
}
}
return false;
}
示例5: IsHand
public bool IsHand(IHand hand)
{
Suit? suit = null;
foreach (var card in hand.GetCards())
{
if (suit.HasValue && suit != card.GetCardSuit())
{
return false;
}
suit = card.GetCardSuit();
}
hand.SetRank(Rank.Flush);
return true;
}
示例6: IsStraight
private bool IsStraight(IHand hand)
{
var sortedHand = hand.SortCards();
var expectedNextCardValue = sortedHand[0].GetCardValue() + 1;
for (var x = 1; x < sortedHand.Count; x++)
{
var currentCard = sortedHand[x];
if (currentCard.GetCardValue() != expectedNextCardValue)
{
return false;
}
expectedNextCardValue++;
}
hand.SetRank(Rank.Straight);
return true;
}
示例7: IsHand
public bool IsHand(IHand hand)
{
Suit? suit = null;
var expectedCard = Value.Ten;
foreach (var card in hand.GetCards().OrderBy(c => c.GetCardValue()))
{
if ((suit.HasValue && suit.Value != card.GetCardSuit()) || (card.GetCardValue() != expectedCard))
{
return false;
}
expectedCard++;
suit = card.GetCardSuit();
}
hand.SetRank(Rank.RoyalFlush);
return true;
}
示例8: IsHand
public bool IsHand(IHand hand)
{
var numberOfPairs = 0;
for (var i = Value.Two; i <= Value.Ace; i++)
{
var cardsOfSameValue = hand.GetCards().Where(obj => obj.GetCardValue() == i);
if (cardsOfSameValue.Count() == 2)
{
numberOfPairs++;
}
}
if (numberOfPairs == 1)
{
hand.SetRank(Rank.Pair);
return true;
}
return false;
}