def __updateAircraftInfoVO(self): self.__selectedAircraft.updatePrice() if not getattr(self.__selectedAircraft, 'vo', None): self.__selectedAircraft.vo = AircraftInfoVO() dataMap = self.__lobbyCarouselHelper.inventory.getAircraftClientDataMap(self.__selectedAircraft.planeID) self.__selectedAircraft.vo.name = localizeAirplaneMid(self.__db.getAircraftName(self.__selectedAircraft.planeID)) self.__selectedAircraft.vo.longName = self.__selectedAircraft.longName self.__selectedAircraft.vo.typeName = self.__selectedAircraft.type self.__selectedAircraft.vo.description = self.__selectedAircraft.getMainDescription() self.__selectedAircraft.vo.iconPath = self.__selectedAircraft.previewIconPath self.__selectedAircraft.vo.level = self.__selectedAircraft.level self.__selectedAircraft.vo.buyCost = CostVO(self.__selectedAircraft.price, self.__selectedAircraft.gold) self.__selectedAircraft.vo.researchExp = dataMap['reqiuredExperiencePlane'] self.__selectedAircraft.vo.researchedParentID = dataMap['researchedParentID'] self.__selectedAircraft.vo.isBought = self.__selectedAircraft.isBought self.__selectedAircraft.vo.isResearched = self.__selectedAircraft.isResearched or self.__selectedAircraft.isPremium self.__selectedAircraft.vo.isResearchAvailable = self.__selectedAircraft.isResearchAvailable() self.__selectedAircraft.vo.isPremium = self.__selectedAircraft.isPremium self.__selectedAircraft.isElite = self.__lobbyCarouselHelper.inventory.isAircraftElite(self.__selectedAircraft.planeID) self.__selectedAircraft.vo.isElite = self.__selectedAircraft.isElite self.__selectedAircraft.experience = dataMap['gotExperience'] self.__selectedAircraft.vo.gainedExp = self.__selectedAircraft.experience planeStatus = self.__selectedAircraft.isPremium * PLANE_CLASS.PREMIUM or self.__selectedAircraft.isElite * PLANE_CLASS.ELITE or PLANE_CLASS.REGULAR self.__selectedAircraft.vo.iconTypePath = PLANE_TYPE_ICO_PATH.icon(self.__selectedAircraft.planeType, planeStatus) self.__updatePlaneRequiredResearches(self.__selectedAircraft.vo, self.__selectedAircraft.planeID) crewSpecList = previewCrewSpecList(self.__selectedAircraft.planeID) self.__selectedAircraft.vo.crew = [] specIcoPath = 'icons/specialization/crew/hangPilotsIcon{0}.png' for crewSpec in crewSpecList: crewMember = CrewMemberVO() crewMember.specIconPath = specIcoPath.format(getSpecializationName(crewSpec)) crewMember.tooltip = localizeTooltips('TOOLTIP_CREW_{0}'.format(getSpecializationName(crewSpec).upper())) self.__selectedAircraft.vo.crew.append(crewMember) return
def __call__(self, account, ob, **kw): adaptedOb = super(IPlaneDescriptionAdapter, self).__call__(account, ob, **kw) if ob is None: return adaptedOb else: if ob.description: adaptedOb['description'] = localizeAirplaneAny( ob.description.textDescription) dbInstance = db.DBLogic.g_instance adaptedOb['presetsList'] = airplanesConfigurationsList[ob.id] adaptedOb['defaultPreset'] = airplanesDefaultConfigurations[ob.id] adaptedOb['level'] = ob.level adaptedOb['icoPath'] = ob.iconPath adaptedOb['bigIcoPath'] = ob.previewIconPath adaptedOb['hudIcoPath'] = ob.hudIcoPath adaptedOb['treeIcoPath'] = ob.treeIconPath adaptedOb[ 'battleLoadingIcoPath'] = ob.battleLoadingIconPath if hasattr( ob, 'battleLoadingIconPath') else ob.previewIconPath adaptedOb['middleName'] = localizeAirplaneMid(ob.name) adaptedOb['name'] = localizeAirplane(ob.name) adaptedOb['longName'] = localizeAirplaneLong(ob.name) adaptedOb['isExclusive'] = dbInstance.isPlaneExclusive(ob.id) adaptedOb['isTest'] = getattr(ob.options, 'isTest', False) if hasattr(ob, 'tags'): adaptedOb['tagsList'] = [[localizeTooltips(x.name), x.type] for x in ob.tags.tag] else: adaptedOb['tagsList'] = [] return adaptedOb
def load(self, src, pList, settings, forceLoad): from gui.Scaleform.GameOptions.vo.HUDSettingsVO import MarkerTargetsVO, MarkerListVO, MarkerTypeVO baseData = Settings.g_instance.markersBaseData markers = settings.markersTemplates src.selectedSystemType = Settings.g_instance.gameUI[ 'measurementSystem'] src.systemType = list() for systemType in [0, 1]: systemVo = MarkerTypeVO() stDistance = list() for key in g_instaceMarkerDistance().stepsDistance: stDistance.append(getValueBySystem(systemType, key)) systemVo.stepsDistance = stDistance systemVo.altCmd = InputMapping.CMD_SHOW_PLAYERS_INFO for targetType in MARKER_TARGET_TYPE: target = getattr(systemVo.data, targetType) for key in AVAILABLE_MARKER_PROPERTIES: addVO = getattr(target, key) addVO.title = localizeOptions( baseData[key][targetType]['label']) addVO.tooltip = localizeTooltips( baseData[key][targetType]['tooltip']) addVO.data = list() listData = baseData[key][targetType]['list'] for value in listData: markerListVO = MarkerListVO() num = getValueBySystem(systemType, value) markerListVO.label = localizeOptions( localizeMarkerValues(key, num)) markerListVO.num = num addVO.data.append(markerListVO) src.systemType.append(systemVo) src.templates = list() for i in range(Settings.g_instance.countTemplates): vo = MarkerTargetsVO() isDefault = settings.getMarkerTemplateType( ) == 'SettingsDefaultMarker' loc = localizeOptions(localizeMarkerByPlane(isDefault, i)) vo.label = loc for vehicleType in ('airMarker', 'groundMarker'): voVehicleType = getattr(vo, vehicleType) for targetType in ('enemy', 'target', 'friendly', 'squads'): voTargetType = getattr(voVehicleType, targetType) for altState in ('basic', 'alt'): voAltState = getattr(voTargetType, altState) for key in AVAILABLE_MARKER_PROPERTIES: setattr( voAltState, key, markers[vehicleType] [targetType][altState][key][i]) src.templates.append(vo) src.selectIDS = settings.selectedMarkers[:] self._isLoaded = True
def _statRecord(name=None, value=None, percentValue=None, title=None, tooltip=None): return dict( name=localizeAchievements(name), value=separateThousandths(value) if isinstance(value, int) else value, percentValue=percentValue, title=localizeAchievements(title) if title else None, tooltip=localizeTooltips(tooltip) if tooltip else None)
def __call__(self, account, ob, **kw): name = ob.client.name.locale description = ob.client.description.locale planeId = part2bomber(ob.id) bigIconPath = ob.client.icon.big smallIconPath = ob.client.icon.small position = ob.client.place adaptedOB = super(IBomberPartAdapter, self).__call__(account, getObject(kw['idTypeList']), **kw) if adaptedOB: adaptedOB['name'] = localizeLobby(name) adaptedOB['description'] = localizeTooltips(description) adaptedOB['planeID'] = planeId adaptedOB['bigIconPath'] = bigIconPath adaptedOB['smallIconPath'] = smallIconPath adaptedOB['position'] = position return adaptedOB
def createRankGainedEventModel(rankID): rankModel = RankModel.getRankByID(rankID) planeType = rankModel.relatedPlaneType iconPathTemplate = rankModel.iconPath templateData = { 'type': 'achievements', 'class': planeTypeToPath[planeType], 'state': 'normal', 'size': '72x88' } iconPath = iconPathTemplate.format(**templateData) titleTemplate = localizeTooltips(rankModel.title) localizedPlaneTypeName = localizeLobby( PREBATTLE_PLANE_TYPE_NAME[planeType]) return { 'type': EconomicsModelView.AWARD_EVENT_TYPE, 'title': titleTemplate.format(class_name=localizedPlaneTypeName), 'icon': iconPath }
def __getRolelocDescription(self, name): """ @param: name - role name @return: loc description """ return localizeTooltips('TOOLTIP_ROLES_%s' % name.upper())
def __call__(self, account, o, **kw): ob = getObject(kw['idTypeList']) adaptedOB = super(IAmmoBeltDescriptionAdapter, self).__call__(account, ob, **kw) from db.DBLogic import g_instance as db_instance guns = db_instance.getBeltSuitableGuns(ob.id) planes = [] globalMaxDamage = maxFireChance = 0 globalMinDamage = minFireChance = 100000000 gunNames = [] gunUpgradeIds = [] for gun in guns: upgrade = db_instance.upgrades.get(gun.name, None) if upgrade is None: continue for upgradeVariant in upgrade.variant: planeID = db_instance.getAircraftIDbyName( upgradeVariant.aircraftName) planeData = db_instance.getAircraftData(planeID) availableAmmoTypes = AVAILABLE_BELTS_BY_PLANE_TYPE[ planeData.airplane.planeType] if ob.ammo[0] in availableAmmoTypes and planeID not in planes: planes.append(planeID) minDamage, maxDamage = db_instance.calculateBeltMinMaxDamage( gun, ob) globalMaxDamage = max(maxDamage, globalMaxDamage) globalMinDamage = min(minDamage, globalMinDamage) fireChance, _ = db_instance.calculateBeltSpec( gun, ob, AMMOBELT_SPECS.FIRE_CHANCE) maxFireChance = max(fireChance, maxFireChance) minFireChance = min(fireChance, minFireChance) gunNames.append(localizeComponents('WEAPON_NAME_' + gun.weapName)) gunUpgradeIds.append(upgrade.id) globalMinDamage = wowpRound(globalMinDamage, 2) globalMaxDamage = wowpRound(globalMaxDamage, 2) minFireChance = wowpRound(minFireChance, 3) maxFireChance = wowpRound(maxFireChance, 3) strDamage = str( globalMinDamage ) if globalMinDamage == globalMaxDamage else '{0}-{1}'.format( globalMinDamage, globalMaxDamage) if maxFireChance > 0: strFireChance = '{0}%'.format( minFireChance * 100) if minFireChance == maxFireChance else '{0}-{1}%'.format( minFireChance, maxFireChance) else: strFireChance = '' if guns: adaptedOB['caliber'] = wowpRound(guns[0].caliber, 2) else: adaptedOB['caliber'] = 0.0 LOG_DEBUG(' TEST LOBBY ', vars(ob)) adaptedOB['suitableGunIDs'] = gunUpgradeIds adaptedOB['hudIcoPath'] = get48ModuleIconPath(ob.lobbyIconPath) adaptedOB['suitablePlaneIDs'] = planes adaptedOB['name'] = localizeComponents('WEAPON_NAME_' + ob.ui_name) adaptedOB['beltType'] = ob.beltType adaptedOB['icoPathSmall'] = get24ModuleIconPath(ob.lobbyIconPath) adaptedOB['globalMaxDamage'] = globalMaxDamage adaptedOB['globalMinDamage'] = globalMinDamage adaptedOB['globalMaxFireChance'] = maxFireChance adaptedOB['globalMinFireChance'] = minFireChance adaptedOB['gunNames'] = ', '.join(set(gunNames)) adaptedOB['shortDescription'] = '{0} {1}'.format( localizeLobby('MODULES_CHARACTERISTICS_DPS'), strDamage) adaptedOB['description'] = '' if strFireChance: adaptedOB['description'] += '\n{0} {1}'.format( localizeLobby( 'LOBBY_MAINTENANCE_MODULE_PARAMETER_FIRE_CHANSE'), strFireChance) adaptedOB['tooltipDescription'] = localizeTooltips( _BELT_TYPE_DESCRIPTION[ ob.beltType]) if ob.beltType in _BELT_TYPE_DESCRIPTION else '' adaptedOB['buyAvailable'] = getattr(ob, 'buyAvailable', True) return adaptedOB
def getUpgradeSpecs(upgrade, forPlaneID = None, cmpUpgrade = None, weaponSlot = None, weaponConfig = None): """ :param upgrade: upgrade from upgrades_db :returns: a tuple of localized name and specs array of ModuleSpecsVO """ nameID = upgrade.name localizedName = '' suitablePlanes = set([]) specs = [] dbInstance = db.DBLogic.g_instance ms = MeasurementSystem() shortDescription = '' for upgradeVariant in upgrade.variant: planeID = dbInstance.getAircraftIDbyName(upgradeVariant.aircraftName) suitablePlanes.add(planeID) if planeID is None: LOG_ERROR('getUpgradeSpecs() cannot find planeID by aircraft name (%s), module name is %s, please, correct DB' % (upgradeVariant.aircraftName, nameID)) continue if forPlaneID is not None and planeID != forPlaneID: continue if upgrade.type == UPGRADE_TYPE.GUN: count = dbInstance.getGunsCount(planeID, nameID, weaponSlot, weaponConfig) localizedName = localizeComponents('WEAPON_NAME_' + nameID) gunData = dbInstance.getGunData(nameID) dps = _mkint(gunData.DPS) specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_DPS, localizeLobby('MODULES_CHARACTERISTICS_DPS'), dps, '', planeID)) specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_ROUNDS_PER_SECOND, localizeLobby('MODULES_CHARACTERISTICS_TEMPO_OF_FIRE'), _mkint(gunData.RPM), localizeLobby('MODULES_CHARACTERISTICS_RATE_OF_FIRE_UNITS'), planeID)) specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_EFFECTIVE_DISTANCE, localizeLobby('MODULES_CHARACTERISTICS_EFFECTIVE_DIST'), _mkint(ms.getMeters(BULLET_FLY_DIST_CORRECTION * gunData.bulletFlyDist / consts.WORLD_SCALING)), ms.localizeMarket('MARKET_AIRPLANE_TURN_RADIUS'), planeID)) shortDescription = '{0}: {1}'.format(localizeTooltips('TOOLTIP_FIXED_DPS'), dps) elif upgrade.type == UPGRADE_TYPE.ENGINE: localizedName = localizeComponents('NAME_MODULE_' + nameID) settings = dbInstance.getAircraftData(planeID) part = findIf(upgradeVariant.logicalPart, lambda p: p.type == 'engine') if part is None: LOG_ERROR("Part of type 'engine' not found", upgrade.__dict__, [ x.__dict__ for x in upgradeVariant.logicalPart ]) partname = part.name engineParameters = filter(lambda m: m.name == partname, settings.airplane.flightModel.engine) if not engineParameters: LOG_ERROR("Can't find settings for engine", nameID, localizedName, partname) for eng in engineParameters: value, unit = (eng.power, localizeLobby('MARKET_AIRPLANE_ENGINE_CAPACITY_LS')) if hasattr(eng, 'power') else (eng.thrust / 10.0, ms.localizeMarket('MARKET_AIRPLANE_ENGINE_CAPACITY_KGS')) locID = 'MODULES_CHARACTERISTICS_ERROR_ENGINE' if hasattr(eng, 'power'): locID = 'MODULES_CHARACTERISTICS_POWER' elif hasattr(eng, 'thrust'): locID = 'MODULES_CHARACTERISTICS_THRIST' specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_POWER, localizeLobby(locID), _mkint(ms.getKgs(value)), unit, planeID)) specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_MODULE_TYPE, localizeLobby('MODULES_CHARACTERISTICS_TYPE'), localizeLobby('MODULES_CHARACTERISTICS_%s' % upgrade.equipmentType), '', planeID)) if forPlaneID is None or planeID == forPlaneID: shortDescription = '{0}{2}: {1}'.format(localizeLobby(locID), _mkint(ms.getKgs(value)), unit) elif upgrade.type == UPGRADE_TYPE.PLANER: localizedName = localizeComponents('NAME_MODULE_' + nameID) settings = dbInstance.getAircraftData(planeID) part = findIf(upgradeVariant.logicalPart, lambda p: p.type == 'hull') if part is None: LOG_ERROR("Part of type 'hull' not found", upgrade.__dict__, [ x.__dict__ for x in upgradeVariant.logicalPart ]) partname = part.name hullParameters = filter(lambda h: h.name == partname, settings.airplane.flightModel.hull) if not hullParameters: LOG_ERROR("Can't find settings for hull", nameID, localizedName, partname) for h in hullParameters: mass = h.mass if hasattr(h, 'mass') else 0.0 hp = h.HP if hasattr(h, 'HP') else 0.0 specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_HEALTH, localizeLobby('MODULES_CHARACTERISTICS_DURABILITY'), hp, '', planeID)) shortDescription = '{0}: {1}'.format(localizeLobby('MODULES_CHARACTERISTICS_DURABILITY'), hp, '', planeID) elif upgrade.type == UPGRADE_TYPE.ROCKET or upgrade.type == UPGRADE_TYPE.BOMB: localizedName = localizeComponents('WEAPON_NAME_' + nameID) shellDBGroupID, shellDescription = dbInstance.getShellComponentsGroupIDAndDescription(nameID) if shellDescription: for spec in getShellDescription(shellDescription): spec.planeID = planeID specs.append(spec) else: LOG_ERROR("Can't find settings for shell", nameID, localizedName) shortDescription = '{0}: {1}'.format(localizeLobby('MODULES_CHARACTERISTICS_DAMAGE'), shellDescription.explosionDamage) elif upgrade.type == UPGRADE_TYPE.TURRET: turret = dbInstance.getTurretData(nameID) localizedName = localizeUpgrade(upgrade) gunData = dbInstance.getGunData(turret.hangarSimilarGun) dps = _mkint(turret.DPS * TURRET_DPS_TO_FIREPOWER_CFC) specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_DPS, localizeLobby('MODULES_CHARACTERISTICS_DPS'), dps, '', planeID)) if gunData: specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_EFFECTIVE_DISTANCE, localizeLobby('MODULES_CHARACTERISTICS_EFFECTIVE_DIST'), _mkint(ms.getMeters(turret.targetLockShootDistance / consts.WORLD_SCALING)), ms.localizeMarket('MARKET_AIRPLANE_TURN_RADIUS'), planeID)) specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_YAW_SECTOR, localizeLobby('MODULES_CHARACTERISTICS_TURRET_HORIZONTAL'), _mkint(math.degrees((turret.yawMax - turret.yawMin) / 2.0)), localizeLobby('MARKET_AIRPLANE_DEGREES'), planeID)) specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_UP_SECTOR, localizeLobby('MODULES_CHARACTERISTICS_TURRET_UP'), _mkint(math.degrees(turret.pitchMax)), localizeLobby('MARKET_AIRPLANE_DEGREES'), planeID)) specs.append(ModuleSpecsVO(ModuleSpecsVO.TYPE_DOWN_SECTOR, localizeLobby('MODULES_CHARACTERISTICS_TURRET_DOWN'), _mkint(math.degrees(turret.pitchMin)), localizeLobby('MARKET_AIRPLANE_DEGREES'), planeID)) if turret.weaponCount > 1: dps = '{0}x {1}'.format(turret.weaponCount, dps) shortDescription = '{0}: {1}'.format(localizeTooltips('TOOLTIP_FIXED_DPS'), dps) if cmpUpgrade is None or cmpUpgrade.name == nameID: return (localizedName, specs, suitablePlanes, shortDescription) else: _, cmpSpecs, _, _ = getUpgradeSpecs(cmpUpgrade, forPlaneID) for mainSpec in specs: if not mainSpec.canCompare: continue cmpSpec = findIf(cmpSpecs, lambda x: x.specType == mainSpec.specType, None) if cmpSpec is not None and mainSpec.value != cmpSpec.value: mainSpec.setCmpValue(mainSpec.value - cmpSpec.value) return (localizedName, specs, suitablePlanes, shortDescription)