def openVehiclePackPreview(self, cmd):
        items = _parseItemsPack(cmd.items)
        price, oldPrice = _parseBuyPrice(cmd.buy_price)
        vehiclesID = []
        for item in items:
            if item.type in ItemPackTypeGroup.VEHICLE:
                vehiclesID.append(item.id)

        if vehiclesID and self.__validVehiclePreviewPack(vehiclesID):
            localEndTime = None
            if cmd.end_date:
                timestamp = getTimestampFromISO(cmd.end_date)
                datetimeInUTC = getDateTimeInUTC(timestamp)
                localDatetime = utcToLocalDatetime(datetimeInUTC)
                localEndTime = (localDatetime -
                                getDateTimeInLocal(0)).total_seconds()
            event_dispatcher.showVehiclePreview(
                vehTypeCompDescr=vehiclesID[0],
                itemsPack=items,
                price=price,
                oldPrice=oldPrice,
                title=cmd.title,
                endTime=localEndTime,
                previewAlias=self._getVehiclePreviewReturnAlias(cmd),
                previewBackCb=self._getVehiclePreviewReturnCallback(cmd),
                buyParams=cmd.buy_params)
        else:
            _pushInvalidPreviewMessage()
        return
Exemple #2
0
 def onGoToPreviewClick(self, vehicleID):
     intVehicleID = int(vehicleID)
     vehicle = g_itemsCache.items.getItemByCD(intVehicleID)
     if vehicle.isPreviewAllowed():
         showVehiclePreview(intVehicleID, VIEW_ALIAS.VEHICLE_COMPARE)
     else:
         SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.VEHICLECOMPARE_PREVIEWNOTALLOWED, vehicle=vehicle.userName, type=SystemMessages.SM_TYPE.Error)
Exemple #3
0
 def goToVehicleView(self, itemCD):
     vehicle = g_itemsCache.items.getItemByCD(int(itemCD))
     if vehicle:
         if vehicle.isPreviewAllowed():
             shared_events.showVehiclePreview(int(itemCD), self.alias)
         elif vehicle.isInInventory:
             shared_events.selectVehicleInHangar(itemCD)
Exemple #4
0
 def onShowInfo(self, itemCD):
     dataCompactId = int(itemCD)
     item = g_itemsCache.items.getItemByCD(dataCompactId)
     if item is None:
         return LOG_ERROR(
             'There is error while attempting to show vehicle info window: ',
             str(dataCompactId))
     else:
         if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
             if item.isPreviewAllowed():
                 shared_events.showVehiclePreview(item.intCD,
                                                  VIEW_ALIAS.LOBBY_STORE)
             else:
                 shared_events.showVehicleInfo(item.intCD)
         else:
             self.fireEvent(
                 events.LoadViewEvent(
                     VIEW_ALIAS.MODULE_INFO_WINDOW,
                     getViewName(VIEW_ALIAS.MODULE_INFO_WINDOW, item.intCD),
                     {
                         'moduleCompactDescr':
                         item.intCD,
                         'isAdditionalInfoShow':
                         i18n.makeString(MENU.MODULEINFO_ADDITIONALINFO)
                     }), EVENT_BUS_SCOPE.LOBBY)
         return
 def _processBackClick(self, ctx=None):
     if self._previewBackCb:
         self._previewBackCb()
     elif self._backAlias == VIEW_ALIAS.LOBBY_RESEARCH and g_currentPreviewVehicle.isPresent(
     ):
         event_dispatcher.showResearchView(
             self._vehicleCD,
             exitEvent=events.LoadViewEvent(
                 SFViewLoadParams(VIEW_ALIAS.LOBBY_TECHTREE),
                 ctx={'nation': g_currentPreviewVehicle.item.nationName}))
     elif self._backAlias == VIEW_ALIAS.VEHICLE_PREVIEW:
         entity = ctx.get('entity', None) if ctx else None
         if entity:
             compactDescr = entity.typeDescriptor.type.compactDescr
             if self.__itemsCache.items.inventory.getItemData(
                     compactDescr) is not None:
                 event_dispatcher.showHangar()
             else:
                 event_dispatcher.showVehiclePreview(
                     compactDescr, previewAlias=self._previousBackAlias)
         else:
             event_dispatcher.showHangar()
     elif self._backAlias == VIEW_ALIAS.LOBBY_STORE:
         showShop()
     else:
         event = g_entitiesFactories.makeLoadEvent(
             SFViewLoadParams(self._backAlias), {'isBackEvent': True})
         self.fireEvent(event, scope=EVENT_BUS_SCOPE.LOBBY)
     return
Exemple #6
0
 def preview(self):
     shared_events.showVehiclePreview(
         self._id,
         previewBackCb=lambda: shared_events.showStorage(
             STORAGE_CONSTANTS.IN_HANGAR, STORAGE_CONSTANTS.
             VEHICLES_TAB_RESTORE),
         previewAlias=VIEW_ALIAS.LOBBY_STORAGE)
 def __processBackClick(self, ctx=None):
     if self._previewBackCb:
         self._previewBackCb()
     elif self._backAlias == VIEW_ALIAS.LOBBY_RESEARCH:
         event_dispatcher.showResearchView(self._vehicleCD)
     elif self._backAlias == VIEW_ALIAS.VEHICLE_PREVIEW:
         entity = ctx.get('entity', None) if ctx else None
         if entity:
             descriptor = entity.typeDescriptor
             event_dispatcher.showVehiclePreview(
                 descriptor.type.compactDescr,
                 previewAlias=self._previousBackAlias)
         else:
             event_dispatcher.showHangar()
     elif self._backAlias == VIEW_ALIAS.LOBBY_STORE:
         if isIngameShopEnabled():
             showWebShop(url=getBuyVehiclesUrl())
         else:
             showOldShop(
                 ctx={
                     'tabId': STORE_TYPES.SHOP,
                     'component': STORE_CONSTANTS.VEHICLE
                 })
     else:
         event = g_entitiesFactories.makeLoadEvent(self._backAlias,
                                                   {'isBackEvent': True})
         self.fireEvent(event, scope=EVENT_BUS_SCOPE.LOBBY)
     return
Exemple #8
0
 def goToVehicleView(self, itemCD):
     vehicle = g_itemsCache.items.getItemByCD(int(itemCD))
     if vehicle:
         if vehicle.isPreviewAllowed():
             shared_events.showVehiclePreview(int(itemCD), self.alias)
         elif vehicle.isInInventory:
             shared_events.selectVehicleInHangar(itemCD)
 def goToVehicleView(self, itemCD):
     LOG_DEBUG('BCResearch.goToVehicleView', itemCD, self.alias)
     itemsCache = dependency.instance(IItemsCache)
     vehicle = itemsCache.items.getItemByCD(int(itemCD))
     if vehicle.isPreviewAllowed():
         shared_events.showVehiclePreview(int(itemCD), self.alias)
     elif vehicle.isInInventory:
         shared_events.selectVehicleInHangar(itemCD)
 def request4Buy(self, itemCD):
     nationData = g_bootcamp.getNationData()
     if nationData['module'] == itemCD:
         super(BCResearch, self).request4Buy(itemCD)
     elif nationData['vehicle_second'] == itemCD:
         shared_events.showVehiclePreview(int(itemCD), self.alias)
     else:
         super(BCResearch, self).request4Buy(itemCD)
 def request4Unlock(self, unlockCD, vehCD, unlockIdx, xpCost):
     nationData = g_bootcamp.getNationData()
     if nationData['module'] == unlockCD:
         super(BCResearch, self).request4Unlock(unlockCD, vehCD, unlockIdx, xpCost)
     elif nationData['vehicle_second'] == unlockCD:
         shared_events.showVehiclePreview(int(unlockCD), self.alias)
     else:
         super(BCResearch, self).request4Unlock(unlockCD, vehCD, unlockIdx, xpCost)
 def showVehiclePreview(self):
     vehicle = self.__getVehicleAward()
     if vehicle.isInInventory:
         event_dispatcher.selectVehicleInHangar(vehicle.intCD)
     else:
         event_dispatcher.showVehiclePreview(
             vehicle.intCD,
             previewAlias=PERSONAL_MISSIONS_ALIASES.
             PERSONAL_MISSIONS_AWARDS_VIEW_ALIAS)
Exemple #13
0
 def goToVehicleView(self, itemCD):
     vehicle = self._itemsCache.items.getItemByCD(int(itemCD))
     if vehicle:
         if vehicle.isPreviewAllowed():
             shared_events.showVehiclePreview(int(itemCD), self.alias)
         elif vehicle.isInInventory:
             if not vehicle.activeInNationGroup:
                 itemCD = iterVehTypeCDsInNationGroup(vehicle.intCD).next()
             shared_events.selectVehicleInHangar(itemCD)
 def goToVehicleView(self):
     if self._vehicle.isPreviewAllowed():
         if self._exitEvent.alias in VEHICLE_PREVIEW_ALIASES:
             self._onExit()
         else:
             backCb = partial(shared_events.showVehPostProgressionView, self._intCD, self._exitEvent)
             shared_events.showVehiclePreview(self._intCD, self.alias, previewBackCb=backCb)
     elif self._vehicle.isInInventory:
         shared_events.selectVehicleInHangar(self._intCD)
Exemple #15
0
 def onGoToPreviewClick(self, slotID):
     cmpVehicle = self.comparisonBasket.getVehicleAt(int(slotID))
     vehicleStrCD = cmpVehicle.getVehicleStrCD()
     vehicleIntCD = cmpVehicle.getVehicleCD()
     vehicle = self.itemsCache.items.getItemByCD(vehicleIntCD)
     if vehicle.isPreviewAllowed():
         showVehiclePreview(vehicleIntCD, VIEW_ALIAS.VEHICLE_COMPARE, vehStrCD=vehicleStrCD)
     else:
         SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.VEHICLECOMPARE_PREVIEWNOTALLOWED, vehicle=vehicle.userName, type=SystemMessages.SM_TYPE.Error)
 def openVehiclePreview(self, cmd):
     vehicleID = cmd.vehicle_id
     if self.__validVehiclePreview(vehicleID):
         event_dispatcher.showVehiclePreview(
             vehTypeCompDescr=vehicleID,
             previewAlias=self._getVehiclePreviewReturnAlias(cmd),
             previewBackCb=self._getVehiclePreviewReturnCallback(cmd))
     else:
         _pushInvalidPreviewMessage()
Exemple #17
0
 def request4Buy(self, itemCD):
     nationData = g_bootcampGarage.getNationData()
     if nationData['module'] == itemCD:
         g_bootcampGarage.hideHint()
         super(BCResearch, self).request4Buy(itemCD)
         g_bootcampGarage.highlightLobbyHint('DialogAccept')
     elif nationData['vehicle_second'] == itemCD:
         shared_events.showVehiclePreview(int(itemCD), self.alias)
     else:
         super(BCResearch, self).request4Buy(itemCD)
 def goToVehicleView(self, itemCD):
     LOG_DEBUG('BCResearch.goToVehicleView', itemCD, self.alias)
     itemsCache = dependency.instance(IItemsCache)
     vehicle = itemsCache.items.getItemByCD(int(itemCD))
     if vehicle.isPreviewAllowed():
         shared_events.showVehiclePreview(int(itemCD), self.alias)
     elif vehicle.isInInventory:
         shared_events.selectVehicleInHangar(itemCD)
         if g_bootcamp.getLessonNum() >= g_bootcamp.getContextIntParameter(
                 'researchSecondVehicleLesson'):
             g_bootcampGarage.checkSecondVehicleHintEnabled()
Exemple #19
0
 def request4Unlock(self, unlockCD, vehCD, unlockIdx, xpCost):
     nationData = g_bootcampGarage.getNationData()
     if nationData['module'] == unlockCD:
         g_bootcampGarage.hideHint()
         super(BCResearch, self).request4Unlock(unlockCD, vehCD, unlockIdx,
                                                xpCost)
         g_bootcampGarage.highlightLobbyHint('DialogAccept')
     elif nationData['vehicle_second'] == unlockCD:
         shared_events.showVehiclePreview(int(unlockCD), self.alias)
     else:
         super(BCResearch, self).request4Unlock(unlockCD, vehCD, unlockIdx,
                                                xpCost)
 def onShowInfo(self, data):
     dataCompactId = int(data.id)
     item = g_itemsCache.items.getItemByCD(dataCompactId)
     if item is None:
         return LOG_ERROR('There is error while attempting to show vehicle info window: ', str(dataCompactId))
     else:
         if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
             if item.isPreviewAllowed():
                 shared_events.showVehiclePreview(item.intCD, VIEW_ALIAS.LOBBY_STORE)
             else:
                 shared_events.showVehicleInfo(item.intCD)
         else:
             self.fireEvent(events.LoadViewEvent(VIEW_ALIAS.MODULE_INFO_WINDOW, getViewName(VIEW_ALIAS.MODULE_INFO_WINDOW, item.intCD), {'moduleCompactDescr': str(item.intCD),
              'isAdditionalInfoShow': i18n.makeString(MENU.MODULEINFO_ADDITIONALINFO)}), EVENT_BUS_SCOPE.LOBBY)
         return
def customizationPreview(itemCD, itemsCache=None, vehicleCD=None):
    if vehicleCD is None:
        suitableVehicles = []
        item = itemsCache.items.getItemByCD(itemCD)
        itemFilter = item.descriptor.filter
        nationsFilter = []
        if itemFilter is not None and itemFilter.include:
            for node in itemFilter.include:
                if node.nations:
                    nationsFilter += node.nations
                if node.vehicles:
                    suitableVehicles += node.vehicles

            if not suitableVehicles and nationsFilter:
                nationName = nations.NAMES[nationsFilter[0]]
                topVehicle = getTopVehicleByNation(nationName)
                if topVehicle:
                    try:
                        vehicleCD = makeVehicleTypeCompDescrByName(topVehicle)
                        vehicle = itemsCache.items.getItemByCD(vehicleCD)
                        if item.mayInstall(vehicle):
                            suitableVehicles.append(vehicleCD)
                    except SoftException as e:
                        _logger.warning(e)

        if not suitableVehicles:
            req = _CUSTOMIZATION_VEHICLE_CRITERIA | ~REQ_CRITERIA.SECRET
            for vehCD, vehicle in itemsCache.items.getVehicles(
                    req).iteritems():
                if not vehicle.isOutfitLocked and item.mayInstall(vehicle):
                    suitableVehicles.append(vehCD)

        if not suitableVehicles:
            secretReq = _CUSTOMIZATION_VEHICLE_CRITERIA | REQ_CRITERIA.SECRET
            for vehCD, vehicle in itemsCache.items.getVehicles(
                    secretReq).iteritems():
                if not vehicle.isOutfitLocked and item.mayInstall(vehicle):
                    suitableVehicles.append(vehCD)

        vehicleCD = random.choice(suitableVehicles)
    showVehiclePreview(vehTypeCompDescr=vehicleCD,
                       previewBackCb=partial(
                           showStorage,
                           defaultSection=STORAGE_CONSTANTS.CUSTOMIZATION),
                       previewAlias=VIEW_ALIAS.LOBBY_STORAGE,
                       vehParams={'styleCD': itemCD})
    return
 def __processBackClick(self, ctx=None):
     if self._backAlias == VIEW_ALIAS.LOBBY_RESEARCH:
         event_dispatcher.showResearchView(self._vehicleCD)
     elif self._backAlias == VIEW_ALIAS.VEHICLE_PREVIEW:
         entity = ctx.get('entity', None) if ctx else None
         if entity:
             descriptor = entity.typeDescriptor
             event_dispatcher.showVehiclePreview(
                 descriptor.type.compactDescr,
                 previewAlias=self._previousBackAlias)
         else:
             event_dispatcher.showHangar()
     else:
         event = g_entitiesFactories.makeLoadEvent(self._backAlias,
                                                   {'isBackEvent': True})
         self.fireEvent(event, scope=EVENT_BUS_SCOPE.LOBBY)
     return
Exemple #23
0
 def showVehiclePreview(self):
     shared_events.showVehiclePreview(self.vehCD, VIEW_ALIAS.LOBBY_STORE)
Exemple #24
0
 def onGoToPreviewClick(self, vehicleID):
     showVehiclePreview(int(vehicleID), VIEW_ALIAS.VEHICLE_COMPARE)
 def showVehiclePreview(self):
     shared_events.showVehiclePreview(self.vehCD, VIEW_ALIAS.VEHICLE_COMPARE)
 def showVehiclePreview(self):
     shared_events.showVehiclePreview(self._vehicleCD)
     shared_events.hideBattleResults()
 def showVehiclePreview(self):
     shared_events.showVehiclePreview(self.vehCD,
                                      VIEW_ALIAS.VEHICLE_COMPARE)
 def showVehiclePreview(self):
     shared_events.showVehiclePreview(self._nodeCD, self._previewAlias)
Exemple #29
0
 def showVehiclePreview(self):
     shared_events.showVehiclePreview(self._vehicleCD)
     shared_events.hideBattleResults()
Exemple #30
0
 def showVehiclePreview(self):
     vehicleCD = getValidVehicleCDForNationChange(self._vehicleCD)
     shared_events.showVehiclePreview(vehicleCD)
     shared_events.hideBattleResults()
Exemple #31
0
 def openVehicleOffersPreview(self, cmd):
     event_dispatcher.showVehiclePreview(vehTypeCompDescr=int(cmd.vehicle_id), offers=_parseOffers(cmd.offers), price=MONEY_UNDEFINED, oldPrice=MONEY_UNDEFINED, previewAlias=self._getVehiclePreviewReturnAlias(cmd), previewBackCb=self._getVehiclePreviewReturnCallback(cmd))
Exemple #32
0
 def openVehiclePreview(self, cmd):
     event_dispatcher.showVehiclePreview(
         cmd.vehicle_id,
         previewAlias=self._getVehiclePreviewReturnAlias(cmd))
 def onGoToPreviewClick(self, vehicleID):
     showVehiclePreview(int(vehicleID), VIEW_ALIAS.VEHICLE_COMPARE)
 def showVehiclePreview(self):
     shared_events.showVehiclePreview(self._nodeCD, self._previewAlias)
 def showVehiclePreview(self):
     shared_events.showVehiclePreview(self.vehCD, VIEW_ALIAS.LOBBY_STORE)