Python 纸牌游戏中的分数更新

Python 纸牌游戏中的分数更新,python,playing-cards,Python,Playing Cards,我完全是python的初学者 我需要帮助更新纸牌游戏的分数 评分工作如下: 玩家A或B有一对:分数+=1 玩家A向玩家B(反之亦然)索要一张牌,而该玩家拥有该牌:得分+=1 玩家B没有,玩家A必须抽一张牌。如果抽签后有配对:得分+=2 我有逻辑,但我真的不知道如何连接起来 我尝试在我的函数中手动添加分数,但它变得混乱和复杂:( 我假设我必须为分数创建一个新函数,并在其他函数中调用它们 我将感谢您的指导 谢谢!以下是一些帮助您入门的代码: class Player: def hasPair(s

我完全是python的初学者

我需要帮助更新纸牌游戏的分数

评分工作如下:

玩家A或B有一对:分数+=1
玩家A向玩家B(反之亦然)索要一张牌,而该玩家拥有该牌:得分+=1
玩家B没有,玩家A必须抽一张牌。如果抽签后有配对:得分+=2

我有逻辑,但我真的不知道如何连接起来

我尝试在我的函数中手动添加分数,但它变得混乱和复杂:(

我假设我必须为分数创建一个新函数,并在其他函数中调用它们

我将感谢您的指导


谢谢!

以下是一些帮助您入门的代码:

class Player:
  def hasPair(self):
    haveIt = False
    #write logic here to see if you have it
    return haveIt
  def hasCard(self,card):
    haveIt = False
    #write logic here to see if this player has the card
    return haveIt
  def drawCard(self):
    #write logic here
    pass
  def ask(self,player,card):
    return player.hasCard(card)
  def increment_score(self,by=1):
    self.score += by

def updateScores(a,b,card):        
  if a.hasPair(): a.increment_score()
  if b.hasPair(): b.increment_score()
  if a.ask(b,card): 
    a.increment_score()
  else:
    a.drawCard()
    if a.hasPair(): a.increment_score(2)
  if b.ask(a,card):
    b.increment_score()
  else:
    b.drawCard()
    if b.hasPair(): b.increment_score(2)    

请发布你已经拥有的代码,这样我们可以(a)更好地理解你想要实现的目标,(b)帮助你,而不必重写你已经完成的一切。