예제 #1
0
 def __init__(self, ctx=None):
     super(EventProgressionVehiclePreview, self).__init__(ctx)
     self._heroInteractive = False
     self.__itemsPack = [
         ItemPackEntry(type=ItemPackType.CREW_100, count=1, groupID=1),
         ItemPackEntry(type=ItemPackType.CUSTOM_SLOT, count=1, groupID=1)
     ]
     addBuiltInEquipment(self.__itemsPack, self.itemsCache, self._vehicleCD)
예제 #2
0
 def _generateItemsPack(self):
     itemsPack = []
     if self._gift.isWithSlotBonus:
         itemsPack.append(ItemPackEntry(type=ItemPackType.CUSTOM_SLOT, count=1, groupID=1))
     if self._gift.bonus.isWithCrew:
         lvl = self._gift.bonus.getTmanRoleLevel(self._gift.bonus.displayedVehicleInfo)
         crewType = getattr(ItemPackType, 'CREW_{}'.format(lvl), ItemPackType.CREW_50)
         itemsPack.append(ItemPackEntry(type=crewType, count=1, groupID=1))
     return itemsPack
예제 #3
0
 def __init__(self, ctx=None):
     super(PackItemsPopover, self).__init__(ctx)
     self.__data = flashObject2Dict(ctx.get('data'))
     self.__rawItems = []
     for item in self.__data.get('items'):
         item = flashObject2Dict(item)
         self.__rawItems.append(ItemPackEntry(type=item.get('type'), id=int(item.get('id')), count=item.get('rawCount') or 0, groupID=item.get('groupID'), title=item.get('title'), description=item.get('description')))
예제 #4
0
 def _onRegisterFlashComponent(self, viewPy, alias):
     super(EventProgressionVehiclePreview,
           self)._onRegisterFlashComponent(viewPy, alias)
     if alias == VEHPREVIEW_CONSTANTS.EVENT_PROGRESSION_BUYING_PANEL_PY_ALIAS:
         itemsData = getDataOneVehicle(itemsPack=self.__itemsPack,
                                       vehicle=g_currentPreviewVehicle.item,
                                       vehicleGroupId=1)
         itemsData.insert(0, self.__getDefaultCrewItemPackEntry())
         viewPy.setData(itemsPack=self.__itemsPack,
                        panelDataVO=self._getBuyingPanelData(),
                        packedItemsVO={'items': itemsData})
     elif alias == VEHPREVIEW_CONSTANTS.CREW_LINKAGE:
         viewPy.setVehicleCrews(
             (ItemPackEntry(id=g_currentPreviewVehicle.item.intCD,
                            groupID=1), ),
             (ItemPackEntry(type=ItemPackType.CREW_100, groupID=1), ))
예제 #5
0
 def showItemTooltip(self, cmd):
     itemType = cmd.type
     itemId = getCDFromId(itemType=cmd.type, itemId=cmd.id)
     itemsCount = cmd.count
     rawItem = ItemPackEntry(type=itemType, id=itemId, count=itemsCount)
     item = lookupItem(rawItem, self.itemsCache, self.goodiesCache)
     showItemTooltip(self.__getTooltipMgr(), rawItem, item)
예제 #6
0
def _getOfferCrew(offer):
    if offer.get('event_type', '') in _CUSTOM_CREW_KEYS:
        crew = ItemPackType.CREW_CUSTOM
    elif Money(**offer.get('buy_price', MONEY_UNDEFINED)).gold:
        crew = ItemPackType.CREW_100
    else:
        crew = ItemPackType.CREW_75
    return ItemPackEntry(type=crew, groupID=1)
예제 #7
0
 def showItemTooltip(self, cmd):
     itemType = cmd.type
     if itemType == ItemPackType.CREW_BOOK:
         itemId = makeIntCompactDescrByID('crewBook', CrewBookCacheType.CREW_BOOK, cmd.id)
     else:
         itemId = getCDFromId(itemType=cmd.type, itemId=cmd.id)
     rawItem = ItemPackEntry(type=itemType, id=itemId, count=cmd.count or 1, extra=cmd.extra or {})
     item = lookupItem(rawItem, self.itemsCache, self.goodiesCache)
     showItemTooltip(self.__getTooltipMgr(), rawItem, item)
예제 #8
0
    def _onRegisterFlashComponent(self, viewPy, alias):
        super(OfferGiftVehiclePreview, self)._onRegisterFlashComponent(viewPy, alias)
        if alias == VEHPREVIEW_CONSTANTS.OFFER_GIFT_BUYING_PANEL_PY_ALIAS:
            itemsData = getDataOneVehicle(itemsPack=self.__itemsPack, vehicle=g_currentPreviewVehicle.item, vehicleGroupId=1)
            for item in self.__itemsPack:
                if item.type in ItemPackTypeGroup.CREW:
                    itemsData.insert(0, self.__getCrewItemPackEntry(item))

            viewPy.setData(itemsPack=self.__itemsPack, panelDataVO=self._getBuyingPanelData(), packedItemsVO={'items': itemsData}, confirmCallback=self._confirmCallback)
        elif alias == VEHPREVIEW_CONSTANTS.CREW_LINKAGE:
            viewPy.setVehicleCrews((ItemPackEntry(id=g_currentPreviewVehicle.item.intCD, groupID=1),), [ item for item in self.__itemsPack if item.type in ItemPackTypeGroup.CREW ])
 def __showStylePreview(self, style, vehicleCD):
     itemsPack = (ItemPackEntry(type=ItemPackType.CREW_100, groupID=1), )
     showStylePreview(vehicleCD,
                      style=style,
                      topPanelData={
                          'linkage':
                          VEHPREVIEW_CONSTANTS.TOP_PANEL_TABS_LINKAGE,
                          'tabIDs': (TabID.VEHICLE, TabID.STYLE),
                          'currentTabID': TabID.STYLE
                      },
                      itemsPack=itemsPack,
                      backCallback=self.__getPreviewCallback())
예제 #10
0
 def __getItemData(self, itemType, itemId):
     rawItem = ItemPackEntry(type=itemType, id=itemId)
     if itemType in ItemPackTypeGroup.CUSTOMIZATION:
         return self.__getCustomization(rawItem, itemId)
     elif itemType == ItemPackType.DEMOUNT_KIT:
         return self.__getDemountKit(itemId)
     item = lookupItem(rawItem, self.__itemsCache, self.__goodiesCache)
     if item is None:
         _logger.warning("Award '%r' not supported", itemType)
         return ('', '')
     else:
         return (item.icon, item.userName)
예제 #11
0
 def _onRegisterFlashComponent(self, viewPy, alias):
     super(VehiclePreview, self)._onRegisterFlashComponent(viewPy, alias)
     if alias == VEHPREVIEW_CONSTANTS.BUYING_PANEL_PY_ALIAS:
         viewPy.setIsHeroTank(self.__isHeroTank)
         viewPy.setBackAlias(self._backAlias)
         viewPy.setBackCallback(self._previewBackCb)
         if self._itemsPack:
             viewPy.setPackItems(self._itemsPack, self._price,
                                 self._oldPrice, self._title)
             viewPy.setTimerData(self.__endTime)
             viewPy.setBuyParams(self.__buyParams)
         elif self.__offers:
             viewPy.setOffers(self.__offers, self._title,
                              self.__description)
     elif alias == VEHPREVIEW_CONSTANTS.CREW_LINKAGE:
         if self._itemsPack:
             crewItems = tuple((item for item in self._itemsPack
                                if item.type in ItemPackTypeGroup.CREW))
             vehicleItems = tuple(
                 (item for item in self._itemsPack
                  if item.type in ItemPackTypeGroup.VEHICLE))
             if not vehicleItems and crewItems:
                 groupID = crewItems[0].groupID
                 vehicleItems = (ItemPackEntry(
                     id=g_currentPreviewVehicle.item.intCD,
                     groupID=groupID), )
             viewPy.setVehicleCrews(vehicleItems, crewItems)
         elif self.__offers:
             offer = getActiveOffer(self.__offers)
             viewPy.setVehicleCrews(
                 (ItemPackEntry(id=g_currentPreviewVehicle.item.intCD,
                                groupID=offer.crew.groupID), ),
                 (offer.crew, ))
         elif self.__isHeroTank:
             crewData = self.__heroTanksControl.getCurrentTankCrew()
             if crewData and crewData.get('tankmen'):
                 viewPy.setVehicleCrews(
                     (ItemPackEntry(id=g_currentPreviewVehicle.item.intCD,
                                    groupID=1), ),
                     (ItemPackEntry(type=ItemPackType.CREW_CUSTOM,
                                    groupID=1,
                                    extra=crewData), ))
             else:
                 viewPy.setVehicleCrews(
                     (ItemPackEntry(id=g_currentPreviewVehicle.item.intCD,
                                    groupID=1), ), ())
         else:
             viewPy.setVehicleCrews(
                 (ItemPackEntry(id=g_currentPreviewVehicle.item.intCD,
                                groupID=1), ), ())
     elif alias == VEHPREVIEW_CONSTANTS.BROWSE_LINKAGE:
         viewPy.setHeroTank(self.__isHeroTank)
         if self.__offers:
             offer = self.__currentOffer if self.__currentOffer is not None else getActiveOffer(
                 self.__offers)
             viewPy.setActiveOffer(offer)
     elif alias == VEHPREVIEW_CONSTANTS.WOT_PLUS_PANEL_LINKAGE:
         viewPy.setOffers(self.__offers)
     return
def addBuiltInEquipment(packItems, itemsCache, vehicleCD):
    if packItems and itemsCache and vehicleCD:
        vehicle = itemsCache.items.getItemByCD(vehicleCD)
        groupID = 1
        for item in packItems:
            if item.id == vehicleCD:
                groupID = item.groupID

        for eqId in vehicle.getBuiltInEquipmentIDs():
            eqItem = ItemPackEntry(type=ItemPackType.ITEM_EQUIPMENT,
                                   id=eqId,
                                   count=1,
                                   groupID=groupID)
            packItems.append(eqItem)
 def __onExtraPreviewClick(self):
     styleInfo = getStyleForChapter(self.__chapterID,
                                    battlePass=self.__battlePass)
     vehicleCD = getVehicleCDForStyle(styleInfo,
                                      itemsCache=self.__itemsCache)
     itemsPack = (ItemPackEntry(type=ItemPackType.CREW_100, groupID=1), )
     showStylePreview(vehicleCD,
                      style=styleInfo,
                      topPanelData={
                          'linkage':
                          VEHPREVIEW_CONSTANTS.TOP_PANEL_TABS_LINKAGE,
                          'tabIDs': (TabID.VEHICLE, TabID.STYLE),
                          'currentTabID': TabID.STYLE
                      },
                      itemsPack=itemsPack,
                      backCallback=self.__getPreviewCallback())
def collapseItemsPack(items):
    if items is None or len(items) < 2:
        return items
    else:
        uniqueItems = []
        for _, group in itertools.groupby(sorted(items, key=_getItemKey),
                                          key=_getItemKey):
            items = list(group)
            item = items[0]
            uniqueItems.append(
                ItemPackEntry(type=item.type,
                              id=item.id,
                              count=sum((item.count for item in items)),
                              groupID=item.groupID,
                              compensation=item.compensation,
                              iconSource=item.iconSource,
                              title=item.title,
                              description=item.description))

        return uniqueItems
 def onOfferSelected(self, offerID):
     self.__currentOffer = findFirst(lambda o: o.id == offerID,
                                     self.__offers)
     if self.__currentOffer:
         vehicle = g_currentPreviewVehicle.item
         crew = self.__currentOffer.crew
         g_eventBus.handleEvent(
             HasCtxEvent(ctx={
                 'vehicleItems':
                 [ItemPackEntry(id=vehicle.intCD, groupID=crew.groupID)],
                 'crewItems': [crew],
                 'offer':
                 self.__currentOffer
             },
                         eventType=OFFER_CHANGED_EVENT))
         self.__buyParams = self.__currentOffer.buyParams
         self.__price = self.__currentOffer.buyPrice
         self.as_setBuyDataS(
             self.__previewDP.getOffersBuyingPanelData(self.__getBtnData()))
         description = self.__description or self.__getCurrentOfferDescription(
         ) or {}
         self.as_setSetTitleTooltipS(makeTooltip(**description))
예제 #16
0
def _getOfferCrew(offer):
    return ItemPackEntry(type=ItemPackType.CREW_100 if Money(**offer.get('buy_price', MONEY_UNDEFINED)).gold else ItemPackType.CREW_75, groupID=1)