本文整理汇总了Python中game_state.GameState.keep方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.keep方法的具体用法?Python GameState.keep怎么用?Python GameState.keep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game_state.GameState
的用法示例。
在下文中一共展示了GameState.keep方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPlayer
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import keep [as 别名]
class TestPlayer(TestCase):
def setUp(self):
self.player = Player()
json_string = open('pelda.json').read()
self.pelda = json.loads(json_string)
self.state = GameState(self.pelda)
def test_keep(self):
self.assertEqual(240, self.state.keep())
def test_first_round(self):
self.assertEqual(500,self.player.betRequest(self.pelda))
def test_first_round_nopair_a(self):
self.pelda["players"][1]["hole_cards"][0]["rank"] = "A"
self.assertEqual(400,self.player.betRequest(self.pelda))
def test_second_round(self):
self.pelda[u"bet_index"] = 1
self.assertEqual(240,self.player.betRequest(self.pelda))
def test_JJ_preflop(self):
state = json.loads(open('prefloptest.json').read())
self.assertEqual(500, self.player.betRequest(state))
def test_get_highest_rank(self):
self.state = GameState(self.pelda)
self.assertEqual('K',self.state.get_highest_rank())
self.pelda["players"][1]["hole_cards"][0]["rank"] = "A"
self.assertEqual('A',self.state.get_highest_rank())
self.pelda["players"][1]["hole_cards"][0]["rank"] = "7"
self.assertEqual('K',self.state.get_highest_rank())
self.pelda["players"][1]["hole_cards"][1]["rank"] = "J"
self.assertEqual('J',self.state.get_highest_rank())
def test_if_we_have_pairs(self):
self.state = GameState(self.pelda)
self.assertTrue(self.state.have_pair_in_hand())
def test_in_command(self):
assert( {u'rank': u'4', u'suit': u'spades'} in [ {u'rank': u'4', u'suit': u'spades'} ] )
assert( not {u'rank': u'4', u'suit': u'spades'} in [ {u'rank': u'4', u'suit': u'hearts'} ] )