• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python shared_utils.findFirst函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shared_utils.findFirst函数的典型用法代码示例。如果您正苦于以下问题:Python findFirst函数的具体用法?Python findFirst怎么用?Python findFirst使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了findFirst函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _getValue

 def _getValue(self):
     result = list()
     shell = self._tooltip.item
     configuration = self._tooltip.context.getParamsConfiguration(shell)
     vehicle = configuration.vehicle
     params = configuration.params
     historicalBattleID = configuration.historicalBattleID
     battle = g_eventsCache.getHistoricalBattles().get(historicalBattleID)
     vDescr = vehicle.descriptor if vehicle is not None else None
     vCompDescr = vehicle.intCD if vehicle is not None else None
     if vehicle is not None and battle is not None and battle.canParticipateWith(vCompDescr):
         vDescr = battle.getVehicleModifiedDescr(vehicle)
     result.append([])
     if params:
         result = [ItemsParameters.g_instance.getParameters(shell.descriptor, vDescr)]
     result.append([])
     if vehicle is not None:
         gun = VehicleItem(vDescr.gun)
         vehicleShell = findFirst(lambda s: s.intCD == shell.intCD, vehicle.shells)
         shellCount = vehicleShell.count if vehicleShell else getattr(shell, 'count', 0)
         if battle is not None and battle.canParticipateWith(vCompDescr):
             _, shellCount = findFirst(lambda x: x[0].intCD == shell.intCD, battle.getShellsLayout(vCompDescr), (None, 0))
         result[-1].append({'label': 'ammo',
          'current': shellCount,
          'total': gun.descriptor['maxAmmo']})
     return result
开发者ID:webiumsk,项目名称:WOT0.9.10,代码行数:26,代码来源:shell.py


示例2: parseTag

 def parseTag(self, pyGlooxTag):
     igrID, igrRoomID, gameHost, arenaLabel = (0, 0, '', '')
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix='igr-id')))
     if tag:
         igrID = tag.getCData()
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix='igr-room-id')))
     if tag:
         igrRoomID = tag.getCData()
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix='game-host')))
     if tag:
         gameHost = tag.getCData()
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix='arena-label')))
     if tag:
         arenaLabel = tag.getCData()
     return makeClientInfo(igrID, igrRoomID, gameHost, arenaLabel)
开发者ID:webiumsk,项目名称:WOT0.9.10,代码行数:15,代码来源:wg_items.py


示例3: onUnitSettingChanged

 def onUnitSettingChanged(self, opCode, value):
     if opCode == UNIT_OP.CHANGE_FALLOUT_TYPE:
         rosterType = self.unitFunctional.getRosterType()
         self.__battleType, _ = findFirst(lambda (k, v): v == rosterType, FALLOUT_QUEUE_TYPE_TO_ROSTER.iteritems(), (QUEUE_TYPE.UNKNOWN, None))
         self.__updateVehicles()
         self._proxy.onSettingsChanged()
     return
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:7,代码来源:fallout_controller.py


示例4: __onItemsChanged

 def __onItemsChanged(self, updateReason, invalidItems):
     vehiclesDiff = invalidItems.get(GUI_ITEM_TYPE.VEHICLE)
     if vehiclesDiff is not None:
         falloutVehicle = findFirst(lambda v: v.intCD in vehiclesDiff, getFalloutCtrl().getSelectedVehicles())
         if falloutVehicle is not None:
             self.__updatePrebattleControls()
     return
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:7,代码来源:lobbyheader.py


示例5: cancel

 def cancel(self):
     item = findFirst(lambda item: item.getStage() == EQUIPMENT_STAGES.PREPARING, self._equipments.itervalues())
     if item is not None:
         item.deactivate()
         return True
     else:
         return False
开发者ID:webiumsk,项目名称:WOT0.10.0,代码行数:7,代码来源:equipment_ctrl.py


示例6: validateVehicles

    def validateVehicles(self, vInfos, flags):
        from gui.shared.gui_items.Vehicle import Vehicle

        if not findFirst(lambda v: not v.isEmpty(), vInfos, False):
            return (False, UNIT_RESTRICTION.FALLOUT_VEHICLE_MIN)
        else:
            for vInfo in vInfos:
                vehicle = vInfo.getVehicle()
                if vehicle is None:
                    continue
                isReadyToBattle = vehicle.isReadyToPrebattle(checkForRent=not flags.isInPreArena())
                if vehicle and not isReadyToBattle:
                    if vehicle.isBroken:
                        return (False, UNIT_RESTRICTION.VEHICLE_BROKEN)
                    if not vehicle.isCrewFull:
                        return (False, UNIT_RESTRICTION.VEHICLE_CREW_NOT_FULL)
                    if not flags.isInPreArena() and vehicle.rentalIsOver:
                        return (False, UNIT_RESTRICTION.VEHICLE_RENT_IS_OVER)
                    if vehicle.isInBattle:
                        return (False, UNIT_RESTRICTION.VEHICLE_IS_IN_BATTLE)
                    isGroupReady, state = vehicle.isGroupReady()
                    if not isGroupReady:
                        if state == Vehicle.VEHICLE_STATE.FALLOUT_REQUIRED:
                            return (False, UNIT_RESTRICTION.FALLOUT_VEHICLE_LEVEL_REQUIRED)
                        if state == Vehicle.VEHICLE_STATE.FALLOUT_MIN:
                            return (False, UNIT_RESTRICTION.FALLOUT_VEHICLE_MIN)
                        if state == Vehicle.VEHICLE_STATE.FALLOUT_MAX:
                            return (False, UNIT_RESTRICTION.FALLOUT_VEHICLE_MAX)
                        if state == Vehicle.VEHICLE_STATE.FALLOUT_BROKEN:
                            return (False, UNIT_RESTRICTION.FALLOUT_VEHICLE_BROKEN)
                    return (False, UNIT_RESTRICTION.VEHICLE_NOT_VALID)

            return (True, UNIT_RESTRICTION.UNDEFINED)
开发者ID:aevitas,项目名称:wotsdk,代码行数:33,代码来源:restrictionslimits.py


示例7: __updateUsersData

    def __updateUsersData(self, userDBIDs):
        diff = []
        userGetter = storage_getter('users')().getUser
        colorGetter = g_settings.getColorScheme('rosters').getColors
        for userDBID in userDBIDs:
            data = findFirst(lambda d: d['creator'].get('dbID') == userDBID, self.collection)
            if data is not None:
                clubDBID = data['cfdUnitID']
                try:
                    index = self.mapping[clubDBID]
                    item = self.collection[index]
                except (KeyError, IndexError):
                    LOG_ERROR('Item not found', clubDBID)
                    continue

                creator = userGetter(userDBID)
                creatorVO = makeUserVO(creator, colorGetter)
                creatorName = creator.getName()
                item.update({'creatorName': creatorName,
                 'rating': self.getGuiUserRating(userDBID)})
                if creator.hasValidName():
                    item['creator'] = creatorVO
                diff.append(index)

        if len(diff):
            self.updateItems(diff)
        return
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:27,代码来源:rally_dps.py


示例8: isTransportationAvailable

    def isTransportationAvailable(self):
        forImport = self.getBuildingsAvailableForImport()

        def filter(item):
            return len(self.getBuildingsAvailableForExport(item)) > 0

        return findFirst(filter, forImport) is not None
开发者ID:aevitas,项目名称:wotsdk,代码行数:7,代码来源:clientclientfortifiedregion.py


示例9: itemOnVehicleComparator

def itemOnVehicleComparator(vehicle, item):
    vehicleParams = params.VehicleParams(vehicle).getParamsDict()
    withItemParams = vehicleParams
    mayInstall, reason = vehicle.descriptor.mayInstallComponent(item.intCD)
    if item.itemTypeID == ITEM_TYPES.vehicleTurret:
        mayInstall, reason = vehicle.descriptor.mayInstallTurret(item.intCD, vehicle.gun.intCD)
        if not mayInstall:
            properGun = findFirst(lambda gun: vehicle.descriptor.mayInstallComponent(gun['compactDescr'])[0], item.descriptor['guns'])
            if properGun is not None:
                removedModules = vehicle.descriptor.installTurret(item.intCD, properGun['compactDescr'])
                withItemParams = params.VehicleParams(vehicle).getParamsDict()
                vehicle.descriptor.installTurret(*removedModules)
            else:
                LOG_ERROR('not possible to install turret', item, reason)
        else:
            removedModules = vehicle.descriptor.installTurret(item.intCD, vehicle.gun.intCD)
            withItemParams = params.VehicleParams(vehicle).getParamsDict()
            vehicle.descriptor.installTurret(*removedModules)
    elif not mayInstall and reason == 'not for current vehicle' and item.itemTypeID == ITEM_TYPES.vehicleGun:
        turret = g_paramsCache.getPrecachedParameters(item.intCD).getTurretsForVehicle(vehicle.intCD)[0]
        removedModules = vehicle.descriptor.installTurret(turret, vehicle.gun.intCD)
        vehicleParams = params.VehicleParams(vehicle).getParamsDict()
        vehicle.descriptor.installTurret(turret, item.intCD)
        withItemParams = params.VehicleParams(vehicle).getParamsDict()
        vehicle.descriptor.installTurret(*removedModules)
    else:
        removedModule = vehicle.descriptor.installComponent(item.intCD)
        withItemParams = params.VehicleParams(vehicle).getParamsDict()
        vehicle.descriptor.installComponent(removedModule[0])
    return VehiclesComparator(withItemParams, vehicleParams)
开发者ID:aevitas,项目名称:wotsdk,代码行数:30,代码来源:items_parametersparams_helper.py


示例10: updateList

    def updateList(self):
        directions = []
        openedDirectionsCount = len(self.fortCtrl.getFort().getOpenedDirections())
        fightsForDirections = self.fortCtrl.getFort().getDirectionsInBattle()
        for direction in range(1, g_fortCache.maxDirections + 1):
            buildings = self.fortCtrl.getFort().getBuildingsByDirections().get(direction)
            isOpened = buildings is not None
            inBattle = direction in fightsForDirections
            canBeClosed = isOpened and not inBattle and findFirst(lambda b: b is not None, buildings) is None
            buildingsData = []
            if isOpened:
                for building in buildings:
                    data = None
                    if building is not None:
                        uid = self.getBuildingUIDbyID(building.typeID)
                        data = {'uid': uid,
                         'progress': self._getProgress(building.typeID, building.level),
                         'toolTipData': [i18n.makeString('#fortifications:Buildings/buildingName/%s' % uid), self.getCommonBuildTooltipData(building)],
                         'iconSource': FortViewHelper.getSmallIconSource(uid, building.level)}
                    buildingsData.append(data)

            directions.append({'uid': direction,
             'fullName': i18n.makeString('#fortifications:General/direction', value=i18n.makeString('#fortifications:General/directionName%d' % direction)),
             'isOpened': isOpened,
             'canBeClosed': canBeClosed,
             'closeButtonVisible': isOpened and openedDirectionsCount > 1,
             'buildings': buildingsData})

        self.as_setDirectionsS(directions)
        return
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:30,代码来源:fortcreatedirectionwindow.py


示例11: getShellsLayoutPrice

    def getShellsLayoutPrice(self):
        """
        @return: price that should be paid to fill layout
        """
        goldPrice = 0
        creditsPrice = 0
        if self.shellsLayout is None:
            return (creditsPrice, goldPrice)
        else:
            for shellCompDescr, count, isBoughtForCredits in LayoutIterator(self.shellsLayout):
                if not shellCompDescr or not count:
                    continue
                shell = g_itemsCache.items.getItemByCD(int(shellCompDescr))
                vehShell = findFirst(lambda s: s.intCD == shellCompDescr, self.vehicle.shells)
                vehCount = vehShell.count if vehShell is not None else 0
                buyCount = count - shell.inventoryCount - vehCount
                if buyCount:
                    if shell.buyPrice[1] and not isBoughtForCredits:
                        goldPrice += shell.buyPrice[1] * buyCount
                    elif shell.buyPrice[1] and isBoughtForCredits:
                        creditsPrice += shell.buyPrice[1] * buyCount * g_itemsCache.items.shop.exchangeRateForShellsAndEqs
                    elif shell.buyPrice[0]:
                        creditsPrice += shell.buyPrice[0] * buyCount

            return (creditsPrice, goldPrice)
开发者ID:webiumsk,项目名称:WOT-0.9.12-CT,代码行数:25,代码来源:vehicle.py


示例12: canSelectVehicle

 def canSelectVehicle(self, vehicle):
     if not self.isSelected():
         return (False, '')
     cfg = self.getConfig()
     if findFirst(lambda v: v.level == cfg.vehicleLevelRequired, self.getSelectedVehicles()) is None and vehicle.level != cfg.vehicleLevelRequired:
         return (False, i18n.makeString(FALLOUT.TANKCAROUSELSLOT_SELECTIONBUTTONTOOLTIP, requiredLevel=int2roman(cfg.vehicleLevelRequired), level=toRomanRangeString(list(cfg.allowedLevels - {cfg.vehicleLevelRequired}), 1)))
     return (True, '')
开发者ID:kblw,项目名称:wot_client,代码行数:7,代码来源:fallout_controller.py


示例13: setPlayerAssistResult

 def setPlayerAssistResult(self, assistType, details):
     if not self.__isPEEnabled:
         return
     else:
         eventID = None
         series = 1
         if assistType == _SET.SPOTTED:
             eventID = _EVENT_ID.PLAYER_SPOTTED_ENEMY
             series = self.__getSeries(details)
         elif assistType in (_SET.RADIO_HIT_ASSIST, _SET.RADIO_KILL_ASSIST, _SET.TRACK_ASSIST):
             if assistType == _SET.TRACK_ASSIST:
                 series = self.__getSeries(details)
             eventID = _EVENT_ID.PLAYER_ASSIST_TO_KILL_ENEMY
         elif assistType == _SET.BASE_CAPTURE_POINTS:
             eventID = _EVENT_ID.PLAYER_CAPTURED_BASE
         elif assistType == _SET.BASE_CAPTURE_DROPPED:
             eventID = _EVENT_ID.PLAYER_DROPPED_CAPTURE
         elif assistType == _SET.TANKING:
             eventID = _EVENT_ID.PLAYER_USED_ARMOR
             series = findFirst(None, details, default=1)
         else:
             LOG_CODEPOINT_WARNING(assistType)
         if eventID:
             self.__pushPlayerEvent(eventID, series)
         return
开发者ID:webiumsk,项目名称:WOT-0.9.12-CT,代码行数:25,代码来源:battle_feedback.py


示例14: parseTag

 def parseTag(self, pyGlooxTag):
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix='status')))
     code = self.getDefaultData()
     if tag is not None:
         found = tag.findAttribute('code')
         if found and found.isdigit():
             code = int(found)
     return code
开发者ID:aevitas,项目名称:wotsdk,代码行数:8,代码来源:extensionserror.py


示例15: parseTag

 def parseTag(self, pyGlooxTag):
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix='count')))
     if tag:
         count = int(tag.getCData())
     else:
         count = 0
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix='first')))
     if tag:
         first = self._converter(tag.getCData())
     else:
         first = None
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix='last')))
     if tag:
         last = self._converter(tag.getCData())
     else:
         last = None
     return (count, first, last)
开发者ID:webiumsk,项目名称:WOT-0.9.15.1,代码行数:17,代码来源:rsm.py


示例16: _getValidatedVehicles

 def _getValidatedVehicles(vInfos):
     if not findFirst(lambda v: not v.isEmpty(), vInfos, False):
         if g_currentVehicle.isPresent():
             vehicle = g_currentVehicle.item
             vInfos = (unit_items.VehicleInfo(vehicle.invID, vehicle.intCD, vehicle.level),)
         else:
             vInfos = (unit_items.VehicleInfo(),)
     return vInfos
开发者ID:aevitas,项目名称:wotsdk,代码行数:8,代码来源:restrictionslimits.py


示例17: getBackgroundImage

 def getBackgroundImage(self):
     if self.__potapovQuest.getQuestBranch() == potapov_quests.PQ_BRANCH.FALLOUT:
         return _BG_IMG_FALLOUT[self.__potapovQuest.getMajorTag()]
     else:
         vehType = findFirst(None, self.__potapovQuest.getVehicleClasses())
         if vehType in _BG_IMG_BY_VEH_TYPE:
             return _BG_IMG_BY_VEH_TYPE[vehType]
         return random.choice(_BG_IMG_BY_VEH_TYPE.values())
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:8,代码来源:awards.py


示例18: __getNextMotiveQuest

    def __getNextMotiveQuest(self):
        quests = g_eventsCache.getMotiveQuests(lambda q: q.isAvailable() and not q.isCompleted())
        sortedQuests = sorted(quests.values(), key=lambda q: q.getPriority())
        nextQuest = findFirst(None, sortedQuests)
        for quest in sortedQuests:
            if quest.getPriority() > self.__quest.getPriority():
                return quest

        return nextQuest
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:9,代码来源:awards.py


示例19: __updateQuests

 def __updateQuests(self):
     self.__clearQuestsData()
     refSystemQuests = g_eventsCache.getHiddenQuests(lambda x: x.getType() == EVENT_TYPE.REF_SYSTEM_QUEST)
     if refSystemQuests:
         self.__quests = self.__mapQuests(refSystemQuests.values())
         self.__totalXP, _ = self.__quests[-1]
         notCompleted = findFirst(lambda q: not q.isCompleted(), refSystemQuests.values())
         self.__isTotallyCompleted = notCompleted is None
     self.onQuestsUpdated()
开发者ID:kblw,项目名称:wot_client,代码行数:9,代码来源:refsystem.py


示例20: parseTag

 def parseTag(self, pyGlooxTag):
     info = self.getDefaultData()
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix="nickname")))
     if tag:
         info["name"] = tag.getCData()
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix="userid")))
     if tag:
         info["dbID"] = long(tag.getCData())
     clanDBID, clanAbbrev = (0, "")
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix="clanid")))
     if tag:
         clanDBID = tag.getCData()
     tag = findFirst(None, pyGlooxTag.filterXPath(self.getXPath(suffix="clantag")))
     if tag:
         clanAbbrev = tag.getCData()
     if clanDBID and clanAbbrev:
         info["clanInfo"] = makeClanInfo(clanDBID, clanAbbrev)
     return info
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:18,代码来源:wg_items.py



注:本文中的shared_utils.findFirst函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shared_utils.forEach函数代码示例发布时间:2022-05-27
下一篇:
Python shared_jinja.get函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap