本文整理汇总了Python中GameState.getPlayers方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.getPlayers方法的具体用法?Python GameState.getPlayers怎么用?Python GameState.getPlayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameState
的用法示例。
在下文中一共展示了GameState.getPlayers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: players
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import getPlayers [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
#.........这里部分代码省略.........