Exemplo n.º 1
0
def _CarouselDataProvider_vehicleComparisonKey(base, cls, vehicle):
    try:
        global carousel_config
        if not 'sorting_criteria' in carousel_config:
            return base(vehicle)

        comparisonKey = [
            not vehicle.isEvent,
            not vehicle.isFavorite]

        for sort_criterion in carousel_config['sorting_criteria']:
            if sort_criterion.find('-') == 0:
                sort_criterion = sort_criterion[1:] #remove minus sign
                factor = -1
            else:
                factor = 1

            if sort_criterion in ['winRate', 'markOfMastery']:
                itemsCache = dependency.instance(IItemsCache)
                vehicles_stats = itemsCache.items.getAccountDossier().getRandomStats().getVehicles() # battlesCount, wins, markOfMastery, xp
                stats = vehicles_stats.get(vehicle.intCD)
                comparisonKey.append(factor if stats else 0)
                if stats:
                    if sort_criterion == 'winRate':
                        comparisonKey.append(float(stats.wins) / stats.battlesCount * factor)
                    elif sort_criterion == 'markOfMastery':
                        comparisonKey.append(stats.markOfMastery * factor)
            elif sort_criterion in ['wtr', 'xtdb', 'xte', 'marksOnGun', 'damageRating']:
                vDossier = dossier.getDossier(PROFILE_DROPDOWN_KEYS.ALL, None, vehicle.intCD)
                comparisonKey.append(factor if vDossier else 0)
                if vDossier:
                    comparisonKey.append(vDossier[sort_criterion] * factor)
            elif sort_criterion == 'nation':
                if 'nations_order' in carousel_config and len(carousel_config['nations_order']):
                    custom_nations_order = carousel_config['nations_order']
                    comparisonKey.append(vehicle.nationName not in custom_nations_order)
                    if vehicle.nationName in custom_nations_order:
                        comparisonKey.append(custom_nations_order.index(vehicle.nationName))
                comparisonKey.append(GUI_NATIONS_ORDER_INDEX[vehicle.nationName])
            elif sort_criterion == 'type':
                if 'types_order' in carousel_config and len(carousel_config['types_order']):
                    custom_types_order = carousel_config['types_order']
                    comparisonKey.append(vehicle.type not in custom_types_order)
                    if vehicle.type in custom_types_order:
                        comparisonKey.append(custom_types_order.index(vehicle.type))
                comparisonKey.append(VEHICLE_TYPES_ORDER_INDICES[vehicle.type])
            elif sort_criterion == 'premium':
                comparisonKey.append(int(not vehicle.isPremium) * factor)
            elif sort_criterion == 'level':
                comparisonKey.append(vehicle.level * factor)
            elif sort_criterion == 'maxBattleTier':
                comparisonKey.append(getTiers(vehicle.level, vehicle.type, vehicle.name)[1] * factor)

        comparisonKey.extend([vehicle.buyPrices.itemPrice.price.gold, vehicle.buyPrices.itemPrice.price.credits, vehicle.userName])

        return tuple(comparisonKey)

    except Exception as ex:
        err(traceback.format_exc())
Exemplo n.º 2
0
def carousel_data_provider_vehicleComparisonKey(base, vehicle):
    try:
        global carousel_config
        if not 'sorting_criteria' in carousel_config:
            return base(vehicle)

        comparisonKey = [
            not vehicle.isEvent,
            not vehicle.isFavorite]

        for sort_criterion in carousel_config['sorting_criteria']:
            if sort_criterion.find('-') == 0:
                sort_criterion = sort_criterion[1:] #remove minus sign
                factor = -1
            else:
                factor = 1

            if sort_criterion in ['winRate', 'markOfMastery']:
                vehicles_stats = g_itemsCache.items.getAccountDossier().getRandomStats().getVehicles() # battlesCount, wins, markOfMastery, xp
                stats = vehicles_stats.get(vehicle.intCD)
                comparisonKey.append(factor if stats else 0)
                if stats:
                    if sort_criterion == 'winRate':
                        comparisonKey.append(float(stats.wins) / stats.battlesCount * factor)
                    elif sort_criterion == 'markOfMastery':
                        comparisonKey.append(stats.markOfMastery * factor)
            elif sort_criterion in ['xtdb', 'xte', 'marksOnGun', 'damageRating']:
                vDossier = dossier.getDossier((PROFILE_DROPDOWN_KEYS.ALL, None, vehicle.intCD))
                comparisonKey.append(factor if vDossier else 0)
                if vDossier:
                    comparisonKey.append(vDossier[sort_criterion] * factor)
            elif sort_criterion == 'nation':
                if 'nations_order' in carousel_config and len(carousel_config['nations_order']):
                    custom_nations_order = carousel_config['nations_order']
                    comparisonKey.append(vehicle.nationName not in custom_nations_order)
                    if vehicle.nationName in custom_nations_order:
                        comparisonKey.append(custom_nations_order.index(vehicle.nationName))
                comparisonKey.append(GUI_NATIONS_ORDER_INDEX[vehicle.nationName])
            elif sort_criterion == 'type':
                if 'types_order' in carousel_config and len(carousel_config['types_order']):
                    custom_types_order = carousel_config['types_order']
                    comparisonKey.append(vehicle.type not in custom_types_order)
                    if vehicle.type in custom_types_order:
                        comparisonKey.append(custom_types_order.index(vehicle.type))
                comparisonKey.append(VEHICLE_TYPES_ORDER_INDICES[vehicle.type])
            elif sort_criterion == 'premium':
                comparisonKey.append(int(not vehicle.isPremium) * factor)
            elif sort_criterion == 'level':
                comparisonKey.append(vehicle.level * factor)
            elif sort_criterion == 'maxBattleTier':
                comparisonKey.append(getTiers(vehicle.level, vehicle.type, vehicle.name)[1] * factor)

        comparisonKey.extend([vehicle.buyPrice.gold, vehicle.buyPrice.credits, vehicle.userName])

        return tuple(comparisonKey)

    except Exception as ex:
        err(traceback.format_exc())
Exemplo n.º 3
0
def ProfileTechnique_receiveVehicleDossier(base, self, vehCD, accountDBID):
    global _lastVehCD
    _lastVehCD = vehCD
    base(self, vehCD, accountDBID)
    _lastVehCD = None

    if config.networkServicesSettings.statAwards:
        if self._isDAAPIInited():
            vDossier = dossier.getDossier((self._battlesType, accountDBID, vehCD))
            self.flashObject.as_responseVehicleDossierXvm(vDossier)
Exemplo n.º 4
0
def ProfileTechnique_receiveVehicleDossier(base, self, vehId, playerId):
    global _lastVehId
    _lastVehId = vehId
    base(self, vehId, playerId)
    _lastVehId = None

    if token.networkServicesSettings['statAwards']:
        if self._isDAAPIInited():
            vDossier = dossier.getDossier((self._battlesType, playerId, vehId))
            self.flashObject.as_responseVehicleDossierXvm(vDossier)
Exemplo n.º 5
0
def ProfileTechnique_receiveVehicleDossier(base, self, vehCD, accountDBID):
    global _lastVehCD
    _lastVehCD = vehCD
    base(self, vehCD, accountDBID)
    _lastVehCD = None

    if config.networkServicesSettings.statAwards:
        if self._isDAAPIInited():
            vDossier = dossier.getDossier(self._battlesType, accountDBID, vehCD)
            self.flashObject.as_responseVehicleDossierXvm(vDossier)
Exemplo n.º 6
0
def ProfileTechnique_getTechniqueListVehicles(base, self, targetData, addVehiclesThatInHangarOnly = False):
    res = base(self, targetData, addVehiclesThatInHangarOnly)
    if config.networkServicesSettings.statAwards:
        global _lastAccountDBID
        for x in res:
            try:
                vehCD = x['id']
                vDossier = dossier.getDossier((self._battlesType, _lastAccountDBID, vehCD))
                x['xvm_xte'] = int(vDossier['xte']) if vDossier is not None else -1
                x['xvm_xte_flag'] = 0
            except:
                err(traceback.format_exc())
    return res
Exemplo n.º 7
0
def ProfileTechnique_getTechniqueListVehicles(base, self, targetData, addVehiclesThatInHangarOnly = False):
    res = base(self, targetData, addVehiclesThatInHangarOnly)
    if config.networkServicesSettings.statAwards:
        global _lastAccountDBID
        for x in res:
            try:
                vehCD = x['id']
                vDossier = dossier.getDossier(self._battlesType, _lastAccountDBID, vehCD)
                x['xvm_xte'] = int(vDossier['xte']) if vDossier is not None else -1
                x['xvm_xte_flag'] = 0
            except:
                err(traceback.format_exc())
    return res