Ejemplo n.º 1
0
 def test_each_gamemode_is_valid(self):
     game_modes_found = set()
     map(game_modes_found.update, GAME_MODES_BY_MAP_ID.values())
     self.assertSetEqual(set(GAME_MODES_NAMES.keys()), game_modes_found)
     for game_mode in game_modes_found:
         self.assertIn(game_mode, GAME_MODES_NAMES)
Ejemplo n.º 2
0
        port = int(self.address.split(':')[1])
        with closing(Frostbite1Connection(self.console, host, port)) as t_conn:
            return t_conn.sendRequest(('serverInfo', ))[1:]

    @ServerInfo.data.setter
    def data(self, value):
        try:
            self._data = Bf3Parser.decodeServerinfo(value)
        except Exception, err:
            self.console.error(err)
            self._data = None
        else:
            self._data['map'] = bf3_MAP_NAME_BY_ID.get(self.data['level'],
                                                       self.data['level'])
            del self._data['level']
            self._data['gamemode'] = bf3_GAME_MODES_NAMES.get(
                self.data['gamemode'], self.data['gamemode'])
            self._data['address'] = self.address
            self._data['name'] = self._data['serverName']
            del self._data['serverName']
            self._data['players'] = self._data['numPlayers']
            del self._data['numPlayers']
            self._data['max_players'] = self._data['maxPlayers']
            del self._data['maxPlayers']
        self.console.verbose(repr(self._data))

    def update(self):
        self.console.info("Updating info for %r" % self)
        self._data = None
        self.info = None
        try:
            raw_data = self.frostbite_info()
Ejemplo n.º 3
0
 def test_each_gamemode_is_valid(self):
     game_modes_found = set()
     map(game_modes_found.update, GAME_MODES_BY_MAP_ID.values())
     self.assertSetEqual(set(GAME_MODES_NAMES.keys()), game_modes_found)
     for game_mode in game_modes_found:
         self.assertIn(game_mode, GAME_MODES_NAMES)
        host = self.address.split(':')[0]
        port = int(self.address.split(':')[1])
        with closing(Frostbite1Connection(self.console, host, port)) as t_conn:
            return t_conn.sendRequest(('serverInfo',))[1:]

    @ServerInfo.data.setter
    def data(self, value):
        try:
            self._data = Bf3Parser.decodeServerinfo(value)
        except Exception, err:
            self.console.error(err)
            self._data = None
        else:
            self._data['map'] = bf3_MAP_NAME_BY_ID.get(self.data['level'], self.data['level'])
            del self._data['level']
            self._data['gamemode'] = bf3_GAME_MODES_NAMES.get(self.data['gamemode'], self.data['gamemode'])
            self._data['address'] = self.address
            self._data['name'] = self._data['serverName']
            del self._data['serverName']
            self._data['players'] = self._data['numPlayers']
            del self._data['numPlayers']
            self._data['max_players'] = self._data['maxPlayers']
            del self._data['maxPlayers']
        self.console.verbose(repr(self._data))

    def update(self):
        self.console.info("Updating info for %r" % self)
        self._data = None
        self.info = None
        try:
            raw_data = self.frostbite_info()