Ejemplo n.º 1
0
 def __setClanInfo(self, clanInfo):
     if not isPlayerAccount():
         return
     else:
         name = BigWorld.player().name
         if clanInfo and len(clanInfo) > 1:
             clanAbbrev = clanInfo[1]
         else:
             clanAbbrev = None
         hasNew = not AccountSettings.getFilter(BOOSTERS)['wasShown']
         activeBoosters = g_goodiesCache.getBoosters(
             criteria=REQ_CRITERIA.BOOSTER.ACTIVE).values()
         hasActiveBooster = len(activeBoosters) > 0
         readyBoosters = g_goodiesCache.getBoosters(
             criteria=REQ_CRITERIA.BOOSTER.IS_READY_TO_ACTIVATE).values()
         boostersAvailable = sum(
             (booster.count for booster in readyBoosters))
         hasAvailableBoosters = boostersAvailable > 0
         boosterIcon, boosterText = (None, None)
         if hasActiveBooster:
             boosterIcon = RES_ICONS.MAPS_ICONS_BOOSTERS_ACTIVEBOOSTERICON
             booster = sorted(activeBoosters,
                              key=lambda x: x.getUsageLeftTime())[0]
             boosterText = booster.getShortLeftTimeStr()
         elif hasAvailableBoosters:
             boosterIcon = RES_ICONS.MAPS_ICONS_BOOSTERS_AVAILABLEBOOSTERICON
             if boostersAvailable <= _MAX_BOOSTERS_TO_DISPLAY:
                 boosterText = str(boostersAvailable)
             else:
                 boosterText = str(_MAX_BOOSTERS_TO_DISPLAY) + '+'
         self.as_nameResponseS({
             'userVO': {
                 'fullName':
                 g_lobbyContext.getPlayerFullName(name, clanInfo=clanInfo),
                 'userName':
                 name,
                 'clanAbbrev':
                 clanAbbrev
             },
             'isTeamKiller': g_itemsCache.items.stats.isTeamKiller,
             'hasNew': hasNew,
             'hasActiveBooster': hasActiveBooster,
             'hasAvailableBoosters': hasAvailableBoosters,
             'tooltip': TOOLTIPS.HEADER_ACCOUNT,
             'tooltipType': TOOLTIP_TYPES.COMPLEX,
             'boosterIcon': boosterIcon,
             'boosterBg': RES_ICONS.MAPS_ICONS_BOOSTERS_ACTIVEBOOSTERBG,
             'boosterText': boosterText
         })
         if g_clanCache.clanDBID:
             self.requestClanEmblem32x32(g_clanCache.clanDBID)
         else:
             self.as_setClanEmblemS(None)
         return
Ejemplo n.º 2
0
 def __getActiveBoosterByType(self, bType):
     criteria = REQ_CRITERIA.BOOSTER.ACTIVE | REQ_CRITERIA.BOOSTER.BOOSTER_TYPES([bType])
     activeBoosters = g_goodiesCache.getBoosters(criteria=criteria).values()
     if len(activeBoosters) > 0:
         return max(activeBoosters, key=attrgetter("effectValue"))
     else:
         return None
    def _buildList(self):
        result = []
        activeBoosters = g_goodiesCache.getBoosters(
            criteria=REQ_CRITERIA.BOOSTER.ACTIVE)
        activeBoostersList = sorted(activeBoosters.values(),
                                    key=lambda b: b.getUsageLeftTime(),
                                    reverse=True)
        availableBoostersCount = len(self.__getAvailableBoosters())
        activeBoostersCount = min(len(activeBoostersList),
                                  MAX_ACTIVE_BOOSTERS_COUNT)
        freeSlotsCount = MAX_ACTIVE_BOOSTERS_COUNT - min(
            activeBoostersCount, MAX_ACTIVE_BOOSTERS_COUNT)
        addBoostersSlotsCount = min(freeSlotsCount, availableBoostersCount)
        self._slotsMap = {}
        for idx in range(0, activeBoostersCount):
            booster = activeBoostersList[idx]
            self._slotsMap[idx] = booster.boosterID
            result.append(self.__makeBoosterVO(idx, booster))

        icon = ''
        if not self._isPanelInactive:
            icon = RES_ICONS.MAPS_ICONS_ARTEFACT_EMPTYORDER
        addAndActiveBoostersCount = activeBoostersCount + addBoostersSlotsCount
        for idx in range(activeBoostersCount, MAX_ACTIVE_BOOSTERS_COUNT):
            self._slotsMap[idx], slotLinkage = self.getEmptySlotParams(
                idx, addAndActiveBoostersCount)
            result.append(self.__makeEmptyBoosterVO(idx, slotLinkage, icon))

        self.as_setPanelPropsS(_GUI_SLOTS_PROPS)
        self.as_setSlotsS(result)
Ejemplo n.º 4
0
 def __setClanInfo(self, clanInfo):
     if not isPlayerAccount():
         return
     else:
         name = BigWorld.player().name
         if clanInfo and len(clanInfo) > 1:
             clanAbbrev = clanInfo[1]
         else:
             clanAbbrev = None
         hasNew = not AccountSettings.getFilter(BOOSTERS)['wasShown']
         activeBoosters = g_goodiesCache.getBoosters(criteria=REQ_CRITERIA.BOOSTER.ACTIVE).values()
         hasActiveBooster = len(activeBoosters) > 0
         readyBoosters = g_goodiesCache.getBoosters(criteria=REQ_CRITERIA.BOOSTER.IS_READY_TO_ACTIVATE).values()
         boostersAvailable = sum((booster.count for booster in readyBoosters))
         hasAvailableBoosters = boostersAvailable > 0
         boosterIcon, boosterText = (None, None)
         if hasActiveBooster:
             boosterIcon = RES_ICONS.MAPS_ICONS_BOOSTERS_ACTIVEBOOSTERICON
             booster = sorted(activeBoosters, key=lambda x: x.getUsageLeftTime())[0]
             boosterText = booster.getShortLeftTimeStr()
         elif hasAvailableBoosters:
             boosterIcon = RES_ICONS.MAPS_ICONS_BOOSTERS_AVAILABLEBOOSTERICON
             if boostersAvailable <= _MAX_BOOSTERS_TO_DISPLAY:
                 boosterText = str(boostersAvailable)
             else:
                 boosterText = str(_MAX_BOOSTERS_TO_DISPLAY) + '+'
         self.as_nameResponseS({'userVO': {'fullName': g_lobbyContext.getPlayerFullName(name, clanInfo=clanInfo),
                     'userName': name,
                     'clanAbbrev': clanAbbrev},
          'isTeamKiller': g_itemsCache.items.stats.isTeamKiller,
          'hasNew': hasNew,
          'hasActiveBooster': hasActiveBooster,
          'hasAvailableBoosters': hasAvailableBoosters,
          'tooltip': TOOLTIPS.HEADER_ACCOUNT,
          'tooltipType': TOOLTIP_TYPES.COMPLEX,
          'boosterIcon': boosterIcon,
          'boosterBg': RES_ICONS.MAPS_ICONS_BOOSTERS_ACTIVEBOOSTERBG,
          'boosterText': boosterText})
         if g_clanCache.clanDBID:
             self.requestClanEmblem32x32(g_clanCache.clanDBID)
         else:
             self.as_setClanEmblemS(None)
         return
    def __startBoosterTimeNotifyCallback(self):
        self.__boostersForUpdate = []
        activeBoosters = g_goodiesCache.getBoosters(REQ_CRITERIA.BOOSTER.ACTIVE).values()
        notificationList = []
        for booster in activeBoosters:
            notificationList.append((booster.boosterID, booster.getUsageLeftTime() % time_utils.ONE_MINUTE))

        if len(notificationList) > 0:
            _, nextBoosterNotification = min(notificationList, key=itemgetter(1))
            for item in notificationList:
                if item[1] == nextBoosterNotification:
                    self.__boostersForUpdate.append(item[0])

            nextBoosterNotification = max(nextBoosterNotification, 1)
        else:
            return
        self.__boosterNotifyTimeCallback = BigWorld.callback(nextBoosterNotification, self.__notifyBoosterTime)
Ejemplo n.º 6
0
 def __setClanInfo(self, clanInfo):
     if not isPlayerAccount():
         return
     else:
         name = BigWorld.player().name
         if clanInfo and len(clanInfo) > 1:
             clanAbbrev = clanInfo[1]
         else:
             clanAbbrev = None
         hasNew = not AccountSettings.getFilter(BOOSTERS)['wasShown']
         hasActiveBooster = len(g_goodiesCache.getBoosters(criteria=REQ_CRITERIA.BOOSTER.ACTIVE)) > 0
         self.as_nameResponseS(g_lobbyContext.getPlayerFullName(name, clanInfo=clanInfo), name, clanAbbrev, g_itemsCache.items.stats.isTeamKiller, g_clanCache.isInClan, hasNew, hasActiveBooster, TOOLTIPS.HEADER_ACCOUNT, TOOLTIP_TYPES.COMPLEX)
         if g_clanCache.clanDBID:
             self.requestClanEmblem32x32(g_clanCache.clanDBID)
         else:
             self.as_setClanEmblemS(None)
         return
    def __startBoosterTimeNotifyCallback(self):
        self.__boostersForUpdate = []
        activeBoosters = g_goodiesCache.getBoosters(
            REQ_CRITERIA.BOOSTER.ACTIVE).values()
        notificationList = []
        for booster in activeBoosters:
            notificationList.append(
                (booster.boosterID,
                 booster.getUsageLeftTime() % time_utils.ONE_MINUTE))

        if len(notificationList) > 0:
            _, nextBoosterNotification = min(notificationList,
                                             key=itemgetter(1))
            for item in notificationList:
                if item[1] == nextBoosterNotification:
                    self.__boostersForUpdate.append(item[0])

            nextBoosterNotification = max(nextBoosterNotification, 1)
        else:
            return
        self.__boosterNotifyTimeCallback = BigWorld.callback(
            nextBoosterNotification, self.__notifyBoosterTime)
    def _buildList(self):
        result = []
        activeBoosters = g_goodiesCache.getBoosters(criteria=REQ_CRITERIA.BOOSTER.ACTIVE)
        activeBoostersList = sorted(activeBoosters.values(), key=lambda b: b.getUsageLeftTime(), reverse=True)
        availableBoostersCount = len(self.__getAvailableBoosters())
        activeBoostersCount = min(len(activeBoostersList), MAX_ACTIVE_BOOSTERS_COUNT)
        freeSlotsCount = MAX_ACTIVE_BOOSTERS_COUNT - min(activeBoostersCount, MAX_ACTIVE_BOOSTERS_COUNT)
        addBoostersSlotsCount = min(freeSlotsCount, availableBoostersCount)
        self._slotsMap = {}
        for idx in range(0, activeBoostersCount):
            booster = activeBoostersList[idx]
            self._slotsMap[idx] = booster.boosterID
            result.append(self.__makeBoosterVO(idx, booster))

        icon = ''
        if not self._isPanelInactive:
            icon = RES_ICONS.MAPS_ICONS_ARTEFACT_EMPTYORDER
        addAndActiveBoostersCount = activeBoostersCount + addBoostersSlotsCount
        for idx in range(activeBoostersCount, MAX_ACTIVE_BOOSTERS_COUNT):
            self._slotsMap[idx], slotLinkage = self.getEmptySlotParams(idx, addAndActiveBoostersCount)
            result.append(self.__makeEmptyBoosterVO(idx, slotLinkage, icon))

        self.as_setPanelPropsS(_GUI_SLOTS_PROPS)
        self.as_setSlotsS(result)
 def __getAvailableBoosters(self):
     criteria = REQ_CRITERIA.BOOSTER.IS_READY_TO_ACTIVATE
     return g_goodiesCache.getBoosters(criteria=criteria)
 def __getAvailableBoosters(self):
     criteria = REQ_CRITERIA.BOOSTER.IS_READY_TO_ACTIVATE
     return g_goodiesCache.getBoosters(criteria=criteria)
Ejemplo n.º 11
0
 def __getActiveBoosters(self):
     return g_goodiesCache.getBoosters(criteria=REQ_CRITERIA.BOOSTER.ACTIVE).values()
Ejemplo n.º 12
0
 def __getAvailableBoosters(self):
     criteria = REQ_CRITERIA.BOOSTER.IN_ACCOUNT | REQ_CRITERIA.CUSTOM(self.__isBoosterValid)
     return sorted(g_goodiesCache.getBoosters(criteria=criteria).values(), self._sortAvailableBoosters)
Ejemplo n.º 13
0
 def __getAvailableTotal(self):
     boosters = g_goodiesCache.getBoosters(criteria=REQ_CRITERIA.BOOSTER.IN_ACCOUNT).values()
     return sum((booster.count for booster in boosters))