def getShopAirplanesResponse(self, resultID, airplanesList=[]):
        if self.__shopAirplaneList is None:
            self.__shopAirplaneList = []
            for airplaneMap in airplanesList:
                airplane = getLobbyAirplane(airplaneMap['airplaneID'])
                airplane.price = airplaneMap['price']
                airplane.gold = airplaneMap['gold']
                airplane.isResearched = airplaneMap['isResearched']
                airplane.experience = airplaneMap['planeXP']
                airplane.modules = LobbyAirplaneModules(
                    airplaneMap['airplaneID'],
                    airplaneMap['defaultModulesList'])
                airplane.weapons = LobbyAirplaneWeapons(
                    airplaneMap['airplaneID'], None,
                    airplaneMap['defaultWeaponsMap'])
                airplane.isPremium = airplaneMap['isPremium']
                airplane.isElite = airplaneMap['isElite']
                if airplane is None:
                    LOG_ERROR('Airplane not found', airplaneMap['airplaneID'])
                    continue
                self.__shopAirplaneList.append(airplane)

        self.__shopAirplaneList.sort(
            key=operator.attrgetter('level', 'type', 'price'))
        airplaneASList = getAirplaneASList(self.__shopAirplaneList,
                                           SHOP_AIRPLANE)
        if self.__lobby.mode == HANGAR_MODE.STORE:
            self.__lobby.call_1('shop.updateShopPlanes', airplaneASList)
        return
    def getUpgradesList(self, callbacksList, planeID, reload3DModel):
        LOG_TRACE('getUpgradesList(planeID)', planeID)
        if self.__planeSelected is None and planeID is None:
            return
        else:
            aircraftID = planeID or self.__planeSelected.planeID
            upgradesList = self.inventory.getAircraftUpgradesData(aircraftID)
            installedWeapons = self.inventory.getSlotsConfiguration(aircraftID)
            slotsInfo = self.inventory.getAircraftInstalledWeaponsData(aircraftID)
            customPresetUpgrades = self.inventory.getCustomPreset(aircraftID)
            presetAvailableList = self.inventory.getAvailablePresets(aircraftID, True)
            installedPreset = self.inventory.getInstalledPreset(aircraftID)
            if planeID is not None:
                plane = self.getCarouselAirplane(planeID)
                if plane is None:
                    plane = getLobbyAirplane(planeID)
            else:
                plane = self.__planeSelected
            if plane is None or plane.planeID not in self.inventory.aircraftsData:
                LOG_ERROR('getUpgradesList() error', plane is None, plane is not None and plane.planeID not in self.inventory.aircraftsData)
                return
            plane.modules = LobbyAirplaneModules(plane.planeID, upgradesList)
            plane.weapons = LobbyAirplaneWeapons(plane.planeID, upgradesList, installedWeapons)
            plane.weapons.updateSlotsInfo(slotsInfo)
            plane.presets = LobbyAirplanePresets(plane.planeID, plane.modules, plane.weapons, customPresetUpgrades, presetAvailableList, installedPreset)
            plane.presets.fillPresets()
            plane.partTypes = plane.modules.getPartTypes()
            if planeID is None:
                if reload3DModel:
                    self.queryRefresh3DModel(self.__planeSelected)
                self.sendUpgradesListToAS()
            for callback in callbacksList:
                callback()

            return
Example #3
0
 def __getAircraftUpgradesInfoResponse(self, aircraftID):
     customPresetUpgrades = self.__lobbyCarouselHelper.inventory.getCustomPreset(aircraftID)
     presetAvailableList = self.__lobbyCarouselHelper.inventory.getAvailablePresets(aircraftID, True)
     installedPreset = self.__lobbyCarouselHelper.inventory.getInstalledPreset(aircraftID)
     if self.__lobby.mode == HANGAR_MODE.RESEARCH:
         airplane = self.__lobbyCarouselHelper.getCarouselAirplane(aircraftID)
         if not airplane:
             airplane = getLobbyAirplane(aircraftID)
         airplane.presets = LobbyAirplanePresets(airplane.planeID, airplane.modules, airplane.weapons, customPresetUpgrades, presetAvailableList, installedPreset)
         airplane.presets.fillPresets()
         airplane.sendUpgradesListToAS(self.__lobby)
 def onPreviewPreset(self, presetName, planeID, onlyDescription = False):
     LOG_DEBUG('onPreviewPreset', onlyDescription)
     self.isPreviewPreset = True
     plane = self.getCarouselAirplane(planeID)
     if plane is None:
         plane = getLobbyAirplane(planeID)
     preset = plane.presets.findPreset(presetName)
     if preset is not None:
         self.previewPreset(plane, preset.modulesList, preset.weaponsList, onlyDescription)
     else:
         LOG_ERROR("couldn't find preset")
     return
    def __getAirplanesListResponse(self):
        """ See CAROUSEL_DATA in alias.xml for actual data """
        carouselList = self.inventory.getCarouselAircrafts()
        self.__airplanesList = []
        for airplane in carouselList:
            carouselAirplane = getLobbyAirplane(airplane['plane'])
            self.__updateCarouselAirplane(carouselAirplane, airplane)
            self.__airplanesList.append(carouselAirplane)

        self.__isCached = True
        self.__slotsCount = self.inventory.getSlotCount()
        aircraftID = self.inventory.getCurrentAircraftID() or -1
        self.__sendCarouselDataToAS(aircraftID)
        if self.__lobby is not None:
            self.__lobby.onCarouselLoaded()
        return
 def addCarouselAirplane(self, aircraftID, ignorePrizesWindow = False):
     if self._prizesWindowShown and not ignorePrizesWindow:
         if aircraftID not in self._pendingAddList:
             self._pendingAddList.append(aircraftID)
         return
     else:
         carouselAirplane = getLobbyAirplane(aircraftID)
         carouselAirplane.isBought = True
         if not filter(lambda x: x.planeID == aircraftID, self.__airplanesList):
             self.__airplanesList.append(carouselAirplane)
             self.updateCarouselAirplane(aircraftID, None)
             self.onGetUpgradesList([], aircraftID)
             presetName = self.inventory.getInstalledPreset(aircraftID)
             if presetName == CUSTOM_PRESET_NAME:
                 upgrades = [ upgrade['name'] for upgrade in carouselAirplane.modules.getInstalled() ]
                 gID = db.DBLogic.createGlobalID(carouselAirplane.planeID, upgrades, carouselAirplane.weapons.getInstalledWeaponsList())
                 self.inventory.setCustomPreset(aircraftID, gID)
         return carouselAirplane
 def sendUpgradesListToAS(self, planeID = None):
     LOG_DEBUG('sendUpgradesListToAS called', planeID)
     if self.__lobby is None or self.__lobby.mode != HANGAR_MODE.HOME and self.__lobby.mode != HANGAR_MODE.RESEARCH:
         return
     else:
         planeID = planeID or self.__lobby.researchTreeHelper.enteredInAircraftID
         if planeID is not None:
             plane = self.getCarouselAirplane(planeID)
             if plane is None:
                 plane = getLobbyAirplane(planeID)
             if self.__lobby.researchTreeHelper.enteredInAircraftID:
                 plane.sendUpgradesListToAS(self.__lobby)
         else:
             if self.__planeSelected is None:
                 LOG_ERROR('Plane object is None')
                 return
             if self.__planeSelected.modules is None or self.__planeSelected.weapons is None or self.__planeSelected.presets is None:
                 self.onGetUpgradesList()
             else:
                 self.__planeSelected.sendUpgradesListToAS(self.__lobby)
         return
Example #8
0
    def __call__(self, account, ob, **kw):
        if ob is None:
            return
        else:
            cmpUpgrade = None
            cmpUpgradeID = None
            weaponConfig = None
            slotID = None
            upgrade = None
            upgradeID = None
            plane = None
            _, typeList = splitIDTypeList(kw['idTypeList'])
            if isinstance(ob, list):
                for idx in xrange(0, len(typeList)):
                    if typeList[idx] == 'plane':
                        plane = ob[idx]
                    elif typeList[idx] == 'upgrade':
                        if upgradeID is None:
                            upgrade = ob[idx]
                            upgradeID = kw['idTypeList'][idx][0]
                        else:
                            cmpUpgrade = ob[idx]
                            cmpUpgradeID = kw['idTypeList'][idx][0]
                    elif typeList[idx] == 'weaponConfig':
                        weaponConfig = ob[idx]
                    elif typeList[idx] == 'weaponslot':
                        slotID = ob[idx].id

            else:
                upgrade = ob
            adaptedOb = super(IModuleDescriptionAdapter,
                              self).__call__(account, ob, **kw)
            if upgrade is not None:
                outName, specs, planesSet, shortDescription = getUpgradeSpecs(
                    upgrade, plane.id if plane is not None else None,
                    cmpUpgrade, slotID, weaponConfig)
            elif weaponConfig is None or slotID is None or cmpUpgradeID is None or cmpUpgrade.type not in UPGRADE_TYPE.WEAPON:
                return adaptedOb
            adaptedOb['configComparison'] = []
            adaptedOb['requiredModules'] = []
            dbInstance = db.DBLogic.g_instance
            cmpGlobalID = 0
            if cmpUpgradeID is not None:
                import BWPersonality
                lch = BWPersonality.g_lobbyCarouselHelper
                lobbyAirplane = lch.getCarouselAirplane(
                    plane.id) or getLobbyAirplane(plane.id)
                upgradeName = upgrade.name if upgrade is not None else None
                cmpName = cmpUpgrade.name if cmpUpgrade is not None else None
                if lobbyAirplane is not None:
                    upgrades = [
                        x['name']
                        for x in lobbyAirplane.modules.getInstalled()
                    ]
                    weaponList = lobbyAirplane.weapons.getInstalledWeaponsList(
                    )
                    if not upgrades:
                        planeConfig = airplanesConfigurations[
                            airplanesDefaultConfigurations[plane.id]]
                        upgrades = planeConfig.modules
                        weaponList = planeConfig.weaponSlots
                    cmpGlobalID, newUpgrades, newWeaponList = adjustPlaneConfig(
                        lobbyAirplane.planeID, upgrades, weaponList,
                        upgradeName, cmpName, slotID, weaponConfig)
                    oldGlobalID = db.DBLogic.createGlobalID(
                        lobbyAirplane.planeID, upgrades, weaponList)
                    requiredModules = getDiffModules(oldGlobalID, cmpGlobalID,
                                                     upgradeName,
                                                     (slotID, weaponConfig))
                    for upgradeName in requiredModules:
                        reqUpgrade = dbInstance.getUpgradeByName(upgradeName)
                        name, _, _, _ = getUpgradeSpecs(
                            reqUpgrade,
                            plane.id if plane is not None else None, None,
                            slotID, weaponConfig)
                        adaptedOb['requiredModules'].append(name)

                    cmpLobbyAirplane = lobbyAirplane.previewPreset(
                        newUpgrades, [{
                            'slot': x[0],
                            'configuration': x[1]
                        } for x in newWeaponList])
                    comparisonSpecs = cmpLobbyAirplane.getGroupedDescriptionFields(
                        True, lobbyAirplane, cmpGlobalID, False)
                    for el in comparisonSpecs:
                        for i, j in el.__dict__.iteritems():
                            if i != 'main':
                                continue
                            specObj = None
                            if j is not None:
                                specObj = j.__dict__
                            if specObj and specObj['comparisonValue']:
                                adaptedOb['configComparison'].append(specObj)

            if not adaptedOb['configComparison']:
                adaptedOb['configComparison'] = None
            if upgrade is not None:
                gunData = dbInstance.getGunData(upgrade.name)
                if gunData is None:
                    moduleType = localizeComponents(
                        MODULE_GROUP_NAME.get(
                            getattr(upgrade, 'moduleGroup', None),
                            MODULE_GROUP_NAME[upgrade.type]))
                else:
                    profileName = gunData.gunProfileName.upper()
                    if profileName == 'MACHINEGUN_SMALL':
                        profileName = 'MACHINE_GUN_LOW'
                    else:
                        profileName = profileName.replace(
                            'MACHINEGUN_SMALL', 'MACHINE_GUN')
                    profileName = profileName.replace('CANNON_HIGH_VULCAN',
                                                      'CANNON_HIGH')
                    moduleType = localizeLobby(
                        '{0}_DESCRIPTION'.format(profileName))
                adaptedOb['name'] = '{0} {1}'.format(moduleType, outName)
                adaptedOb['type'] = upgrade.type
                adaptedOb['description'] = shortDescription
                if hasattr(upgrade, 'level'):
                    adaptedOb['level'] = upgrade.level
                else:
                    adaptedOb['level'] = 0
                adaptedOb['specsList'] = [spec.__dict__ for spec in specs]
                adaptedOb['airplanesList'] = map(
                    lambda x: localizeAirplane(dbInstance.getAircraftName(x)),
                    filter(lambda x: x in planesSet,
                           dbInstance.getShopPlaneList()))
                adaptedOb['suitablePlaneIDs'] = list(planesSet)
                adaptedOb['icoPath'] = get48ModuleIconPath(
                    getattr(upgrade, 'iconPath', ICON_MODULE_DEFAULT_PATH))
                isArmoredTargetEffective = EFFECTIVE_AGAINST_ARMORED_OBJECTS.NORMAL
                if upgrade.type in [UPGRADE_TYPE.BOMB, UPGRADE_TYPE.ROCKET]:
                    isArmoredTargetEffective = EFFECTIVE_AGAINST_ARMORED_OBJECTS.IS_EFFECTIVE
                if upgrade.type == UPGRADE_TYPE.GUN:
                    isArmoredTargetEffective = EFFECTIVE_AGAINST_ARMORED_OBJECTS.NOT_EFFECTIVE if gunData.caliber < MIN_CALIBER else EFFECTIVE_AGAINST_ARMORED_OBJECTS.LOW_EFFECTIVE
                adaptedOb['armoredTargetEffective'] = isArmoredTargetEffective
                adaptedOb['buyAvailable'] = getattr(upgrade, 'buyAvailable',
                                                    True)
                if upgrade.type == UPGRADE_TYPE.GUN:
                    compData = gunData
                elif upgrade.type in UPGRADE_TYPE.SHELL:
                    compData = dbInstance.getComponentByName(
                        UPGRADE_TYPE_TO_COMPONENT_TYPE[upgrade.type],
                        upgrade.name)
                elif upgrade.type == UPGRADE_TYPE.TURRET:
                    turret = dbInstance.getTurretData(upgrade.name)
                    compData = dbInstance.getGunData(turret.hangarSimilarGun)
                else:
                    compData = None
                if compData is not None and hasattr(compData, 'tag'):
                    adaptedOb['propsList'] = [[localizeLobby(x.name), x.type]
                                              for x in compData.tag]
                else:
                    adaptedOb['propsList'] = []
                adaptedOb['cmpGlobalID'] = cmpGlobalID
            else:
                adaptedOb['name'] = ''
                adaptedOb['type'] = -1
                adaptedOb['description'] = ''
                adaptedOb['level'] = 0
                adaptedOb['specsList'] = []
                adaptedOb['airplanesList'] = []
                adaptedOb['suitablePlaneIDs'] = []
                adaptedOb['icoPath'] = ''
                adaptedOb['armoredTargetEffective'] = False
                adaptedOb['buyAvailable'] = False
                adaptedOb['cmpGlobalID'] = 0
            return adaptedOb
    def __call__(self, account, obList, **kw):
        import BWPersonality
        lch = BWPersonality.g_lobbyCarouselHelper
        globalID = kw['idTypeList'][0][0]
        planeID = db.DBLogic.g_instance.getPlaneIDByGlobalID(globalID)
        ob = None
        measurementSystem = None
        obCompare = None
        _, typeList = splitIDTypeList(kw['idTypeList'])
        if isinstance(obList, list):
            for idx in xrange(0, len(typeList)):
                if typeList[idx] == 'measurementSystem':
                    measurementSystem = MeasurementSystem(obList[idx])
                elif typeList[idx] == 'planePreset':
                    if ob is None:
                        ob = obList[idx]
                    else:
                        obCompare = obList[idx]

        if obCompare is not None:
            airplaneForCompare = lch.getCarouselAirplane(
                obCompare['plane'].planeID) or getLobbyAirplane(
                    obCompare['plane'].planeID)
        else:
            airplaneForCompare = None
        carouselAirplane = lch.getCarouselAirplaneSelected()
        if carouselAirplane is not None:
            currentPlaneID = carouselAirplane.planeID
            installedGlobalID = lch.inventory.getInstalledUpgradesGlobalID(
                currentPlaneID) if lch.inventory.isAircraftBought(
                    currentPlaneID) else 0
        else:
            installedGlobalID = 0
        modify = globalID == installedGlobalID
        adaptedOb = super(IConfigSpecsAdapter,
                          self).__call__(account, ob, **kw)
        if ob is not None:
            plane = ob['plane']
            lobbyPlane = lch.getCarouselAirplane(
                plane.planeID) or getLobbyAirplane(plane.planeID)
            equipment = lch.inventory.getEquipment(planeID)
            crewList = lch.inventory.getCrewList(planeID)
            if airplaneForCompare is None:
                projectiles = lobbyPlane.weapons.getInstalledProjectiles()
            else:
                projectiles = None
            specs = getPerformanceSpecsTable(globalID, modify, projectiles,
                                             equipment, crewList)
            if specs is not None:
                for key, value in specs.__dict__.iteritems():
                    if key in self._iface.attr:
                        ob[key] = value

            specs = lobbyPlane.getGroupedDescriptionFields(
                True, airplaneForCompare, globalID, modify, measurementSystem)
            adaptedOb['specs'] = []
            for el in specs:
                group = {}
                for i, j in el.__dict__.iteritems():
                    if isinstance(j, list):
                        vlist = []
                        for jel in j:
                            vlist.append(jel.__dict__)

                        group[i] = vlist
                    elif j is not None:
                        group[i] = j.__dict__

                adaptedOb['specs'].append(group)

        return adaptedOb
Example #10
0
    def __fillNodes(self, selectedAircraftID):
        inventory = self.__lobbyCarouselHelper.inventory
        self.__originPlane = self.__lobbyCarouselHelper.getCarouselAirplane(selectedAircraftID)
        if self.__originPlane is None:
            self.__originPlane = getLobbyAirplane(selectedAircraftID)
        if self.__originPlane is None:
            LOG_ERROR('Aircraft %d not found' % selectedAircraftID)
            return
        else:
            LOG_DEBUG('__onInitialized selectedAircraftID = {0}'.format(selectedAircraftID))
            self.__selectedAircraft = copy.deepcopy(self.__originPlane)
            self.__selectedAircraft.presets.fillPresets()
            self.__selectedAircraft.experience = self.__lobbyCarouselHelper.inventory.getAircraftExp(selectedAircraftID)
            if (self.__selectedAircraft.isPremium or self.__selectedAircraft.isBought) and not self.__selectedAircraft.isResearched:
                self.__lobbyCarouselHelper.inventory.openAircraft(self.__selectedAircraft.planeID)
                self.__selectedAircraft.isResearched = True
            self.__nodes.clear()
            aircraftData = self.__db.getAircraftData(selectedAircraftID)
            groupedModules = {}
            groupsVOs = {}
            selectedAircraftName = self.__db.getAircraftName(self.__selectedAircraft.planeID)
            nodesCounter = 0
            for component in self.__selectedAircraft.modules.getSortedModules():
                upgrade = self.__db.upgrades.get(component['name'])
                if upgrade.type == UPGRADE_TYPE.AIRCRAFT:
                    aircraftChildData = self.__db.getAircraftData(self.__db.getAircraftIDbyName(upgrade.name))
                    if aircraftChildData.airplane.options.hidePlaneResearch:
                        continue
                moduleNode = NodeData()
                moduleNode.isDefault = component['isDefault']
                moduleNode.upgrade = upgrade
                moduleNode.upgradeVariant = findIf(moduleNode.upgrade.variant, lambda item: item.aircraftName == selectedAircraftName)
                moduleNode.vo = NodeVO()
                moduleNode.vo.upgradeName = moduleNode.upgrade.name
                moduleNode.vo.dbID = moduleNode.upgrade.id
                moduleNode.vo.name = localizeUpgrade(moduleNode.upgrade)
                moduleNode.vo.isInstalled = component['isInstalled'] and self.__selectedAircraft.isBought
                moduleNode.vo.id = nodesCounter
                nodesCounter += 1
                moduleNode.vo.iconPath = get48ModuleIconPath(getattr(moduleNode.upgrade, 'iconPath', ICON_MODULE_DEFAULT_PATH))
                moduleNode.vo.isBought = inventory.isUpgradeBought(moduleNode.upgrade.name) or moduleNode.vo.isInstalled
                moduleNode.vo.requiredCount = 1
                moduleNode.vo.availableCount = max(0, inventory.getUpgradeCount(moduleNode.upgrade.name))
                groupType = getattr(moduleNode.upgrade, 'moduleGroup', moduleNode.upgrade.type)
                try:
                    moduleNode.groupIndex = aircraftData.airplane.options.moduleGroupsOrder.group.index(groupType)
                except:
                    moduleNode.groupIndex = DEFAULT_MODULE_GROUPS_ORDER_BY_TYPE[groupType]

                moduleNode.groupName = localizeComponents(MODULE_GROUP_NAME[groupType])
                moduleNode.vo.level = moduleNode.upgrade.level
                groupedModules.setdefault(moduleNode.groupIndex, []).append(moduleNode)
                self.__nodes[moduleNode.vo.id] = moduleNode

            for weapon in self.__selectedAircraft.weapons.getSortedWeaponsList():
                moduleNode = NodeData()
                moduleNode.isDefault = weapon.isDefault
                moduleNode.vo = NodeVO()
                moduleNode.vo.weaponConfig = weapon.configurationID
                moduleNode.vo.slotID = weapon.weaponSlotID
                moduleNode.vo.id = nodesCounter
                moduleNode.vo.isInstalled = weapon.isInstalled and self.__selectedAircraft.isBought
                nodesCounter += 1
                if weapon.weaponNameID == EMPTY_WEAPON_NAME_ID:
                    moduleNode.isEmptyWeapon = True
                    moduleNode.vo.dbID = -1
                    moduleNode.vo.iconPath = get48ModuleIconPath(EMPTY_WEAPON_SLOT_ICON_PATH)
                    moduleNode.vo.isResearched = self.__selectedAircraft.isResearched
                    moduleNode.vo.researchExp = 0
                    moduleNode.vo.buyCost = CostVO(0, 0)
                    moduleNode.vo.isEmpty = True
                    moduleNode.vo.incompatibleModules = []
                    moduleNode.vo.name = localizeLobby('WEAPON_NAME_EMPTY')
                else:
                    moduleNode.upgrade = self.__db.upgrades.get(weapon.weaponNameID, None)
                    if moduleNode.upgrade is None:
                        LOG_ERROR('WeaponNameID = "{0}" cannot be found in db'.format(weapon.weaponNameID))
                        continue
                    moduleNode.vo.dbID = moduleNode.upgrade.id
                    moduleNode.upgradeVariant = findIf(moduleNode.upgrade.variant, lambda item: item.aircraftName == selectedAircraftName)
                    if moduleNode.upgradeVariant is None:
                        LOG_ERROR('WeaponNameID = "{0}" does not contains variant for aircraft = {1}'.format(weapon.weaponNameID, selectedAircraftName))
                        continue
                    moduleNode.vo.upgradeName = moduleNode.upgrade.name
                    moduleNode.vo.name = localizeUpgrade(moduleNode.upgrade)
                    moduleNode.vo.iconPath = get48ModuleIconPath(getattr(moduleNode.upgrade, 'iconPath', ICON_MODULE_DEFAULT_PATH))
                    moduleNode.vo.requiredCount = weapon.neededCount
                    moduleNode.vo.level = moduleNode.upgrade.level
                    self.__updateWeaponAvailableCount(moduleNode)
                    moduleNode.vo.weaponType = moduleNode.upgrade.type
                    if moduleNode.upgrade.type == UPGRADE_TYPE.GUN:
                        gun = db.DBLogic.g_instance.getComponentByName(COMPONENT_TYPE.GUNS, moduleNode.upgrade.name)
                        moduleNode.vo.weaponGroup = gun.id
                moduleNode.vo.isWeapon = True
                groupType = 'slot_%s' % str(weapon.weaponSlotID)
                try:
                    moduleNode.groupIndex = aircraftData.airplane.options.moduleGroupsOrder.group.index(groupType)
                except:
                    moduleNode.groupIndex = DEFAULT_MODULE_GROUPS_ORDER_BY_TYPE[groupType]

                moduleNode.groupName = self.__selectedAircraft.weapons.getSlotsInfoMap()[weapon.weaponSlotID]['description']
                groupedModules.setdefault(moduleNode.groupIndex, []).append(moduleNode)
                self.__nodes[moduleNode.vo.id] = moduleNode

            aircraftConfigurations = [ _airplanesConfigurations_db.getAirplaneConfiguration(globalID) for globalID in _airplanesConfigurations_db.airplanesConfigurationsList[selectedAircraftID] ]
            for cSlotId, val in groupedModules.iteritems():
                for cIndex, cModule in enumerate(val):
                    if not groupsVOs.has_key(cModule.groupIndex):
                        groupsVOs[cModule.groupIndex] = GroupVO(cModule.groupIndex, cModule.groupName)
                    groupsVOs[cModule.groupIndex].nodes.append(cModule.vo.id)
                    incompatibleModules = self.__nodes.keys()
                    for aircraftConfig in aircraftConfigurations:
                        if not incompatibleModules:
                            break
                        if cModule.vo.isWeapon and (cModule.vo.slotID, cModule.vo.weaponConfig) in aircraftConfig.weaponSlots or not cModule.vo.isWeapon and cModule.upgrade.name in aircraftConfig.modules:
                            for node in self.__nodes.itervalues():
                                if node.vo.id in incompatibleModules:
                                    if node.vo.isWeapon and (node.vo.slotID, node.vo.weaponConfig) in aircraftConfig.weaponSlots or not node.vo.isWeapon and node.upgrade.name in aircraftConfig.modules:
                                        incompatibleModules.remove(node.vo.id)

                    cModule.vo.incompatibleModules = incompatibleModules
                    cModule.vo.isBought = self.__isBought(cModule)
                    parentNode = None
                    if not cModule.isEmptyWeapon:
                        cModule.vo.buyCost = CostVO(cModule.upgrade.credits, cModule.upgrade.gold)
                        if cModule.upgradeVariant.parentUpgrade:
                            parentUpgrade = cModule.upgradeVariant.parentUpgrade[0]
                            if hasattr(parentUpgrade, 'weaponConfig'):
                                parentNode = findIf(self.__nodes.itervalues(), lambda n: not n.isEmptyWeapon and n.vo.isWeapon and n.upgrade.name == parentUpgrade.name and parentUpgrade.weaponConfig.slotID == n.vo.slotID and parentUpgrade.weaponConfig.slotConfigID == n.vo.weaponConfig)
                            else:
                                parentNode = findIf(self.__nodes.itervalues(), lambda n: not n.isEmptyWeapon and n.upgrade.name == parentUpgrade.name)
                            if parentNode:
                                cModule.vo.parentID = parentNode.vo.id
                            cModule.vo.researchExp = cModule.upgradeVariant.parentUpgrade[0].experience
                            if not cModule.isDefault:
                                self.__updateNodeRequiredResearches(cModule)
                        self.__updateResearchStatus(cModule)
                    if cModule.vo.isWeapon:
                        if not cModule.isDefault:
                            requiredNodes = [ n for n in self.__nodes.itervalues() if not n.vo.isWeapon and any((s for s in n.upgradeVariant.slot if s.id == cModule.vo.slotID and cModule.vo.weaponConfig in s.typeId)) ]
                            if parentNode is None and len(requiredNodes) == 1 and len(groupedModules[requiredNodes[0].groupIndex]) != 1:
                                cModule.vo.parentID = requiredNodes[0].vo.id
                            elif cModule.vo.parentID == -1:
                                for node in groupedModules[cModule.groupIndex]:
                                    if node.vo.id != cModule.vo.id and cModule.vo.level > node.vo.level and (not parentNode or parentNode.vo.level < node.vo.level) or node.isDefault:
                                        parentNode = node

                                if parentNode:
                                    cModule.vo.parentID = parentNode.vo.id
                    else:
                        for slot in cModule.upgradeVariant.slot:
                            if len(slot.typeId) == 1 and self.__db.getWeaponInfo(selectedAircraftID, slot.id, slot.typeId[0]) is None:
                                node = findIf(self.__nodes.itervalues(), lambda n: n.isEmptyWeapon and not n.isDefault and n.vo.slotID == slot.id and n.vo.weaponConfig == slot.typeId[0])
                                if node is not None:
                                    node.vo.parentID = cModule.vo.id

            aircraftUpgrades, aircrafts = self.__db.getAircraftUpgrades(selectedAircraftID)
            if not aircraftData.airplane.options.hidePlaneResearch:
                for childUpgrade in aircrafts:
                    self.__addAircraftNode(childUpgrade.name, childUpgrade, nodesCounter, False, selectedAircraftID)
                    nodesCounter += 1

            selectedAircraftUpgrade = self.__db.upgrades.get(selectedAircraftName, None)
            if selectedAircraftUpgrade is not None and not aircraftData.airplane.options.hidePlaneResearch:
                parentAircraftUpgrades = [ self.__db.upgrades.get(variant.aircraftName, None) for variant in selectedAircraftUpgrade.variant ]
                for parentAircraftUpgrade in parentAircraftUpgrades:
                    if parentAircraftUpgrade:
                        self.__addAircraftNode(parentAircraftUpgrade.name, parentAircraftUpgrade, nodesCounter, True)
                    else:
                        self.__addAircraftNode(selectedAircraftUpgrade.variant[0].aircraftName, None, nodesCounter, True)
                    nodesCounter += 1

            self.__updateAircraftInfoVO()
            selectedPresetName = self.__selectedAircraft.presets.getInstalled().name if self.__selectedAircraft.isBought else self.__db.getAircraftDefaultPreset(selectedAircraftID).name
            self.__lobby.call_1('moduleTree.setData', DataVO([ n.vo for n in self.__nodes.itervalues() ], groupsVOs.values(), [ PresetVO(preset.name, preset.title) for preset in self.__selectedAircraft.presets.getAll() ], selectedPresetName, self.__selectedAircraft.vo))
            self.__previewSelectedModulesStats(-1)
            return
 def getPreset(self, presetName, planeID):
     plane = self.getCarouselAirplane(planeID)
     if plane is None:
         plane = getLobbyAirplane(planeID)
     return plane.presets.findPreset(presetName)