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


Python Hand.receive方法代码示例

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


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

示例1: NormalPlayer

# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import receive [as 别名]
class NormalPlayer(Player):
    '''This class corresponds to normal players in the table'''
    def __init__(self, hand=None, money=0, name = "Stranger"):
        Player.__init__(self, hand, money, name)
        self._issplit=False

    def startMatch(self,cards):
        self._hand=Hand(cards)

    def hasEnoughToBet(self,bet=0):
        '''Check whether a player has enough to bet'''
        return self.money()>=bet

    def isSplit(self):
        '''Check whether the player has split.'''
        return self._issplit

    def extraChips(self,dollar):
        ''' extraChips(int) -> None -- Receive dollar worth of money'''
        assert(dollar >= 0)
        self._money += dollar

    def updateAfterDouble(self,card,bet=0):
        '''Updates player's instance after doubling and makes sure player has enough'''
        try:
            if self.hasEnoughToBet(int(bet)):
                self._money-=bet
                self._hand.receive(card)
            else:
                print("Not enough money to double")
        except ValueError:
            print ("Bet is not an integer")

    def updateAfterSplit(self,bet=0):
        '''Updates player after he split his pair. Creates an alternative hand'''
        try:
            if self.hasEnoughToBet(int(bet)):
                self._money-=bet
                self._secondhand = self._hand.split()
                self._issplit=True
            else:
                print("Not enough money to double")
        except ValueError:
            print ("Bet is not an integer")

    def updateAfterSecondHit(self):
        pass

    def updateAfterBet(self,bet=0):
        '''Updates player's money after betting and makes sure player has enough'''
        try:
            if self.hasEnoughToBet(int(bet)):
                self.money-=bet
            else:
                print("Not enough money to bet")
        except ValueError:
            print ("Bet is not an integer")
开发者ID:JeromeLefebvre,项目名称:CardsForTheWorkingMathematician,代码行数:59,代码来源:player.py

示例2: Dealer

# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import receive [as 别名]
class Dealer(Player):
    '''This class corresponds to the dealer. We assign no money to it and interpret
    its money as wins or losses for the house'''
    def __init__(self, hand=None):
        Player.__init__(self, hand, 0, "Dealer")

    def startMatch(self,cards,withholecard=True):
        '''Deals initial cards to the dealer'''
        if withholecard:
            self._hand=Hand(cards[0])
            self._holecard=cards[1]
        else:
            self._hand=Hand(cards)

    def flipHoleCard(self):
        '''Adds the holecard to the hand'''
        self._hand.receive(self._holecard)
开发者ID:JeromeLefebvre,项目名称:CardsForTheWorkingMathematician,代码行数:19,代码来源:player.py


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