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


Python GameState.nextDealer方法代码示例

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


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

示例1: players

# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import nextDealer [as 别名]

#.........这里部分代码省略.........
  #   socket - socket for client
  #   tokens - tokens of message from client
  # Notes:
  #   Also starts game when all players have registered.
  #   Should this be changed??
  #
  def processClientMessage(self, socket, tokens):
    
    if tokens[0] == 'LOGOUT':
      self.logoutPlayer(socket)
      
    elif self.state == 'REGISTRATION' or self.state == 'RESTART':
      print "Registration state."
      
      if tokens[0] == 'LOGIN':
        print 'Login: ', tokens[1]
        
        self.loginPlayer(socket, tokens[1])
        
        if self.numReadyPlayers == self.numPlayers:
          print "Players Ready."

          # if new game
          if self.state == 'REGISTRATION':
            self.playGame(0, -1)

          else: # restarting interrupted game
            scores = self.gameState.currentScores()
            
            for i in range(self.numPlayers):
              self.players[i].score = scores[i]
              
            self.playGame( self.gameState.numHands(),
                           self.gameState.nextDealer())
          raise 'End server'
    else:
      print 'Error'
      socket.send('ERROR Unknown\n')

  #
  # logs out player
  # Parameter:
  #   socket - socket of player
  #
  def logoutPlayer( self, socket ):
    
    player = findPlayer(socket)
    
    if player is not None:
      i = self.players.index(player)
      del self.players[i]
      player.sendMessage('OK')
    else:
      socket.send('ERROR\n')

  #
  # broadcast a message to all players
  # Parameter:
  #   msg - text of message
  #
  def broadcastMessage( self, msg ):
    for player in self.players:
      player.sendMessage(msg)

  #
  # make a list of numbers of tricks for each hand
开发者ID:SeanCCarter,项目名称:ohell,代码行数:70,代码来源:server.py


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