本文整理汇总了C#中IHand.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IHand.ToString方法的具体用法?C# IHand.ToString怎么用?C# IHand.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHand
的用法示例。
在下文中一共展示了IHand.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsFlush
public bool IsFlush(IHand hand)
{
if (!IsValidHand(hand))
{
return false;
}
if (hand.Cards.Count != 5)
{
return false;
}
for (int i = 0; i < 5; i++)
{
if (hand.ToString().IndexOf(hand.Cards[i].ToString()) != hand.ToString().LastIndexOf(hand.Cards[i].ToString()))
{
return false;
}
}
CardSuit cardsSuit = hand.Cards[0].Suit;
for (int j = 0; j < 5; j++)
{
if (hand.Cards[j].Suit != cardsSuit)
{
return false;
}
}
return true;
}
示例2: IsFourOfAKind
public bool IsFourOfAKind(IHand hand)
{
if (!IsValidHand(hand))
{
return false;
}
int faceCounter = 1;
int maxCounter = 0;
String[] splitedHand = hand.ToString().Split(' ');
for (int i = 0, len = splitedHand.Length; i < len; i++)
{
for (int j = i + 1; j < len; j++)
{
if (splitedHand[i][0] == splitedHand[j][0])
{
faceCounter++;
}
}
if (faceCounter > maxCounter)
{
maxCounter = faceCounter;
faceCounter = 1;
}
}
if (maxCounter == 4)
return true;
else
return false;
}
示例3: IsFlush
public bool IsFlush(IHand hand)
{
if (!this.IsValidHand(hand))
{
return false;
}
string checkString = hand.ToString();
int[] checkPlaces = new int[NumberOfSuits];
checkPlaces[0] = checkString.IndexOf("Hearts");
checkPlaces[1] = checkString.IndexOf("Clubs");
checkPlaces[2] = checkString.IndexOf("Spades");
checkPlaces[3] = checkString.IndexOf("Diamonds");
int countOfSuits = 0;
for (var i = 0; i < NumberOfSuits; i++)
{
if (checkPlaces[i] != -1)
{
countOfSuits++;
}
}
if (countOfSuits == 1)
{
return true;
}
else
{
return false;
}
}
示例4: IsFlush
public bool IsFlush(IHand hand)
{
if(!IsValidHand(hand))
{
return false;
}
String[] splitedHand = hand.ToString().Split(' ');
for (int i = 0, len = splitedHand.Length; i < len; i++)
{
for (int j = i + 1; j < len; j++)
{
if (splitedHand[i][1] != splitedHand[j][1])
{
return false;
}
}
}
return true;
}
示例5: IsValidHand
public bool IsValidHand(IHand hand)
{
if (hand == null)
{
return false;
}
if (hand.Cards.Count != 5)
{
return false;
}
byte initialCardsCount = 5;
for (int i = 0; i < initialCardsCount; i++)
{
if (hand.ToString().IndexOf(hand.Cards[i].ToString()) != hand.ToString().LastIndexOf(hand.Cards[i].ToString()))
{
return false;
}
}
return true;
}
示例6: IsValidHand
public bool IsValidHand(IHand hand)
{
if (hand?.Cards.Count != 5)
{
return false;
}
for (int i = 0; i < 5; i++)
{
if (hand.ToString().IndexOf(hand.Cards[i].ToString()) != hand.ToString().LastIndexOf(hand.Cards[i].ToString()))
{
return false;
}
}
return true;
}
示例7: IsValidHand
public bool IsValidHand(IHand hand)
{
if (hand == null)
{
throw new ArgumentNullException("No hand passed");
}
if (hand.Cards.Count != 5)
{
return false;
}
for (int i = 0; i < 5; i++)
{
if (hand.ToString().IndexOf(hand.Cards[i].ToString()) != hand.ToString().LastIndexOf(hand.Cards[i].ToString()))
{
return false;
}
}
return true;
}
示例8: IsValidHand
public bool IsValidHand(IHand hand)
{
String[] splitedHand = hand.ToString().Split(' ');
if (splitedHand.Length != ValidHandCount)
{
return false;
}
for (int i = 0,len = splitedHand.Length; i < len; i++)
{
for (int j = i+1; j < len; j++)
{
if (splitedHand[i] == splitedHand[j])
{
return false;
}
}
}
return true;
}
示例9: RecognizeHandStrength
public HandStrength RecognizeHandStrength(IHand hand)
{
HandStrength handStrength = HandStrength.HighCard;
if (!IsValidHand(hand))
{
throw new ArgumentException("this hand is not valid: " + hand.ToString());
}
if (IsStraightFlush(hand))
{
handStrength = HandStrength.StraightFlush;
return handStrength;
}
if (IsFourOfAKind(hand))
{
handStrength = HandStrength.FourOfAKind;
return handStrength;
}
if (IsFullHouse(hand))
{
handStrength = HandStrength.FullHouse;
return handStrength;
}
if (IsFlush(hand))
{
handStrength = HandStrength.Flush;
return handStrength;
}
if (IsStraight(hand))
{
handStrength = HandStrength.Straight;
return handStrength;
}
if (IsThreeOfAKind(hand))
{
handStrength = HandStrength.ThreeOfAKind;
return handStrength;
}
if (IsTwoPairs(hand))
{
handStrength = HandStrength.TwoPairs;
return handStrength;
}
if (IsOnePair(hand))
{
handStrength = HandStrength.OnePair;
return handStrength;
}
return handStrength;
}