Beispiel #1
0
 def load(self):
     gameMap = GameMap.getGameMap(self.mapId)
     self.game = Game(self.id, self.name, gameMap, self.myNickName)
     serverSocket.write(
         pickle.dumps({
             'action': 'getGameMemberInfo',
             'game_id': self.id
         }))
     serverSocket.flush()
Beispiel #2
0
 def _quitGame(self):
     message = {'type': 'quit'}
     self.connectionManager.broadcast(message)
     message = {
         'action': 'quitGameReq',
         'game_id': self.gameId,
         'player_id': self.connectionManager.player
     }
     serverSocket.write(pickle.dumps(message))
     serverSocket.flush()
Beispiel #3
0
 def createGame(self):
     print 'create game'
     for country in xrange(1, self.gameMap.countries + 1):
         self.gameMap.army[country] = random.randint(Game.INIT_ARMY_MAX * 0.8, Game.INIT_ARMY_MAX * 1.2)
     if serverSocket.state() != QAbstractSocket.ConnectedState:
         serverSocket.waitForConnected()
     message = {'action': 'createGameReq',
                'gameName': self.gameName, 'mapName': self.gameMap.mapId,
                'playerName': self.myNickName,
                'ip': serverSocket.localAddress().toString(), 'port': nodeServer.serverPort()}
     serverSocket.write(pickle.dumps(message))
Beispiel #4
0
    def joinGame(self):
        print 'join game'
        # workaround this function also being called when creating game
        for player in self.players:
            if player.id == -1: return

        if serverSocket.state() != QAbstractSocket.ConnectedState:
            serverSocket.waitForConnected()
        message = {'action': 'joinGameReq', 'game_id': self.gameId,
                   'playerName': self.myNickName,
                   'ip': serverSocket.localAddress().toString(), 'port': nodeServer.serverPort()}
        serverSocket.write(pickle.dumps(message))
        QTimer.singleShot(5000, self._checkJoined)
Beispiel #5
0
 def createGame(self):
     print 'create game'
     for country in xrange(1, self.gameMap.countries + 1):
         self.gameMap.army[country] = random.randint(
             Game.INIT_ARMY_MAX * 0.8, Game.INIT_ARMY_MAX * 1.2)
     if serverSocket.state() != QAbstractSocket.ConnectedState:
         serverSocket.waitForConnected()
     message = {
         'action': 'createGameReq',
         'gameName': self.gameName,
         'mapName': self.gameMap.mapId,
         'playerName': self.myNickName,
         'ip': serverSocket.localAddress().toString(),
         'port': nodeServer.serverPort()
     }
     serverSocket.write(pickle.dumps(message))
Beispiel #6
0
    def joinGame(self):
        print 'join game'
        # workaround this function also being called when creating game
        for player in self.players:
            if player.id == -1: return

        if serverSocket.state() != QAbstractSocket.ConnectedState:
            serverSocket.waitForConnected()
        message = {
            'action': 'joinGameReq',
            'game_id': self.gameId,
            'playerName': self.myNickName,
            'ip': serverSocket.localAddress().toString(),
            'port': nodeServer.serverPort()
        }
        serverSocket.write(pickle.dumps(message))
        QTimer.singleShot(5000, self._checkJoined)
Beispiel #7
0
 def _quitGame(self):
     message = {'type': 'quit'}
     self.connectionManager.broadcast(message)
     message = {'action': 'quitGameReq', 'game_id': self.gameId, 'player_id': self.connectionManager.player}
     serverSocket.write(pickle.dumps(message))
     serverSocket.flush()
 def load(self):
     self.games = {}
     serverSocket.write(pickle.dumps({'action': 'getGameInfo'}))
     serverSocket.flush()
Beispiel #9
0
 def load(self):
     gameMap = GameMap.getGameMap(self.mapId)
     self.game = Game(self.id, self.name, gameMap, self.myNickName)
     serverSocket.write(pickle.dumps({'action': 'getGameMemberInfo', 'game_id': self.id}))
     serverSocket.flush()
 def load(self):
     self.games = {}
     serverSocket.write(pickle.dumps({'action': 'getGameInfo'}))
     serverSocket.flush()