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


Python GameState.numHands方法代碼示例

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


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

示例1: players

# 需要導入模塊: import GameState [as 別名]
# 或者: from GameState import numHands [as 別名]
class OhHellServer:
  """
  Oh Hell server class
 
  Attributes:
    serverAddress
      address of server

    serverPort
      port server is listening on

    serverSocket
      socket that server uses for listening to incoming connections

    sockets
      list of all sockets maintained by server

    players
      list of players (Player instances)

    numReadyPlayers
      number of players ready to play

    numPlayers
      number of players in game

    state
      state of game, one of:
        REGISTRATION - new game, waiting for all players to register
        RESTART      - recovering and restarting old game, waiting for players
        PLAYING      - game is under way

    gameState
      state of the game, really a history of the hands

    trickNums
      a list of the num of tricks for each hand to play

    numHands
      how many hands to play

    handNum
      the number of the current hand

    dealer
      the index of the dealer for the current hand

    trump
      the trump for the current hand

    deck
      the deck of cards for the current hand
  """
  
  def __init__(self, port = 7000):
    """
    Constructor
    Parameter:
      port - TCP port for server to listen on
    """
    self.serverAddress = ''
    self.serverPort = port
    self.players = []
    self.numReadyPlayers = 0

  #
  # start a brand new game
  # Parameter:
  #   numPlayers - number of players in game
  #
  def newGame( self, numPlayers ):
    
    print 'New Game of', numPlayers, 'players'
    
    self.gameState = GameState()
    self.gameState.init_new(numPlayers, now())
    
    self.state = 'REGISTRATION'
    self.findXMLFileName()
    self.mainloop(numPlayers)

  #
  # restart a game
  # Parameter:
  #   fileName - name of file with state of old game (in XML)
  #
  def restart( self, fileName ):
    parser = GameXMLParser()
    self.xmlFileName = fileName
    self.gameState = parser.parse(fileName)
    self.incomingPlayers = self.gameState.getPlayers()
    
    for p in self.incomingPlayers:
      self.players.append( Player(None, p[1]) )
      
    self.state = 'RESTART'
    self.mainloop(len(self.incomingPlayers))
      
  #
  # the main loop for the game
#.........這裏部分代碼省略.........
開發者ID:SeanCCarter,項目名稱:ohell,代碼行數:103,代碼來源:server.py


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