Exemple #1
0
 def setTarget(self, target):
     state = _g_aimState['target']
     vInfo = dict(target.publicInfo)
     state['id'] = target.id
     state['startTime'] = None
     clanAbbrev = BigWorld.player().arena.vehicles.get(target.id, {}).get('clanAbbrev', '')
     state['name'] = i18n.convert('%s[%s]' % (vInfo['name'], clanAbbrev) if len(clanAbbrev) > 0 else vInfo['name'])
     state['vType'] = i18n.convert(target.typeDescriptor.type.userString)
     state['isFriend'] = vInfo['team'] == BigWorld.player().team
     self._setTarget(state['name'], state['vType'], state['isFriend'])
Exemple #2
0
 def setTarget(self, target):
     state = _g_aimState['target']
     vInfo = dict(target.publicInfo)
     state['id'] = target.id
     state['startTime'] = None
     clanAbbrev = BigWorld.player().arena.vehicles.get(target.id, {}).get(
         'clanAbbrev', '')
     state['name'] = i18n.convert('%s[%s]' % (vInfo['name'], clanAbbrev)
                                  if len(clanAbbrev) > 0 else vInfo['name'])
     state['vType'] = i18n.convert(target.typeDescriptor.type.userString)
     state['isFriend'] = vInfo['team'] == BigWorld.player().team
     self._setTarget(state['name'], state['vType'], state['isFriend'])
    def onVehicleChanged(self, vehID):
        Waiting.show('updating')
        self.__selectedVehicle = vehID
        modulesAll = g_itemsCache.items.getVehicles(
            self.__getRoleCriteria(self.__selectedNation,
                                   self.__selectedVehClass,
                                   self.__selectedVehicle)).values()
        roles = []
        data = [self.__getTankmanRoleEmptyRow()]
        modulesAll.sort()
        selectedIndex = 0
        counter = 0
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({
                    'id':
                    role[0],
                    'label':
                    convert(getSkillsConfig()[role[0]]['userString'])
                })
                if self.__selectedTmanRole == role[0]:
                    selectedIndex = counter
                counter = counter + 1

        self.as_setTankmanRoleDataS(
            self.__getSendingData(data,
                                  len(data) > 1, selectedIndex))
        Waiting.hide('updating')
        self.onDataChange(self.__selectedNation, self.__selectedVehClass,
                          self.__selectedVehicle, self.__selectedTmanRole)
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': nationID,
          'label': MENU.nations(nations.NAMES[int(nationID)])}]
        classesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': tankType,
          'label': DIALOGS.recruitwindow_vehicleclassdropdown(tankType)}]
        typesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, tankType, typeID)).values()
        modulesAll.sort()
        for module in modulesAll:
            typesDP.append({'id': module.innationID,
             'label': module.shortUserName})
            for role in module.descriptor.type.crewRoles:
                if role[0] == roleType:
                    rolesDP.append({'id': role[0],
                     'label': convert(getSkillsConfig()[role[0]]['userString'])})

            break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP, rolesDP)
        return
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': nationID,
          'label': MENU.nations(nations.NAMES[int(nationID)])}]
        classesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': tankType,
          'label': DIALOGS.recruitwindow_vehicleclassdropdown(tankType)}]
        typesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[0] == nationID and module.descriptor.type.id[1] == typeID:
                typesDP.append({'id': module.descriptor.type.id[1],
                 'label': module.descriptor.type.shortUserString})
                for role in module.descriptor.type.crewRoles:
                    if role[0] == roleType:
                        rolesDP.append({'id': role[0],
                         'label': convert(getSkillsConfig()[role[0]]['userString'])})

                break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP, rolesDP)
        return
Exemple #6
0
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': nationID,
          'label': MENU.nations(nations.NAMES[int(nationID)])}]
        classesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': tankType,
          'label': DIALOGS.recruitwindow_vehicleclassdropdown(tankType)}]
        typesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, tankType, typeID)).values()
        modulesAll.sort()
        for module in modulesAll:
            typesDP.append({'id': module.innationID,
             'label': module.shortUserName})
            for role in module.descriptor.type.crewRoles:
                if role[0] == roleType:
                    rolesDP.append({'id': role[0],
                     'label': convert(getSkillsConfig()[role[0]]['userString'])})

            break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP, rolesDP)
        return
Exemple #7
0
 def __setText(self, name, type, health):
     text = i18n.convert(self.__msgCaption % {
         'name': name,
         'type': type,
         'health': health
     })
     Aim._flashCall(self, 'updatePlayerInfo', [text])
Exemple #8
0
 def getSkillIconName(self, skillName):
     """Change icon for brotherhood skill
     :return:
     """
     if skillName == 'brotherhood':
         return 'sabaton_brotherhood.png'
     return i18n.convert(tankmen.getSkillsConfig().getSkill(skillName).icon)
    def getVehicleInfo(self):
        vehicle = g_itemsCache.items.getItemByCD(self.vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ', self.vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName, tankman.lastUserName, tankman.roleLevel)
                tankmenParams.append({'tankmanType': i18n.convert(tankmen.getSkillsConfig()[role].get('userString', '')),
                 'value': tankmanLabel})

            info = {'vehicleName': vehicle.longUserName,
             'vehicleDiscription': vehicle.fullDescription,
             'vehicleImage': vehicle.icon,
             'vehicleLevel': vehicle.level,
             'vehicleNation': vehicle.nationID,
             'vehicleElite': vehicle.isElite,
             'vehicleType': vehicle.type,
             'VehicleInfoPropsData': [ {'name': n,
                                      'value': v} for n, v in params['parameters'] ],
             'VehicleInfoBaseData': params['base'],
             'VehicleInfoCrewData': tankmenParams}
            self.as_setVehicleInfoS(info)
            return
    def getVehicleInfo(self):
        vehicle = self._itemsCache.items.getItemByCD(self.__vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ', self.__vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            skillsConfig = tankmen.getSkillsConfig()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName, tankman.lastUserName, tankman.roleLevel)
                tankmenParams.append({'tankmanType': i18n.convert(skillsConfig.getSkill(role).userString),
                 'value': tankmanLabel})

            paramsList = formatters.getFormattedParamsList(vehicle.descriptor, params['parameters'], excludeRelative=True)
            info = {'vehicleName': vehicle.longUserName,
             'vehicleDescription': vehicle.fullDescription,
             'vehicleImage': vehicle.icon,
             'vehicleLevel': vehicle.level,
             'vehicleNation': vehicle.nationID,
             'vehicleElite': vehicle.isElite,
             'vehicleType': vehicle.type,
             'propsData': self.__packParams(paramsList),
             'baseData': params['base'],
             'crewData': tankmenParams}
            self.as_setVehicleInfoS(info)
            return
    def __setTankmenData(self):
        modulesAll = self.itemsCache.items.getVehicles(
            self.__getRoleCriteria(self.__selectedNation,
                                   self.__selectedVehClass,
                                   self.__selectedVehicle)).values()
        roles = []
        data = [self.__getTankmanRoleEmptyRow()]
        modulesAll.sort()
        selectedIndex = 0
        counter = 0
        skillsConfig = getSkillsConfig()
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({
                    'id':
                    role[0],
                    'label':
                    convert(skillsConfig.getSkill(role[0]).userString)
                })
                if self.__selectedTmanRole == role[0]:
                    selectedIndex = counter
                counter = counter + 1

        self.as_setTankmanRoleDataS(
            self.__getSendingData(data,
                                  len(data) > 1, selectedIndex))
    def __handleConnectionStatus(self, stage, status, serverMsg, isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = "LOGGED_ON"
        LOG_DEBUG("__handleConnectionStatus %s %s %s" % (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status == "DNS_LOOKUP_FAILED":
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status != "LOGIN_REJECTED_LOGIN_QUEUE":
                    self.__clearAutoLoginTimer()
                if status != "LOGIN_REJECTED_RATE_LIMITED":
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                if status not in ("LOGIN_REJECTED_INVALID_PASSWORD",):
                    g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR("Handle logon status error: status = %r, message = %r" % (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide("login")

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
                if connectionManager.isConnected():
                    connectionManager.disconnect()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__kickPeripheryID is not None:
                if self.__kickPeripheryID == -1:
                    msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                elif self.__kickPeripheryID == -2:
                    msg = "#menu:login/status/centerRestart"
                elif self.__kickPeripheryID == -3:
                    msg = "#menu:login/status/versionMismatch"
            elif connectionManager.isVersionsDiffered:
                msg = ""
                self.onHandleUpdateClientSoftwareNeeded()
            localizedMessage = i18n.convert(i18n.makeString(msg))
            lastLoginType = Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readString("lastLoginType", "basic")
            if lastLoginType != "basic" and not Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readBool(
                "rememberPwd", False
            ):
                from gui.social_network_login import Bridge as socialNetworkLogin

                localizedMessage = socialNetworkLogin.getLogoutWarning(lastLoginType)
            self.onSetStatus(localizedMessage, self.ALL_VALID)
            connectionManager.disconnect()
        return
def _packNotRecruitedTankman(recruitInfo):
    expiryTime = recruitInfo.getExpiryTime()
    recruitBeforeStr = _ms(MENU.BARRACKS_NOTRECRUITEDACTIVATEBEFORE,
                           date=expiryTime) if expiryTime else ''
    availableRoles = recruitInfo.getRoles()
    roleType = availableRoles[0] if len(availableRoles) == 1 else ''
    result = {
        'firstName': i18n.convert(recruitInfo.getFirstName()),
        'lastName': i18n.convert(recruitInfo.getLastName()),
        'rank': recruitBeforeStr,
        'specializationLevel': recruitInfo.getRoleLevel(),
        'role': text_styles.counter(recruitInfo.getLabel()),
        'vehicleType': '',
        'iconFile': recruitInfo.getBarracksIcon(),
        'roleIconFile':
        Tankman.getRoleBigIconPath(roleType) if roleType else '',
        'rankIconFile': '',
        'contourIconFile': '',
        'tankmanID': -1,
        'nationID': -1,
        'typeID': -1,
        'roleType': roleType,
        'tankType': '',
        'inTank': False,
        'compact': '',
        'lastSkillLevel': recruitInfo.getLastSkillLevel(),
        'actionBtnEnabled': True,
        'inCurrentTank': False,
        'vehicleID': None,
        'slot': None,
        'locked': False,
        'lockMessage': '',
        'isInSelfVehicleClass': True,
        'isInSelfVehicleType': True,
        'notRecruited': True,
        'isRankNameVisible': True,
        'recoveryPeriodText': None,
        'actionBtnLabel': MENU.BARRACKS_BTNRECRUITNOTRECRUITED,
        'actionBtnTooltip': TOOLTIPS.BARRACKS_TANKMEN_RECRUIT,
        'skills': [],
        'isSkillsVisible': False,
        'recruitID': str(recruitInfo.getRecruitID())
    }
    return result
    def __setTankmenData(self):
        skillsConfig = getSkillsConfig()
        hasRoles = self.__hasPredefinedTmanRoles()
        if hasRoles and len(self.__predefinedTmanRoles) == 1:
            data = []
            for roleName in self.__predefinedTmanRoles:
                data.append(
                    _packItemVO(
                        roleName,
                        convert(skillsConfig.getSkill(roleName).userString)))

            selectedIndex = 0
        else:
            modulesAll = self.itemsCache.items.getVehicles(
                self.__getRoleCriteria(self.__selectedNationIdx,
                                       self.__selectedVehClass,
                                       self.__selectedVehicle)).values()
            roles = []
            data = [self.__getTankmanRoleEmptyRow()]
            modulesAll.sort()
            selectedIndex = 0
            counter = 0
            for module in modulesAll:
                for role in module.descriptor.type.crewRoles:
                    roleName = role[0]
                    if roleName in roles:
                        continue
                    if not hasRoles or roleName in self.__predefinedTmanRoles:
                        roles.append(roleName)
                        data.append(
                            _packItemVO(
                                roleName,
                                convert(
                                    skillsConfig.getSkill(
                                        roleName).userString)))
                        if self.__selectedTmanRole == roleName:
                            selectedIndex = counter
                    counter += 1

        self.as_setTankmanRoleDataS(
            self.__getSendingData(data,
                                  len(data) > 1, selectedIndex))
Exemple #15
0
    def getVehicleInfo(self):
        Waiting.show('updating')
        items = yield ItemsRequester().request()
        vehicle = items.getItemByCD(self.vehicleDescr.type.compactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ',
                      self.vehicleDescr.type.compactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName,
                                                     tankman.lastUserName,
                                                     tankman.roleLevel)
                tankmenParams.append({
                    'tankmanType':
                    i18n.convert(tankmen.getSkillsConfig()[role].get(
                        'userString', '')),
                    'value':
                    tankmanLabel
                })

            info = {
                'vehicleName':
                vehicle.longUserName,
                'vehicleDiscription':
                vehicle.fullDescription,
                'vehicleImage':
                vehicle.icon,
                'vehicleLevel':
                vehicle.level,
                'vehicleNation':
                vehicle.nationID,
                'vehicleElite':
                vehicle.isElite,
                'vehicleType':
                vehicle.type,
                'VehicleInfoPropsData': [{
                    'name': n,
                    'value': v
                } for n, v in params['parameters']],
                'VehicleInfoBaseData':
                params['base'],
                'VehicleInfoCrewData':
                tankmenParams
            }
            self.as_setVehicleInfoS(info)
            Waiting.hide('updating')
            return
Exemple #16
0
    def getVehicleInfo(self):
        vehicle = self._itemsCache.items.getItemByCD(
            self.__vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ',
                      self.__vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            skillsConfig = tankmen.getSkillsConfig()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    lastUserName = tankman.lastUserName
                    if tankman.skinID != NO_CREW_SKIN_ID and self._lobbyContext.getServerSettings(
                    ).isCrewSkinsEnabled():
                        skinItem = self._itemsCache.items.getCrewSkin(
                            tankman.skinID)
                        lastUserName = i18n.makeString(skinItem.getLastName())
                    tankmanLabel = '%s %s (%d%%)' % (
                        tankman.rankUserName, lastUserName, tankman.roleLevel)
                tankmenParams.append({
                    'tankmanType':
                    i18n.convert(skillsConfig.getSkill(role).userString),
                    'value':
                    tankmanLabel
                })

            roleStr = getRoleTextWithLabel(vehicle.role, vehicle.roleLabel)
            paramsList = formatters.getFormattedParamsList(
                vehicle.descriptor, params['parameters'], excludeRelative=True)
            info = {
                'vehicleName': vehicle.longUserName,
                'vehicleDescription': vehicle.fullDescription,
                'vehicleImage': vehicle.icon,
                'vehicleLevel': vehicle.level,
                'vehicleNation': vehicle.nationID,
                'vehicleElite': vehicle.isElite,
                'vehicleType': vehicle.type,
                'propsData': self.__packParams(paramsList),
                'baseData': params['base'],
                'crewData': tankmenParams,
                'roleStr': roleStr
            }
            self.as_setVehicleInfoS(info)
            return
    def __handleConnectionStatus(self, stage, status, serverMsg, isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = 'LOGGED_ON'
        LOG_DEBUG('__handleConnectionStatus %s %s %s' % (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status == 'DNS_LOOKUP_FAILED':
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status != 'LOGIN_REJECTED_LOGIN_QUEUE':
                    self.__clearAutoLoginTimer()
                if status != 'LOGIN_REJECTED_RATE_LIMITED':
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                if status not in ('LOGIN_REJECTED_INVALID_PASSWORD',):
                    g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR('Handle logon status error: status = %r, message = %r' % (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide('login')

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__kickPeripheryID is not None:
                if self.__kickPeripheryID == -1:
                    msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                elif self.__kickPeripheryID == -2:
                    msg = '#menu:login/status/centerRestart'
                elif self.__kickPeripheryID == -3:
                    msg = '#menu:login/status/versionMismatch'
            elif connectionManager.isVersionsDiffered:
                msg = ''
                self.onHandleUpdateClientSoftwareNeeded()
            self.onSetStatus(i18n.convert(i18n.makeString(msg)), self.ALL_VALID)
            connectionManager.disconnect()
Exemple #18
0
    def updateRoleDropdown(self, nationID, vclass, typeID):
        Waiting.show("updating")
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, vclass, typeID)).values()
        roles = []
        data = [{"id": None, "label": DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll.sort()
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({"id": role[0], "label": convert(getSkillsConfig()[role[0]]["userString"])})

        self.flashObject.as_setRoleDropdown(data)
        Waiting.hide("updating")
        return
Exemple #19
0
    def __setCrewViewModelData(self, tankSlotVM, guiVh):
        crewListVM = tankSlotVM.getCrewList()
        roles = guiVh.descriptor.type.crewRoles
        crew = sortCrew(guiVh.crew, roles)
        skillsConfig = getSkillsConfig()
        isDogInCrew = 'dog' in guiVh.tags
        iconsSmall = self.__icons.tankmen.icons.small
        for slotIdx, tankman in crew:
            tankmanVM = NationChangeTankmanModel()
            if tankman is not None:
                if tankman.skinID != NO_CREW_SKIN_ID and self.__lobbyContext.getServerSettings(
                ).isCrewSkinsEnabled():
                    skinItem = self.__itemsCache.items.getCrewSkin(
                        tankman.skinID)
                    tankmanVM.setImage(
                        iconsSmall.crewSkins.dyn(skinItem.getIconName())())
                else:
                    tankmanVM.setImage(
                        iconsSmall.dyn(
                            getIconResourceName(tankman.extensionLessIcon))())
                tankmanVM.setInvID(tankman.invID)
            else:
                role = roles[slotIdx][0]
                tankmanVM.setImage(
                    self.__icons.tankmen.icons.small.silhouette_mask())
                tankmanVM.setIsSimpleTooltip(True)
                tankmanVM.setSimpleTooltipHeader(
                    convert(skillsConfig.getSkill(role).userString))
                tankmanVM.setSimpleTooltipBody(guiVh.longUserName)
            R.strings.multinational_vehicles.changeScreen.title.header()
            crewListVM.addViewModel(tankmanVM)

        if isDogInCrew:
            tankmanVM = NationChangeTankmanModel()
            dogTooltip = R.strings.tooltips.hangar.crew.rudy.dog.dyn(
                guiVh.nationName)
            tankmanVM.setImage(self.__icons.tankmen.icons.small.ussr_dog_1())
            tankmanVM.setIsSimpleTooltip(True)
            tankmanVM.setSimpleTooltipHeader(backport.text(
                dogTooltip.header()))
            tankmanVM.setSimpleTooltipBody(backport.text(dogTooltip.body()))
            tankmanVM.setIsDog(True)
            crewListVM.addViewModel(tankmanVM)
        if any(
            (tankman[1] is not None for tankman in guiVh.crew)) or isDogInCrew:
            tankSlotVM.setNoCrew(False)
        return
Exemple #20
0
    def __handleConnectionStatus(self, stage, status, serverMsg,
                                 isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = 'LOGGED_ON'
        LOG_DEBUG('__handleConnectionStatus %s %s %s' %
                  (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(
                    status, self.__logOnFailedDefaultHandler)
                if status == 'DNS_LOOKUP_FAILED':
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(
                    status, self.__logOnFailedDefaultHandler)
                if status != 'LOGIN_REJECTED_LOGIN_QUEUE':
                    self.__clearAutoLoginTimer()
                if status != 'LOGIN_REJECTED_RATE_LIMITED':
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR(
                    'Handle logon status error: status = %r, message = %r' %
                    (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide('login')

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__accNotReady:
                msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                self.__accNotReady = False
            self.onSetStatus(i18n.convert(i18n.makeString(msg)),
                             self.ALL_VALID)
            connectionManager.disconnect()
Exemple #21
0
    def onShowRecruitWindow(self, callbackID):
        credits, gold = g_itemsCache.items.stats.money
        upgradeParams = yield DeprecatedStatsRequester().getTankmanCost()
        data = [credits, gold, round(upgradeParams[1]["credits"]), upgradeParams[2]["gold"], len(ROLES)]
        for role in ROLES:
            data.append(role)
            data.append(convert(getSkillsConfig()[role]["userString"]))

        unlocks = yield DeprecatedStatsRequester().getUnlocks()
        modulesAll = yield Requester("vehicle").getFromShop()
        modulesAll.sort()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks:
                data.append(module.type)
                data.append(module.descriptor.type.id[0])
                data.append(module.descriptor.type.id[1])
                data.append(module.descriptor.type.shortUserString)
Exemple #22
0
    def updateRoleDropdown(self, nationID, vclass, typeID):
        Waiting.show('updating')
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, vclass, typeID)).values()
        roles = []
        data = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll.sort()
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({'id': role[0],
                 'label': convert(getSkillsConfig()[role[0]]['userString'])})

        self.flashObject.as_setRoleDropdown(data)
        Waiting.hide('updating')
        return
Exemple #23
0
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{
            'id': None,
            'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW
        }, {
            'id': nationID,
            'label': MENU.nations(nations.NAMES[int(nationID)])
        }]
        classesDP = [{
            'id': None,
            'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW
        }, {
            'id':
            tankType,
            'label':
            DIALOGS.recruitwindow_vehicleclassdropdown(tankType)
        }]
        typesDP = [{'id': None, 'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None, 'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[
                    0] == nationID and module.descriptor.type.id[1] == typeID:
                typesDP.append({
                    'id': module.descriptor.type.id[1],
                    'label': module.descriptor.type.shortUserString
                })
                for role in module.descriptor.type.crewRoles:
                    if role[0] == roleType:
                        rolesDP.append({
                            'id':
                            role[0],
                            'label':
                            convert(getSkillsConfig()[role[0]]['userString'])
                        })

                break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP,
                                            rolesDP)
        return
    def updateRoleDropdown(self, nationID, vclass, typeID):
        Waiting.show('updating')
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        roles = []
        data = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll.sort()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[0] == nationID and module.descriptor.type.id[1] == typeID:
                for role in module.descriptor.type.crewRoles:
                    if role[0] not in roles:
                        roles.append(role[0])
                        data.append({'id': role[0],
                         'label': convert(getSkillsConfig()[role[0]]['userString'])})

        self.flashObject.as_setRoleDropdown(data)
        Waiting.hide('updating')
        return
    def __handleConnectionStatus(self, stage, status, serverMsg, isAutoRegister):
        if self.__onLoggingTryingEndHdlr:
            self.__onLoggingTryingEndHdlr()
        STATUS_LOGGED_ON = "LOGGED_ON"
        LOG_DEBUG("__handleConnectionStatus %s %s %s" % (stage, status, isAutoRegister))
        if stage == 1:
            if status == STATUS_LOGGED_ON:
                handlerFunc = self.__logOnSuccess[status]
            elif isAutoRegister:
                handlerFunc = self.__logAutoRegisterHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status == "DNS_LOOKUP_FAILED":
                    self.onLoginAppFailed(status, serverMsg)
            else:
                handlerFunc = self.__logOnFailedHandlers.get(status, self.__logOnFailedDefaultHandler)
                if status != "LOGIN_REJECTED_LOGIN_QUEUE":
                    self.__clearAutoLoginTimer()
                if status != "LOGIN_REJECTED_RATE_LIMITED":
                    self.__resetLgTimeout()
                self.onCancelQueue(False, False)
                g_preDefinedHosts.clearPeripheryTL()
            try:
                getattr(self, handlerFunc)(status, serverMsg)
            except:
                LOG_ERROR("Handle logon status error: status = %r, message = %r" % (status, serverMsg))
                LOG_CURRENT_EXCEPTION()
                Waiting.hide("login")

            if connectionManager.isUpdateClientSoftwareNeeded():
                self.onHandleUpdateClientSoftwareNeeded()
            elif status != STATUS_LOGGED_ON:
                connectionManager.disconnect()
        elif stage == 6:
            if not self.__kickedFromServer:
                self.onCancelQueue(False, False)
            msg = MENU.LOGIN_STATUS_DISCONNECTED
            if self.__accNotReady:
                msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY
                self.__accNotReady = False
            self.onSetStatus(i18n.convert(i18n.makeString(msg)), self.ALL_VALID)
            connectionManager.disconnect()
Exemple #26
0
    def onShowRecruitWindow(self, callbackID):
        credits, gold = g_itemsCache.items.stats.money
        upgradeParams = yield StatsRequester().getTankmanCost()
        data = [
            credits, gold,
            round(upgradeParams[1]['credits']), upgradeParams[2]['gold'],
            len(ROLES)
        ]
        for role in ROLES:
            data.append(role)
            data.append(convert(getSkillsConfig()[role]['userString']))

        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        modulesAll.sort()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks:
                data.append(module.type)
                data.append(module.descriptor.type.id[0])
                data.append(module.descriptor.type.id[1])
                data.append(module.descriptor.type.shortUserString)
    def onVehicleChanged(self, vehID):
        Waiting.show('updating')
        self.__selectedVehicle = vehID
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(self.__selectedNation, self.__selectedVehClass, self.__selectedVehicle)).values()
        roles = []
        data = [self.__getTankmanRoleEmptyRow()]
        modulesAll.sort()
        selectedIndex = 0
        counter = 0
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({'id': role[0],
                 'label': convert(getSkillsConfig()[role[0]]['userString'])})
                if self.__selectedTmanRole == role[0]:
                    selectedIndex = counter
                counter = counter + 1

        self.as_setTankmanRoleDataS(self.__getSendingData(data, len(data) > 1, selectedIndex))
        Waiting.hide('updating')
        self.onDataChange(self.__selectedNation, self.__selectedVehClass, self.__selectedVehicle, self.__selectedTmanRole)
Exemple #28
0
    def updateRoleDropdown(self, nationID, vclass, typeID):
        Waiting.show('updating')
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        roles = []
        data = [{'id': None, 'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll.sort()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[
                    0] == nationID and module.descriptor.type.id[1] == typeID:
                for role in module.descriptor.type.crewRoles:
                    if role[0] not in roles:
                        roles.append(role[0])
                        data.append({
                            'id':
                            role[0],
                            'label':
                            convert(getSkillsConfig()[role[0]]['userString'])
                        })

        self.flashObject.as_setRoleDropdown(data)
        Waiting.hide('updating')
        return
Exemple #29
0
    def updateTankmen(self):
        Waiting.show('updateTankmen')
        if g_currentVehicle.isPresent():
            tankmen = g_itemsCache.items.getTankmen()
            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (tankmenDescrs[lessMastered] is None or compareMastery(tankmenDescrs[lessMastered].descriptor, tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({'tankmanID': tman.invID if tman is not None else None,
                 'roleType': role,
                 'role': convert(getSkillsConfig()[role]['userString']),
                 'roleIcon': Tankman.getRoleBigIconPath(role),
                 'nationID': vehicle.nationID,
                 'typeID': vehicle.innationID,
                 'slot': slotIdx,
                 'vehicleType': vehicle.shortUserName,
                 'tankType': vehicle.type,
                 'vehicleElite': vehicle.isPremium or vehicle.isPremiumIGR,
                 'roles': list(vehicle.descriptor.type.crewRoles[slotIdx])})

            tankmenData = []
            for tankman in tankmen.itervalues():
                if tankman.isInTank and tankman.vehicleInvID != vehicle.invID:
                    continue
                tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
                bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                skills_count = len(list(ACTIVE_SKILLS))
                skillsList = []
                for skill in tankman.skills:
                    skillsList.append({'tankmanID': tankman.invID,
                     'id': str(tankman.skills.index(skill)),
                     'name': skill.userName,
                     'desc': skill.description,
                     'icon': skill.icon,
                     'level': skill.level,
                     'active': skill.isEnable and skill.isActive})

                newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                if newSkillsCount > 0:
                    skillsList.append({'buy': True,
                     'tankmanID': tankman.invID,
                     'level': lastNewSkillLvl})
                tankmanData = {'firstName': tankman.firstUserName,
                 'lastName': tankman.lastUserName,
                 'rank': tankman.rankUserName,
                 'specializationLevel': tankman.realRoleLevel[0],
                 'role': tankman.roleUserName,
                 'vehicleType': tankmanVehicle.shortUserName,
                 'iconFile': tankman.icon,
                 'rankIconFile': tankman.iconRank,
                 'roleIconFile': Tankman.getRoleBigIconPath(tankman.descriptor.role),
                 'contourIconFile': tankmanVehicle.iconContour,
                 'tankmanID': tankman.invID,
                 'nationID': tankman.nationID,
                 'typeID': tankmanVehicle.innationID,
                 'inTank': tankman.isInTank,
                 'roleType': tankman.descriptor.role,
                 'tankType': tankmanVehicle.type,
                 'efficiencyLevel': tankman.efficiencyRoleLevel,
                 'bonus': bonus_role_level,
                 'lastSkillLevel': tankman.descriptor.lastSkillLevel,
                 'isLessMastered': vehicle.crewIndices.get(tankman.invID) == lessMastered and vehicle.isXPToTman,
                 'compact': tankman.strCD,
                 'availableSkillsCount': skills_count,
                 'skills': skillsList}
                tankmenData.append(tankmanData)

            self.as_tankmenResponseS({'roles': roles,
             'tankmen': tankmenData})
            dogName = ''
            if 'dog' in g_itemsCache.items.getItemByCD(g_currentVehicle.item.intCD).tags:
                dogName = MENU.HANGAR_CREW_RODY_DOG_NAME
            self.as_dogResponseS(dogName)
        Waiting.hide('updateTankmen')
        return
Exemple #30
0
 def description(self):
     """ Returns skill description represented as user-friendly string. """
     return convert(tankmen.getSkillsConfig()[self.name]['description'])
Exemple #31
0
 def doUpdate(self):
     if not BigWorld.wg_quitAndStartLauncher():
         self.__setStatus(i18n.convert(i18n.makeString(MENU.LOGIN_STATUS_LAUNCHERNOTFOUND)), 0)
    def updateTankmen(self, diff=None):
        Waiting.show('updateTankmen')
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            allTankmen = self.itemsCache.items.getTankmen()
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            skillsConfig = getSkillsConfig()
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (
                        tankmenDescrs[lessMastered] is None or
                        compareMastery(tankmenDescrs[lessMastered].descriptor,
                                       tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({
                    'tankmanID':
                    tman.invID if tman is not None else None,
                    'roleType':
                    role,
                    'role':
                    convert(skillsConfig.getSkill(role).userString),
                    'roleIcon':
                    Tankman.getRoleBigIconPath(role),
                    'nationID':
                    vehicle.nationID,
                    'typeID':
                    vehicle.innationID,
                    'slot':
                    slotIdx,
                    'vehicleType':
                    vehicle.shortUserName,
                    'tankType':
                    vehicle.type,
                    'vehicleElite':
                    vehicle.isPremium or vehicle.isPremiumIGR,
                    'roles':
                    list(vehicle.descriptor.type.crewRoles[slotIdx])
                })

            tankmenData = []
            for tankman in allTankmen.itervalues():
                if tankman.isInTank and tankman.vehicleInvID != vehicle.invID:
                    continue
                tankmanVehicle = self.itemsCache.items.getItemByCD(
                    tankman.vehicleNativeDescr.type.compactDescr)
                bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                skills_count = skillsConfig.getNumberOfActiveSkills()
                skillsList = []
                for skill in tankman.skills:
                    skillsList.append({
                        'tankmanID':
                        tankman.invID,
                        'id':
                        str(tankman.skills.index(skill)),
                        'name':
                        skill.userName,
                        'desc':
                        skill.description,
                        'icon':
                        skill.icon,
                        'level':
                        skill.level,
                        'active':
                        skill.isEnable and skill.isActive
                    })

                newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                if newSkillsCount > 0:
                    skillsList.append({
                        'buy': True,
                        'buyCount': newSkillsCount - 1,
                        'tankmanID': tankman.invID,
                        'level': lastNewSkillLvl
                    })
                tankmanData = {
                    'fullName':
                    tankman.fullUserName,
                    'lastName':
                    tankman.lastUserName or tankman.firstUserName,
                    'rank':
                    tankman.rankUserName,
                    'specializationLevel':
                    tankman.realRoleLevel[0],
                    'role':
                    tankman.roleUserName,
                    'vehicleType':
                    tankmanVehicle.shortUserName,
                    'iconFile':
                    tankman.icon,
                    'rankIconFile':
                    tankman.iconRank,
                    'roleIconFile':
                    Tankman.getRoleBigIconPath(tankman.descriptor.role),
                    'contourIconFile':
                    tankmanVehicle.iconContour,
                    'tankmanID':
                    tankman.invID,
                    'nationID':
                    tankman.nationID,
                    'typeID':
                    tankmanVehicle.innationID,
                    'inTank':
                    tankman.isInTank,
                    'roleType':
                    tankman.descriptor.role,
                    'tankType':
                    tankmanVehicle.type,
                    'efficiencyLevel':
                    tankman.efficiencyRoleLevel,
                    'bonus':
                    bonus_role_level,
                    'lastSkillLevel':
                    tankman.descriptor.lastSkillLevel,
                    'isLessMastered':
                    vehicle.crewIndices.get(tankman.invID) == lessMastered
                    and vehicle.isXPToTman,
                    'compact':
                    tankman.strCD,
                    'availableSkillsCount':
                    skills_count,
                    'skills':
                    skillsList
                }
                self.__updateTankmanDataByCrewSkin(tankman, tankmanData)
                tankmenData.append(tankmanData)

            self.as_tankmenResponseS({
                'showRecruit': self._showRecruit,
                'roles': roles,
                'tankmen': tankmenData
            })
            dogName = ''
            if 'dog' in self.itemsCache.items.getItemByCD(
                    g_currentVehicle.item.intCD).tags:
                dogName = backport.text(
                    R.strings.menu.hangar.crew.rody.dog.dyn(
                        vehicle.nationName).name())
            self.as_dogResponseS(dogName)
            tooltipId = TOOLTIPS.HANGAR_CREW_RUDY_DOG + vehicle.nationName
            self.as_setDogTooltipS(tooltipId)
        Waiting.hide('updateTankmen')
        return
Exemple #33
0
def getRankUserName(nationID, rankID):
    return i18n.convert(
        tankmen.getNationConfig(nationID)['ranks'][rankID]['userString'])
Exemple #34
0
def getLastUserName(nationID, lastNameID):
    return i18n.convert(
        tankmen.getNationConfig(nationID)['lastNames'][lastNameID])
Exemple #35
0
def getRankUserName(nationID, rankID):
    return i18n.convert(tankmen.getNationConfig(nationID)['ranks'][rankID]['userString'])
Exemple #36
0
    def updateTankmen(self):
        Waiting.show("updateTankmen")
        if g_currentVehicle.isPresent():
            tankmen = g_itemsCache.items.getTankmen()
            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses["commander"]
            roles = []
            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if (
                    slotIdx > 0
                    and tman is not None
                    and (
                        tankmenDescrs[lessMastered] is None
                        or compareMastery(tankmenDescrs[lessMastered].descriptor, tman.descriptor) > 0
                    )
                ):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append(
                    {
                        "tankmanID": tman.invID if tman is not None else None,
                        "roleType": role,
                        "role": convert(getSkillsConfig()[role]["userString"]),
                        "roleIcon": Tankman.getRoleBigIconPath(role),
                        "nationID": vehicle.nationID,
                        "typeID": vehicle.innationID,
                        "slot": slotIdx,
                        "vehicleType": vehicle.shortUserName,
                        "tankType": vehicle.type,
                        "vehicleElite": vehicle.isPremium or vehicle.isPremiumIGR,
                        "roles": list(vehicle.descriptor.type.crewRoles[slotIdx]),
                    }
                )

            tankmenData = []
            for tankman in tankmen.itervalues():
                if tankman.isInTank and tankman.vehicleInvID != vehicle.invID:
                    continue
                tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
                bonus_role_level = commander_bonus if tankman.descriptor.role != "commander" else 0.0
                skills_count = len(list(ACTIVE_SKILLS))
                skillsList = []
                for skill in tankman.skills:
                    skillsList.append(
                        {
                            "tankmanID": tankman.invID,
                            "id": str(tankman.skills.index(skill)),
                            "name": skill.userName,
                            "desc": skill.description,
                            "icon": skill.icon,
                            "level": skill.level,
                            "active": skill.isEnable and skill.isActive,
                        }
                    )

                newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                if newSkillsCount > 0:
                    skillsList.append({"buy": True, "tankmanID": tankman.invID, "level": lastNewSkillLvl})
                tankmanData = {
                    "firstName": tankman.firstUserName,
                    "lastName": tankman.lastUserName,
                    "rank": tankman.rankUserName,
                    "specializationLevel": tankman.realRoleLevel[0],
                    "role": tankman.roleUserName,
                    "vehicleType": tankmanVehicle.shortUserName,
                    "iconFile": tankman.icon,
                    "rankIconFile": tankman.iconRank,
                    "roleIconFile": Tankman.getRoleBigIconPath(tankman.descriptor.role),
                    "contourIconFile": tankmanVehicle.iconContour,
                    "tankmanID": tankman.invID,
                    "nationID": tankman.nationID,
                    "typeID": tankmanVehicle.innationID,
                    "inTank": tankman.isInTank,
                    "roleType": tankman.descriptor.role,
                    "tankType": tankmanVehicle.type,
                    "efficiencyLevel": tankman.efficiencyRoleLevel,
                    "bonus": bonus_role_level,
                    "lastSkillLevel": tankman.descriptor.lastSkillLevel,
                    "isLessMastered": vehicle.crewIndices.get(tankman.invID) == lessMastered and vehicle.isXPToTman,
                    "compact": tankman.strCD,
                    "availableSkillsCount": skills_count,
                    "skills": skillsList,
                }
                tankmenData.append(tankmanData)

            self.as_tankmenResponseS({"roles": roles, "tankmen": tankmenData})
            dogName = ""
            if "dog" in g_itemsCache.items.getItemByCD(g_currentVehicle.item.intCD).tags:
                dogName = MENU.HANGAR_CREW_RODY_DOG_NAME
            self.as_dogResponseS(dogName)
        Waiting.hide("updateTankmen")
        return
Exemple #37
0
def getSkillIconName(skillName):
    return i18n.convert(tankmen.getSkillsConfig()[skillName]["icon"])
Exemple #38
0
def getFirstUserName(nationID, firstNameID):
    return i18n.convert(tankmen.getNationConfig(nationID)["firstNames"][firstNameID])
Exemple #39
0
def getRoleUserName(role):
    return i18n.convert(tankmen.getSkillsConfig()[role]["userString"])
Exemple #40
0
 def icon(self):
     """ Returns skill icon filename. """
     return convert(tankmen.getSkillsConfig()[self.name]['icon'])
Exemple #41
0
 def onHandleUpdateClientSoftwareNeeded(self):
     success = yield DialogsInterface.showI18nConfirmDialog('updateNeeded')
     if success and not BigWorld.wg_quitAndStartLauncher():
         self.__setStatus(i18n.convert(i18n.makeString(MENU.LOGIN_STATUS_LAUNCHERNOTFOUND)), 0)
Exemple #42
0
def getFirstUserName(nationID, firstNameID):
    return i18n.convert(
        tankmen.getNationConfig(nationID)['firstNames'][firstNameID])
Exemple #43
0
def getRankUserName(nationID, rankID):
    return i18n.convert(tankmen.getNationConfig(nationID)["ranks"][rankID]["userString"])
Exemple #44
0
def getRoleUserName(role):
    return i18n.convert(tankmen.getSkillsConfig()[role]['userString'])
Exemple #45
0
    def updateTankmen(self):
        Waiting.show('updateTankmen')
        tankmen = yield Requester('tankman').getFromInventory()
        vehicles = yield Requester('vehicle').getFromInventory()
        vehicle = None
        if g_currentVehicle.isPresent():
            for veh in vehicles:
                if veh.inventoryId == g_currentVehicle.invID:
                    vehicle = veh
                    break

            if vehicle is None:
                LOG_ERROR('Vehicle not found', g_currentVehicle.invID)
                Waiting.hide('updateTankmen')
                return
            crew = []
            for tId in vehicle.crew:
                if tId is None:
                    crew.append(None)
                    continue
                for tankman in tankmen:
                    if tankman.inventoryId == tId:
                        crew.append(tankman)

            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            brotherhood_bonus = getSkillsConfig()['brotherhood']['crewLevelIncrease']
            for t in crew:
                if t is None or 'brotherhood' not in t.skills or t.skills.index('brotherhood') == len(t.skills) - 1 and t.lastSkillLevel != 100:
                    brotherhood_bonus = 0
                    break

            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (tankmenDescrs[lessMastered] is None or compareMastery(tankmenDescrs[lessMastered].descriptor, tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({'tankmanID': tman.invID if tman is not None else None,
                 'roleType': role,
                 'role': convert(getSkillsConfig()[role]['userString']),
                 'roleIcon': '%s/%s' % (Tankman.ROLE_ICON_PATH_BIG, getSkillsConfig()[role]['icon']),
                 'nationID': vehicle.nationID,
                 'typeID': vehicle.innationID,
                 'slot': slotIdx,
                 'vehicleType': vehicle.shortUserName,
                 'tankType': vehicle.type,
                 'vehicleElite': vehicle.isPremium,
                 'roles': list(vehicle.descriptor.type.crewRoles[slotIdx])})

            tankmenData = []
            crewIDs = vehicle.crewIndices.keys()
            for tankman in tankmen:
                if not tankman.isInTank or tankman.inventoryId in crewIDs:
                    bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                    skills_count = len(list(ACTIVE_SKILLS))
                    skillsList = []
                    for skill in tankman.skills:
                        skillLevel = tankman.lastSkillLevel if tankman.skills.index(skill) == len(tankman.skills) - 1 else 100
                        skillsList.append({'tankmanID': tankman.inventoryId,
                         'id': skill,
                         'name': getSkillsConfig()[skill]['userString'],
                         'desc': getSkillsConfig()[skill]['description'],
                         'icon': getSkillsConfig()[skill]['icon'],
                         'level': tankman.lastSkillLevel,
                         'active': skill not in PERKS or skill == 'brotherhood' and brotherhood_bonus != 0 or skill != 'brotherhood' and skillLevel == 100})

                    newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                    if newSkillsCount > 0:
                        skillsList.append({'buy': True,
                         'tankmanID': tankman.inventoryId,
                         'level': lastNewSkillLvl})
                    tankmanData = {'firstname': tankman.firstname,
                     'lastname': tankman.lastname,
                     'rank': tankman.rank,
                     'specializationLevel': tankman.roleLevel,
                     'role': tankman.role,
                     'vehicleType': tankman.vehicle.type.shortUserString,
                     'iconFile': tankman.icon,
                     'rankIconFile': tankman.iconRank,
                     'roleIconFile': '%s/%s' % (Tankman.ROLE_ICON_PATH_BIG, tankman.iconRole),
                     'contourIconFile': tankman.vehicleIconContour,
                     'tankmanID': tankman.inventoryId,
                     'nationID': tankman.nation,
                     'typeID': tankman.vehicle.type.id[1],
                     'inTank': tankman.isInTank,
                     'roleType': tankman.descriptor.role,
                     'tankType': tankman.vehicleType,
                     'efficiencyLevel': tankman.efficiencyRoleLevel(vehicle.descriptor),
                     'bonus': bonus_role_level,
                     'lastSkillLevel': tankman.lastSkillLevel,
                     'isLessMastered': vehicle.crewIndices.get(tankman.inventoryId) == lessMastered and vehicle.isXPToTman,
                     'compact': tankman.pack(),
                     'availableSkillsCount': skills_count,
                     'skills': skillsList}
                    tankmenData.append(tankmanData)

            self.as_tankmenResponseS(roles, tankmenData)
        Waiting.hide('updateTankmen')
        return
Exemple #46
0
def getSkillIconName(skillName):
    return i18n.convert(tankmen.getSkillsConfig()[skillName]['icon'])
Exemple #47
0
    def updateTankmen(self):
        Waiting.show('updateTankmen')
        if g_currentVehicle.isPresent():
            tankmen = g_itemsCache.items.getTankmen()
            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (
                        tankmenDescrs[lessMastered] is None or
                        compareMastery(tankmenDescrs[lessMastered].descriptor,
                                       tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({
                    'tankmanID':
                    tman.invID if tman is not None else None,
                    'roleType':
                    role,
                    'role':
                    convert(getSkillsConfig()[role]['userString']),
                    'roleIcon':
                    Tankman.getRoleBigIconPath(role),
                    'nationID':
                    vehicle.nationID,
                    'typeID':
                    vehicle.innationID,
                    'slot':
                    slotIdx,
                    'vehicleType':
                    vehicle.shortUserName,
                    'tankType':
                    vehicle.type,
                    'vehicleElite':
                    vehicle.isPremium or vehicle.isPremiumIGR,
                    'roles':
                    list(vehicle.descriptor.type.crewRoles[slotIdx])
                })

            tankmenData = []
            for tankman in tankmen.itervalues():
                if tankman.isInTank and tankman.vehicleInvID != vehicle.invID:
                    continue
                tankmanVehicle = g_itemsCache.items.getItemByCD(
                    tankman.vehicleNativeDescr.type.compactDescr)
                bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                skills_count = len(list(ACTIVE_SKILLS))
                skillsList = []
                for skill in tankman.skills:
                    skillsList.append({
                        'tankmanID':
                        tankman.invID,
                        'id':
                        str(tankman.skills.index(skill)),
                        'name':
                        skill.userName,
                        'desc':
                        skill.description,
                        'icon':
                        skill.icon,
                        'level':
                        skill.level,
                        'active':
                        skill.isEnable and skill.isActive
                    })

                newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                if newSkillsCount > 0:
                    skillsList.append({
                        'buy': True,
                        'buyCount': newSkillsCount - 1,
                        'tankmanID': tankman.invID,
                        'level': lastNewSkillLvl
                    })
                tankmanData = {
                    'firstName':
                    tankman.firstUserName,
                    'lastName':
                    tankman.lastUserName,
                    'rank':
                    tankman.rankUserName,
                    'specializationLevel':
                    tankman.realRoleLevel[0],
                    'role':
                    tankman.roleUserName,
                    'vehicleType':
                    tankmanVehicle.shortUserName,
                    'iconFile':
                    tankman.icon,
                    'rankIconFile':
                    tankman.iconRank,
                    'roleIconFile':
                    Tankman.getRoleBigIconPath(tankman.descriptor.role),
                    'contourIconFile':
                    tankmanVehicle.iconContour,
                    'tankmanID':
                    tankman.invID,
                    'nationID':
                    tankman.nationID,
                    'typeID':
                    tankmanVehicle.innationID,
                    'inTank':
                    tankman.isInTank,
                    'roleType':
                    tankman.descriptor.role,
                    'tankType':
                    tankmanVehicle.type,
                    'efficiencyLevel':
                    tankman.efficiencyRoleLevel,
                    'bonus':
                    bonus_role_level,
                    'lastSkillLevel':
                    tankman.descriptor.lastSkillLevel,
                    'isLessMastered':
                    vehicle.crewIndices.get(tankman.invID) == lessMastered
                    and vehicle.isXPToTman,
                    'compact':
                    tankman.strCD,
                    'availableSkillsCount':
                    skills_count,
                    'skills':
                    skillsList
                }
                tankmenData.append(tankmanData)

            self.as_tankmenResponseS({'roles': roles, 'tankmen': tankmenData})
            dogName = ''
            if 'dog' in g_itemsCache.items.getItemByCD(
                    g_currentVehicle.item.intCD).tags:
                dogName = MENU.HANGAR_CREW_RODY_DOG_NAME
            self.as_dogResponseS(dogName)
        Waiting.hide('updateTankmen')
        return
Exemple #48
0
 def rankUserName(self):
     """ Tankman's rank represented as user-friendly string. """
     return convert(tankmen.getNationConfig(self.nationID)['ranks'][self.descriptor.rankID]['userString'])
Exemple #49
0
 def __setText(self, name, type, health):
     text = i18n.convert(self.__msgCaption % {'name': name,
      'type': type,
      'health': health})
     Aim._flashCall(self, 'updatePlayerInfo', [text])
Exemple #50
0
    def updateTankmen(self):
        Waiting.show('updateTankmen')
        tankmen = yield Requester('tankman').getFromInventory()
        vehicles = yield Requester('vehicle').getFromInventory()
        vehicle = None
        if g_currentVehicle.isPresent():
            for veh in vehicles:
                if veh.inventoryId == g_currentVehicle.invID:
                    vehicle = veh
                    break

            if vehicle is None:
                LOG_ERROR('Vehicle not found', g_currentVehicle.invID)
                Waiting.hide('updateTankmen')
                return
            crew = []
            for tId in vehicle.crew:
                if tId is None:
                    crew.append(None)
                    continue
                for tankman in tankmen:
                    if tankman.inventoryId == tId:
                        crew.append(tankman)

            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            brotherhood_bonus = getSkillsConfig(
            )['brotherhood']['crewLevelIncrease']
            for t in crew:
                if t is None or 'brotherhood' not in t.skills or t.skills.index(
                        'brotherhood') == len(
                            t.skills) - 1 and t.lastSkillLevel != 100:
                    brotherhood_bonus = 0
                    break

            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (
                        tankmenDescrs[lessMastered] is None or
                        compareMastery(tankmenDescrs[lessMastered].descriptor,
                                       tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({
                    'tankmanID':
                    tman.invID if tman is not None else None,
                    'roleType':
                    role,
                    'role':
                    convert(getSkillsConfig()[role]['userString']),
                    'roleIcon':
                    '%s/%s' % (Tankman.ROLE_ICON_PATH_BIG,
                               getSkillsConfig()[role]['icon']),
                    'nationID':
                    vehicle.nationID,
                    'typeID':
                    vehicle.innationID,
                    'slot':
                    slotIdx,
                    'vehicleType':
                    vehicle.shortUserName,
                    'tankType':
                    vehicle.type,
                    'vehicleElite':
                    vehicle.isPremium,
                    'roles':
                    list(vehicle.descriptor.type.crewRoles[slotIdx])
                })

            tankmenData = []
            crewIDs = vehicle.crewIndices.keys()
            for tankman in tankmen:
                if not tankman.isInTank or tankman.inventoryId in crewIDs:
                    bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                    skills_count = len(list(ACTIVE_SKILLS))
                    skillsList = []
                    for skill in tankman.skills:
                        skillLevel = tankman.lastSkillLevel if tankman.skills.index(
                            skill) == len(tankman.skills) - 1 else 100
                        skillsList.append({
                            'tankmanID':
                            tankman.inventoryId,
                            'id':
                            skill,
                            'name':
                            getSkillsConfig()[skill]['userString'],
                            'desc':
                            getSkillsConfig()[skill]['description'],
                            'icon':
                            getSkillsConfig()[skill]['icon'],
                            'level':
                            tankman.lastSkillLevel,
                            'active':
                            skill not in PERKS or skill == 'brotherhood'
                            and brotherhood_bonus != 0
                            or skill != 'brotherhood' and skillLevel == 100
                        })

                    newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                    if newSkillsCount > 0:
                        skillsList.append({
                            'buy': True,
                            'tankmanID': tankman.inventoryId,
                            'level': lastNewSkillLvl
                        })
                    tankmanData = {
                        'firstname':
                        tankman.firstname,
                        'lastname':
                        tankman.lastname,
                        'rank':
                        tankman.rank,
                        'specializationLevel':
                        tankman.roleLevel,
                        'role':
                        tankman.role,
                        'vehicleType':
                        tankman.vehicle.type.shortUserString,
                        'iconFile':
                        tankman.icon,
                        'rankIconFile':
                        tankman.iconRank,
                        'roleIconFile':
                        '%s/%s' %
                        (Tankman.ROLE_ICON_PATH_BIG, tankman.iconRole),
                        'contourIconFile':
                        tankman.vehicleIconContour,
                        'tankmanID':
                        tankman.inventoryId,
                        'nationID':
                        tankman.nation,
                        'typeID':
                        tankman.vehicle.type.id[1],
                        'inTank':
                        tankman.isInTank,
                        'roleType':
                        tankman.descriptor.role,
                        'tankType':
                        tankman.vehicleType,
                        'efficiencyLevel':
                        tankman.efficiencyRoleLevel(vehicle.descriptor),
                        'bonus':
                        bonus_role_level,
                        'lastSkillLevel':
                        tankman.lastSkillLevel,
                        'isLessMastered':
                        vehicle.crewIndices.get(tankman.inventoryId)
                        == lessMastered and vehicle.isXPToTman,
                        'compact':
                        tankman.pack(),
                        'availableSkillsCount':
                        skills_count,
                        'skills':
                        skillsList
                    }
                    tankmenData.append(tankmanData)

            self.as_tankmenResponseS(roles, tankmenData)
        Waiting.hide('updateTankmen')
        return
Exemple #51
0
 def lastUserName(self):
     """ Tankman's lastname represented as user-friendly string. """
     return convert(
         tankmen.getNationConfig(
             self.nationID)['lastNames'][self.descriptor.lastNameID])
Exemple #52
0
 def lastUserName(self):
     """ Tankman's lastname represented as user-friendly string. """
     return convert(tankmen.getNationConfig(self.nationID)['lastNames'][self.descriptor.lastNameID])
Exemple #53
0
 def rankUserName(self):
     """ Tankman's rank represented as user-friendly string. """
     return convert(
         tankmen.getNationConfig(
             self.nationID)['ranks'][self.descriptor.rankID]['userString'])
Exemple #54
0
 def roleUserName(self):
     """ Tankman's role represented as user-friendly string. """
     return convert(tankmen.getSkillsConfig()[self.descriptor.role]['userString'])
Exemple #55
0
 def roleUserName(self):
     """ Tankman's role represented as user-friendly string. """
     return convert(
         tankmen.getSkillsConfig()[self.descriptor.role]['userString'])
Exemple #56
0
 def icon(self):
     """ Returns skill icon filename. """
     return convert(tankmen.getSkillsConfig()[self.name]['icon'])
Exemple #57
0
 def description(self):
     """ Returns skill description represented as user-friendly string. """
     return convert(tankmen.getSkillsConfig()[self.name]['description'])
Exemple #58
0
 def __screenshotNotifyCallback(self, path):
     SystemMessages.pushMessage(convert(makeString('#menu:screenshot/save')) % {'path': path}, SystemMessages.SM_TYPE.Information)
Exemple #59
0
def getLastUserName(nationID, lastNameID):
    return i18n.convert(tankmen.getNationConfig(nationID)["lastNames"][lastNameID])