当前位置: 首页>>代码示例>>Python>>正文


Python Hand.hole_cards方法代码示例

本文整理汇总了Python中hand.Hand.hole_cards方法的典型用法代码示例。如果您正苦于以下问题:Python Hand.hole_cards方法的具体用法?Python Hand.hole_cards怎么用?Python Hand.hole_cards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hand.Hand的用法示例。


在下文中一共展示了Hand.hole_cards方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_single_hand

# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import hole_cards [as 别名]
    def read_single_hand(self, file_in, active_player):
        """Reads the components of a PokerStars hand in a PoserStars text file and returns them in a Hand object.
            The current position of the file must me that the next file_in.readline() will return the first line of
            the hand to read.
            The active_player provided must be the one that the hole cards are shown in the file, or the function
            will return an error.

        Args:
            file_in (File) : The PokerStars hand text file we are working on, already opened by the master function.
            active_player (Player) : The active player in the file (the one we know the hole cards)

        Returns:
            (Hand) : A complete Hand object containing the information gathered.
        """

        stack = -1  # Temporary variable used to get the active player chips from the txt file

        current_hand = Hand(0, 0, [Card(0, "c"), Card(0, "c")], 0)
        try:
            [
                current_hand.handNumber,
                current_hand.tournamentNumber,
                current_hand.timeStarted,
            ] = self.read_hand_starting_line(file_in.readline())

            # TODO: Change the function so it reads the number of seats at the table, and not always 9 seats
            while True:
                file_position = file_in.tell()
                stack = self.read_hand_seat_line(file_in.readline(), active_player)
                if stack == -1:  # Done reading hand seat lines
                    file_in.seek(file_position)
                    break

            while True:
                loss = self.read_blind_line(file_in.readline(), active_player)
                if loss == None:
                    break
                current_hand.loss += loss

            current_hand.hole_cards = self.read_hole_cards_line(file_in.readline(), active_player)

            while True:
                value = self.read_bet_line(file_in.readline(), active_player)
                if value == 0:
                    break
                elif value == None:
                    continue
                elif value < 0:
                    current_hand.loss += -value
                else:
                    current_hand.gain += value

            active_player.stack = stack

            return current_hand

        finally:
            a = 0
开发者ID:Bobsleigh,项目名称:FirePoker,代码行数:60,代码来源:pokertextfile.py


注:本文中的hand.Hand.hole_cards方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。