Пример #1
0
    def getRetrainingData(self, targetVehicle, callback):
        items = self.itemsCache.items
        tankman = items.getTankman(self.tmanInvID)
        nativeVehicleCD = tankman.vehicleNativeDescr.type.compactDescr
        criteria = REQ_CRITERIA.NATIONS([
            tankman.nationID
        ]) | REQ_CRITERIA.UNLOCKED | ~REQ_CRITERIA.VEHICLE.OBSERVER
        if not constants.IS_IGR_ENABLED:
            criteria |= ~REQ_CRITERIA.VEHICLE.IS_PREMIUM_IGR
        if constants.IS_DEVELOPMENT:
            criteria |= ~REQ_CRITERIA.VEHICLE.IS_BOT
        vData = items.getVehicles(criteria)
        tDescr = tankman.descriptor
        vehiclesData = vData.values()
        if nativeVehicleCD not in vData:
            vehiclesData.append(items.getItemByCD(nativeVehicleCD))
        result = []
        for vehicle in sorted(vehiclesData):
            vDescr = vehicle.descriptor
            for role in vDescr.type.crewRoles:
                if tDescr.role == role[0]:
                    result.append({
                        'intCD': vehicle.intCD,
                        'vehicleType': vehicle.type,
                        'userName': vehicle.shortUserName
                    })
                    break

        callback({
            'vehicles': result,
            'retrainButtonsData': packTraining(targetVehicle, [tankman])
        })
Пример #2
0
 def __getRetrainButtonsEnableFlags(self):
     vehicle = self.itemsCache.items.getVehicle(
         self._currentVehicleInvId
     ) if self._currentVehicleInvId is not None else None
     return [
         option['enabled'] for option in reversed(packTraining(vehicle))
     ]
    def getRetrainingData(self, targetVehicle, callback):
        items = self.itemsCache.items
        tankman = items.getTankman(self.tmanInvID)
        nativeVehicleCD = tankman.vehicleNativeDescr.type.compactDescr
        maxResearchedLevel = items.stats.getMaxResearchedLevel(tankman.nationID)
        criteria = ~(~REQ_CRITERIA.UNLOCKED | ~(REQ_CRITERIA.COLLECTIBLE | REQ_CRITERIA.VEHICLE.LEVELS(range(1, maxResearchedLevel + 1))))
        criteria |= REQ_CRITERIA.NATIONS([tankman.nationID]) | ~REQ_CRITERIA.VEHICLE.OBSERVER
        criteria |= ~REQ_CRITERIA.VEHICLE.IS_CREW_LOCKED
        criteria |= ~(REQ_CRITERIA.SECRET | ~REQ_CRITERIA.INVENTORY_OR_UNLOCKED)
        criteria |= ~REQ_CRITERIA.VEHICLE.BATTLE_ROYALE
        criteria |= ~REQ_CRITERIA.VEHICLE.MAPS_TRAINING
        if not constants.IS_IGR_ENABLED:
            criteria |= ~REQ_CRITERIA.VEHICLE.IS_PREMIUM_IGR
        if constants.IS_DEVELOPMENT:
            criteria |= ~REQ_CRITERIA.VEHICLE.IS_BOT
        vData = items.getVehicles(criteria)
        tDescr = tankman.descriptor
        vehiclesData = vData.values()
        if nativeVehicleCD not in vData:
            vehiclesData.append(items.getItemByCD(nativeVehicleCD))
        result = []
        for vehicle in sorted(vehiclesData):
            vDescr = vehicle.descriptor
            for role in vDescr.type.crewRoles:
                if tDescr.role == role[0]:
                    result.append({'intCD': vehicle.intCD,
                     'vehicleType': vehicle.type,
                     'userName': vehicle.shortUserName})
                    break

        callback({'vehicles': result,
         'retrainButtonsData': packTraining(targetVehicle, [tankman])})
    def __updateDataCallBack(self, data=None):
        items = self.itemsCache.items
        shopPrices, _ = items.shop.getTankmanCostWithDefaults()
        skillValues = []
        for cost in shopPrices:
            minValue = maxValue = cost['roleLevel']
            baseRolleLoss = cost['baseRoleLoss']
            classChangeRoleLoss = cost['classChangeRoleLoss']
            for tankman in self.__crew:
                currentRoleLevel = tankman.roleLevel
                if tankman.areClassesCompatible:
                    roleValue = currentRoleLevel - currentRoleLevel * classChangeRoleLoss
                else:
                    roleValue = currentRoleLevel - currentRoleLevel * baseRolleLoss
                if roleValue > maxValue:
                    maxValue = int(round(roleValue))

            skillValues.append((minValue, maxValue))

        data = {'credits': items.stats.credits,
         'gold': items.stats.gold,
         'tankmanCost': shopPrices,
         'retrainButtons': packTraining(self.__vehicle, self.__crew)}
        self.as_setCrewOperationDataS(data)