コード例 #1
0
 def close(self):
     """remove all players and close the sever's socket"""
     for spectator in self.spectators:
         spectator.close()
     
     for player in self.players:
         player.close()
     
     Server.close(self)
コード例 #2
0
 def __init__(self, *args, **kwargs):
     Server.__init__(self, *args, **kwargs)
     self.player_name_count = 0
     self.player_positions_ready = {
         PlayerPositions.PLAYER1 : False,
         PlayerPositions.PLAYER2 : False
     }
     self.player_movesets = {
         PlayerPositions.PLAYER1 : "one attack", 
         PlayerPositions.PLAYER2 : "one attack"
     }
     self.player_data = {
         PlayerPositions.PLAYER1 : versusmode.PlayerData(
             PlayerPositions.PLAYER1,
             PlayerTypes.BOT,
             "one attack",
             5,
             (255,0,0),
             Difficulties.CHALLENGE
         ), 
         PlayerPositions.PLAYER2 : versusmode.PlayerData(
             PlayerPositions.PLAYER2,
             PlayerTypes.BOT,
             "one attack",
             5,
             (0,0,255),
             Difficulties.CHALLENGE
         )
     }
     self.dummies = {
         PlayerPositions.PLAYER1 : DummyChannel(self.player_data[PlayerPositions.PLAYER1], self), 
         PlayerPositions.PLAYER2 : DummyChannel(self.player_data[PlayerPositions.PLAYER2], self)
     }
     self.player_positions = {
         PlayerPositions.PLAYER1 : self.dummies[PlayerPositions.PLAYER1], 
         PlayerPositions.PLAYER2 : self.dummies[PlayerPositions.PLAYER2]
     }
     
     #indicates that point position data has been received by players in the match
     #this ensures that models are ready to be drawn at each client.
     self.all_movesets_loaded_indicators = {
         PlayerPositions.PLAYER1 : False, 
         PlayerPositions.PLAYER2 : False
     }
     
     self.players = []
     self.spectators = []
     self.mode = ServerModes.MOVESET_SELECT
     
     print 'server started!'