當前位置: 首頁>>代碼示例>>Python>>正文


Python GameState.currentScores方法代碼示例

本文整理匯總了Python中GameState.currentScores方法的典型用法代碼示例。如果您正苦於以下問題:Python GameState.currentScores方法的具體用法?Python GameState.currentScores怎麽用?Python GameState.currentScores使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GameState的用法示例。


在下文中一共展示了GameState.currentScores方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: players

# 需要導入模塊: import GameState [as 別名]
# 或者: from GameState import currentScores [as 別名]

#.........這裏部分代碼省略.........
      tokens = string.split(data)
      return tokens

  #
  # process message from client
  # Parameters:
  #   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
  #
開發者ID:SeanCCarter,項目名稱:ohell,代碼行數:70,代碼來源:server.py


注:本文中的GameState.currentScores方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。