本文整理汇总了Python中hand.Hand.clear方法的典型用法代码示例。如果您正苦于以下问题:Python Hand.clear方法的具体用法?Python Hand.clear怎么用?Python Hand.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hand.Hand
的用法示例。
在下文中一共展示了Hand.clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Player
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import clear [as 别名]
class Player(object):
def __init__(self, chips=100):
self.chips = chips
self.hand = Hand()
def _subtract_chips(self, amt):
if self.chips >= amt:
self.chips -= amt
else:
raise StandardError("Not enough chips")
def clear_hand(self):
self.hand.clear()
def bet(self, amt):
self._subtract_chips(amt)
def add_card(self, card):
self.hand.add_card(card)
示例2: Player
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import clear [as 别名]
class Player(object):
HUMAN = 1
COMPUTER = 0
def __init__(self,name,tyyppi):
self.__name=name
self.__cottages=0
self.__points=0
self.__hand = Hand()
self.__type = tyyppi
self.__stack = Hand()
'''
name methods
'''
def getName(self):
return self.__name
'''
point methods
'''
def updatePoints(self,amount):
self.__points += amount
def setPoints(self,amount):
self.__points = amount
def getPoints(self):
return self.__points
'''
cottage methods
'''
def getCottages(self):
return self.__cottages
def raiseCottages(self,amount):
self.__cottages+=amount
def setCottages(self,amount):
self.__cottages=amount
def clearCottages(self):
self.__cottages=0
'''
hand methods
'''
def getHand(self):
return self.__hand
def addCardsToHand(self,cards):
self.__hand.addCards(cards)
def addCardToHand(self,card):
self.__hand.append(cards)
def setHand(self,cards):
self.__hand.clear()
self.__hand.addCards(cards)
def hasCards(self):
return len(self.__hand.getCards())>0
'''
stack methods
'''
def getStack(self):
return self.__stack
def clearStack(self):
self.__stack=Hand()
def addCardsToStack(self,cards):
for card in cards:
self.addCardToStack(card)
def addCardToStack(self,card):
self.__stack.addCard(card)
def setStack(self,cards):
self.__stack.clear()
self.__stack.addCards(cards)
'''
type methods
'''
def getType(self):
return self.__type
'''
other methods
'''
def getScoreFromStack(self):
points = self.__cottages
points += self.__stack.getSureValue()
return points
def __str__(self):
return self.__name+"-"+str(self.__points)
#.........这里部分代码省略.........