本文整理汇总了Python中analyzer.Analyzer._flush方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer._flush方法的具体用法?Python Analyzer._flush怎么用?Python Analyzer._flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer._flush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestAnalyzer
# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import _flush [as 别名]
#.........这里部分代码省略.........
self.p3.hole[1].value = 12
# pair
self.p4.hole[0].value = 12
self.p4.hole[1].value = 11
self.p4.hole[2].value = 14
self.p4.hole[3].value = 14
self.p4.hole[4].value = 13
self.p4.hole[5].value = 3
self.p4.hole[6].value = 2
players = self.analyzer._order(players)
self.analyzer._matching(players)
# Do we have 4 A's with a K kicker?
self.assertEqual(self.p0.hand, [7, 14, 13])
# Do we have a boat A's full of K's?
self.assertEqual(self.p1.hand, [6, 14, 13])
# Do we have trip A's with K & Q kickers?
self.assertEqual(self.p2.hand, [3, 14, 13, 12])
# Do we have 2 pair A's & Q's with a K kicker?
self.assertEqual(self.p3.hand, [2, 14, 12, 13])
# Do we have a pair of A's with K, Q, J kickers?
self.assertEqual(self.p4.hand, [1, 14, 13, 12, 11])
def test_straight(self ):
"""can we find the highest straight in a hand"""
players = self.analyzer._setup()
#p0 has a 6 high straight
self.p0.hole[0].value = 8
self.p0.hole[1].value = 6
self.p0.hole[2].value = 5
self.p0.hole[3].value = 4
self.p0.hole[4].value = 3
self.p0.hole[5].value = 13
self.p0.hole[6].value = 2
#poor p1 hit the wheel
self.p1.hole[0].value = 14
self.p1.hole[1].value = 11
self.analyzer._order(players)
self.analyzer._straight(self.p0)
self.analyzer._straight(self.p1)
expected_0 = [4, 6]
expected_1 = [4, 5]
self.assertEqual(self.p0.hand, expected_0)
self.assertEqual(self.p1.hand, expected_1)
def test_flush(self):
"""Can we find a flush in the players' hands"""
players = self.analyzer._setup()
# a flush
self.p0.hole[0].suit = "d"
self.p0.hole[0].value = 2
self.p0.hole[1].suit = "d"
self.p0.hole[1].value = 2
self.p0.hole[2].suit = "d"
self.p0.hole[3].suit = "d"
self.p0.hole[4].suit = "d"
self.p0.hole[5].suit = "d"
self.p0.hole[5].value = 5
self.p0.hole[6].suit = "d"
self.p0.hole[6].value = 4
self.p1.hole[0].suit = "d"
self.p1.hole[1].suit = "d"
self.p1.hole[0].value = 14
self.p1.hole[1].value = 13
self.p1.hole[2].value = 12
self.p1.hole[3].value = 11
self.p1.hole[4].value = 10
players = self.analyzer._order(players)
self.analyzer._flush(players)
self.assertTrue(self.p0.hand)
self.assertEqual(self.p0.hand[0], 5)
self.assertEqual(len(self.p0.hand), 6)
# p1 should be a straight flush
expected = [8, 14]
self.assertEqual(self.p1.hand, expected)
def test_order(self):
"""Can we order the hands in a proper order, left to right"""
players = self.analyzer._setup()
players = self.analyzer._order(players)
for player in players:
for i in range(6):
v1 = player.hole[i].value
v2 = player.hole[i + 1].value
self.assertTrue(v2 <= v1)
def test_seven_cards(self):
"""Can we get a list of players in the hand with 7 cards in the hand"""
players = self.analyzer._setup()
for player in players:
self.assertTrue(len(player.hole) == 7)