def _populateFilters(self, init = False): vehicles = yield Requester(self._VEHICLE).getFromInventory() oldStyleVehicle = None for v in vehicles: if v.inventoryId == g_currentVehicle.invID: oldStyleVehicle = v break filterVehicle = None if g_currentVehicle.isPresent(): filterVehicle = compactItem(oldStyleVehicle) filter = self._getCurrentFilter() if filter[1] in (self._MODULE, self._SHELL): filter = list(AccountSettings.getFilter(self.getName() + '_' + filter[1])) typeSize = int(filter.pop(0)) filterVehicle = filter[typeSize + 1] self.__clearSubFilter() self.__subFilter = {'current': filterVehicle, self._DATA_PROVIDER: []} vehicles.sort(reverse=True) for v in vehicles: filterElement = {'id': compactItem(v), 'nation': GUI_NATIONS_ORDER_INDEX[nations.NAMES[v.nation]], 'name': v.name} self.__subFilter[self._DATA_PROVIDER].append(filterElement) if init: lang, itemType = self._getCurrentFilter() self.__filterHash.update({'language': lang, 'type': itemType}) self.as_setFilterTypeS(self.__filterHash) self.as_setSubFilterS(self.__subFilter) if init: self._updateFilterOptions(self.__filterHash['type']) self.as_completeInitS() return
def __getCommonData(self, callback): results = None if self.arenaUniqueID: results = yield StatsRequester().getBattleResults(int(self.arenaUniqueID)) elif IS_DEVELOPMENT: results = self.testData yield lambda callback: callback(None) LOG_DEBUG('Player got battle results: ', self.arenaUniqueID, results) if results: from BattleReplay import g_replayCtrl g_replayCtrl.onExtendedBattleResultsReceived(results) personalData = results.get('personal', dict()).copy() playersData = results.get('players', dict()).copy() vehiclesData = results.get('vehicles', dict()).copy() commonData = results.get('common', dict()).copy() statsSorting = AccountSettings.getSettings('statsSorting') commonData['iconType'] = statsSorting.get('iconType') commonData['sortDirection'] = statsSorting.get('sortDirection') self.__populateResultStrings(commonData, personalData) self.__populatePersonalMedals(personalData) self.__populateArenaData(commonData, personalData) personalData['damageAssisted'] = personalData.get('damageAssistedTrack', 0) + personalData.get('damageAssistedRadio', 0) personalData['statValues'] = self.__populateStatValues(personalData, True) self.__populateAccounting(commonData, personalData) self.__populateTankSlot(commonData, personalData, vehiclesData, playersData) self.__populateEfficiency(personalData, vehiclesData, playersData) team1, team2 = self.__populateTeamsData(personalData, playersData, vehiclesData, commonData.get('bonusType', 0)) resultingVehicles = [] dailyXPFactor = 2 if False: try: multipliedXPVehs = yield StatsRequester().getMultipliedXPVehicles() vehicleTypeLocks = yield StatsRequester().getVehicleTypeLocks() globalVehicleLocks = yield StatsRequester().getGlobalVehicleLocks() dailyXPFactor = StatsRequester().getDailyXPFactor() or (yield 2) vehicles = yield Requester('vehicle').getFromInventory() def sorting(first, second): if first.isFavorite and not second.isFavorite: return -1 if not first.isFavorite and second.isFavorite: return 1 return first.__cmp__(second) vehicles.sort(sorting) vehiclesFiltered = [ vehicle for vehicle in vehicles if vehicle.descriptor.type.compactDescr not in multipliedXPVehs and vehicle.repairCost == 0 and vehicle.lock == 0 and None not in vehicle.crew and vehicle.crew != [] and not vehicleTypeLocks.get(vehicle.descriptor.type.compactDescr, {}).get(1, False) and not globalVehicleLocks.get(1, False) ] for vehicle in vehiclesFiltered: try: vehicleInfo = dict() vehicleInfo['inventoryId'] = vehicle.inventoryId vehicleInfo['label'] = vehicle.name vehicleInfo['selected'] = g_currentVehicle.invID == vehicle.inventoryId except Exception: LOG_ERROR("Exception while '%s' vehicle processing" % vehicle.descriptor.type.name) LOG_CURRENT_EXCEPTION() continue resultingVehicles.append(vehicleInfo) except Exception: LOG_CURRENT_EXCEPTION() callback({'personal': personalData, 'common': commonData, 'team1': team1, 'team2': team2, 'vehicles': resultingVehicles, 'dailyXPFactor': dailyXPFactor, 'quests': self.__parseQuestsProgress(personalData.get('questsProgress', {}))}) else: callback(None) return