本文整理汇总了C#中Poker.PokerHandsChecker.IsStraight方法的典型用法代码示例。如果您正苦于以下问题:C# PokerHandsChecker.IsStraight方法的具体用法?C# PokerHandsChecker.IsStraight怎么用?C# PokerHandsChecker.IsStraight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poker.PokerHandsChecker
的用法示例。
在下文中一共展示了PokerHandsChecker.IsStraight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
Console.WriteLine(card);
IHand hand = new Hand(new List<ICard>() {
new Card(CardFace.Ace, CardSuit.Clubs),
new Card(CardFace.Ace, CardSuit.Diamonds),
new Card(CardFace.King, CardSuit.Hearts),
new Card(CardFace.King, CardSuit.Spades),
new Card(CardFace.Seven, CardSuit.Diamonds),
});
Console.WriteLine(hand);
IPokerHandsChecker checker = new PokerHandsChecker();
Console.WriteLine(checker.IsValidHand(hand));
Console.WriteLine(checker.IsStraight(hand));
Console.WriteLine(checker.IsOnePair(hand));
Console.WriteLine(checker.IsTwoPair(hand));
Console.WriteLine(checker.IsStraightFlush(hand));
Console.WriteLine(checker.IsFlush(hand));
Console.WriteLine(checker.IsFourOfAKind(hand));
Console.WriteLine(checker.IsThreeOfAKind(hand));
Console.WriteLine(checker.IsHighCard(hand));
Console.WriteLine(checker.IsFullHouse(hand));
}
示例2: Main
private static void Main()
{
try
{
IHand hand = new Hand(new List<ICard>()
{
new Card(CardFace.Ace, CardSuit.Clubs),
new Card(CardFace.Queen, CardSuit.Clubs),
new Card(CardFace.King, CardSuit.Clubs),
new Card(CardFace.Jack, CardSuit.Clubs),
new Card(CardFace.Ten, CardSuit.Clubs),
});
Console.WriteLine(hand);
IPokerHandsChecker checker = new PokerHandsChecker();
Console.WriteLine(checker.IsValidHand(hand) ? "Hand is valid." : "Hand is not valid!");
Console.WriteLine(checker.IsRoyalFlush(hand) ? "Royal flush." : "Hand is not Royal flush!");
Console.WriteLine(checker.IsStraightFlush(hand) ? "Straight flush." : "Hand is not Straight flush!");
Console.WriteLine(checker.IsFlush(hand) ? "Flush." : "Hand is not Flush!");
Console.WriteLine(checker.IsStraight(hand) ? "Straight." : "Hand is not Straight!");
Console.WriteLine(checker.IsFullHouse(hand) ? "Full house." : "Hand is not Full house!");
Console.WriteLine(checker.IsFourOfAKind(hand) ? "Four of a kind." : "Hand is not Four of a kind!");
Console.WriteLine(checker.IsThreeOfAKind(hand) ? "Three of a kind." : "Hand is not Three of a kind!");
IHand hand1 = new Hand("K♥ J♥ 8♣ 7♦ 4♠");
Console.WriteLine(hand1);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
示例3: Main
public static void Main()
{
XmlConfigurator.Configure();
Log.Info("Info logging");
try
{
ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
Console.WriteLine(card);
IHand hand = new Hand(new List<ICard>()
{
new Card(CardFace.Ace, CardSuit.Clubs),
new Card(CardFace.Jack, CardSuit.Diamonds),
new Card(CardFace.King, CardSuit.Hearts),
new Card(CardFace.Ten, CardSuit.Spades),
new Card(CardFace.Queen, CardSuit.Diamonds),
});
Console.WriteLine(hand);
IPokerHandsChecker checker = new PokerHandsChecker();
Console.WriteLine("Valid hand? : {0}", checker.IsValidHand(hand));
Console.WriteLine("Is Straight : {0}", checker.IsStraight(hand));
Console.WriteLine("Is one pair : {0}", checker.IsOnePair(hand));
Console.WriteLine("Is two pair : {0}", checker.IsTwoPair(hand));
}
catch (Exception e)
{
Log.Error("This is my error", e);
}
}
示例4: StraightHand
public void StraightHand()
{
var hand = new Hand(new List<ICard>() {
new Card(CardFace.Seven, CardSuit.Clubs),
new Card(CardFace.Eight, CardSuit.Hearts),
new Card(CardFace.Ten, CardSuit.Spades),
new Card(CardFace.Nine, CardSuit.Clubs),
new Card(CardFace.Jack, CardSuit.Diamonds)
});
var checker = new PokerHandsChecker();
Assert.IsTrue(checker.IsStraight(hand));
}
示例5: TestIsStraightLessCards
public void TestIsStraightLessCards()
{
Card cardOne = new Card(CardFace.Two, CardSuit.Diamonds);
Card cardTwo = new Card(CardFace.Four, CardSuit.Hearts);
Card cardThree = new Card(CardFace.Three, CardSuit.Spades);
IList<ICard> cards = new List<ICard>();
cards.Add(cardOne);
cards.Add(cardTwo);
cards.Add(cardThree);
Hand hand = new Hand(cards);
PokerHandsChecker poker = new PokerHandsChecker();
bool isStraight = poker.IsStraight(hand);
Assert.AreEqual(false, isStraight, "IsStraight() method in class PokerHandsChecker is not working correctly.");
}
示例6: IsStraight_True
public void IsStraight_True()
{
PokerHandsChecker checker = new PokerHandsChecker();
List<ICard> cardList = new List<ICard>
{
new Card(CardFace.Two,CardSuit.Clubs),
new Card(CardFace.Five,CardSuit.Diamonds),
new Card(CardFace.Four,CardSuit.Spades),
new Card(CardFace.Three,CardSuit.Hearts),
new Card(CardFace.Six,CardSuit.Diamonds)
};
Hand hand = new Hand(cardList);
bool isStraight = checker.IsStraight(hand);
Assert.IsTrue(isStraight);
}
示例7: TestIsStraightWithFiveSequentialCardsSameSuit
public void TestIsStraightWithFiveSequentialCardsSameSuit()
{
PokerHandsChecker handChecker = new PokerHandsChecker();
Hand hand = new Hand(new List<ICard>()
{
new Card(CardFace.Two, CardSuit.Diamonds),
new Card(CardFace.Three, CardSuit.Diamonds),
new Card(CardFace.Four, CardSuit.Diamonds),
new Card(CardFace.Five, CardSuit.Diamonds),
new Card(CardFace.Six, CardSuit.Diamonds)
});
bool result = handChecker.IsStraight(hand);
Assert.AreEqual(false, result);
}
示例8: IsStraight_HandWithFullHouse
public void IsStraight_HandWithFullHouse()
{
IList<ICard> cards = new List<ICard>
{
new Card(CardFace.Ace, CardSuit.Diamonds),
new Card(CardFace.Ace, CardSuit.Hearts),
new Card(CardFace.Six, CardSuit.Clubs),
new Card(CardFace.Six, CardSuit.Hearts),
new Card(CardFace.Six, CardSuit.Spades),
};
Hand hand = new Hand(cards);
PokerHandsChecker checker = new PokerHandsChecker();
Assert.IsFalse(checker.IsStraight(hand));
}
示例9: IsStraight_HandWithStraight
public void IsStraight_HandWithStraight()
{
IList<ICard> cards = new List<ICard>
{
new Card(CardFace.Ace, CardSuit.Diamonds),
new Card(CardFace.King, CardSuit.Hearts),
new Card(CardFace.Queen, CardSuit.Clubs),
new Card(CardFace.Jack, CardSuit.Hearts),
new Card(CardFace.Ten, CardSuit.Spades),
};
Hand hand = new Hand(cards);
PokerHandsChecker checker = new PokerHandsChecker();
Assert.IsTrue(checker.IsStraight(hand));
}
示例10: IsStraight_HandWithFullStraightTheWheel
public void IsStraight_HandWithFullStraightTheWheel()
{
IList<ICard> cards = new List<ICard>
{
new Card(CardFace.Ace, CardSuit.Diamonds),
new Card(CardFace.Two, CardSuit.Diamonds),
new Card(CardFace.Three, CardSuit.Diamonds),
new Card(CardFace.Four, CardSuit.Diamonds),
new Card(CardFace.Five, CardSuit.Diamonds),
};
Hand hand = new Hand(cards);
PokerHandsChecker checker = new PokerHandsChecker();
Assert.IsFalse(checker.IsStraight(hand));
}
示例11: TestIsStraightNotArangedCards
public void TestIsStraightNotArangedCards()
{
Card cardOne = new Card(CardFace.Ten, CardSuit.Diamonds);
Card cardTwo = new Card(CardFace.Queen, CardSuit.Hearts);
Card cardThree = new Card(CardFace.Ace, CardSuit.Spades);
Card cardFour = new Card(CardFace.Jack, CardSuit.Clubs);
Card cardFive = new Card(CardFace.King, CardSuit.Clubs);
IList<ICard> cards = new List<ICard>();
cards.Add(cardOne);
cards.Add(cardTwo);
cards.Add(cardThree);
cards.Add(cardFour);
cards.Add(cardFive);
Hand hand = new Hand(cards);
PokerHandsChecker poker = new PokerHandsChecker();
bool isStraight = poker.IsStraight(hand);
Assert.AreEqual(true, isStraight, "IsStraight() method in class PokerHandsChecker is not working correctly.");
}
示例12: FullHouseTrivial
public void FullHouseTrivial()
{
IList<ICard> cards = new List<ICard>();
cards.Add(new Card(CardFace.Ace, CardSuit.Clubs));
cards.Add(new Card(CardFace.Ace, CardSuit.Diamonds));
cards.Add(new Card(CardFace.Ace, CardSuit.Hearts));
cards.Add(new Card(CardFace.Ten, CardSuit.Spades));
cards.Add(new Card(CardFace.Ten, CardSuit.Clubs));
Hand hand = new Hand(cards);
PokerHandsChecker checker = new PokerHandsChecker();
bool result = checker.IsStraight(hand);
bool expected = false;
Assert.AreEqual(expected, result);
}
示例13: StraightWithAceAsMin
public void StraightWithAceAsMin()
{
IList<ICard> cards = new List<ICard>();
cards.Add(new Card(CardFace.Ace, CardSuit.Clubs));
cards.Add(new Card(CardFace.Two, CardSuit.Clubs));
cards.Add(new Card(CardFace.Three, CardSuit.Diamonds));
cards.Add(new Card(CardFace.Four, CardSuit.Hearts));
cards.Add(new Card(CardFace.Five, CardSuit.Spades));
Hand hand = new Hand(cards);
PokerHandsChecker checker = new PokerHandsChecker();
bool result = checker.IsStraight(hand);
bool expected = true;
Assert.AreEqual(expected, result);
}
示例14: IsStraightTest
public void IsStraightTest()
{
Card aceClubs = new Card(CardFace.Ace, CardSuit.Clubs);
Card queenClubs = new Card(CardFace.Queen, CardSuit.Clubs);
Card kingHearts = new Card(CardFace.King, CardSuit.Hearts);
Card jackClubs = new Card(CardFace.Jack, CardSuit.Clubs);
Card tenOfClubs = new Card(CardFace.Ten, CardSuit.Clubs);
List<ICard> cardsInHand = new List<ICard>();
cardsInHand.Add(tenOfClubs);
cardsInHand.Add(aceClubs);
cardsInHand.Add(jackClubs);
cardsInHand.Add(queenClubs);
cardsInHand.Add(kingHearts);
IHand hand = new Hand(cardsInHand);
PokerHandsChecker handsChecker = new PokerHandsChecker();
Assert.IsTrue(handsChecker.IsStraight(hand));
}
示例15: IsNotStraightTest
public void IsNotStraightTest()
{
Card twoOfHearts = new Card(CardFace.Two, CardSuit.Hearts);
Card aceOfSpades = new Card(CardFace.Ace, CardSuit.Spades);
Card threeOfHearts = new Card(CardFace.Three, CardSuit.Hearts);
Card kingOfHearts = new Card(CardFace.King, CardSuit.Hearts);
Card tenOfHearts = new Card(CardFace.Ten, CardSuit.Hearts);
List<ICard> cardsInHand = new List<ICard>();
cardsInHand.Add(twoOfHearts);
cardsInHand.Add(aceOfSpades);
cardsInHand.Add(threeOfHearts);
cardsInHand.Add(kingOfHearts);
cardsInHand.Add(tenOfHearts);
IHand hand = new Hand(cardsInHand);
PokerHandsChecker handsChecker = new PokerHandsChecker();
Assert.IsFalse(handsChecker.IsStraight(hand));
}