Пример #1
0
 def __premiumBuyRequest(self, days, cost):
     wasPremium = self.itemsCache.items.stats.isPremium
     arenaUniqueID = self._arenaUniqueID
     result = yield PremiumAccountBuyer(days, cost, arenaUniqueID).request()
     if not result.success and result.auxData and result.auxData.get('errStr', '') in ('Battle not in cache', 'Not supported'):
         arenaUniqueID = 0
         result = yield PremiumAccountBuyer(days, cost, arenaUniqueID, withoutBenefits=True).request()
     if len(result.userMsg):
         SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType)
     if result.success:
         if arenaUniqueID and self._premiumBonusesDiff:
             SystemMessages.pushI18nMessage('#system_messages:premium/post_battle_premium', type=SystemMessages.SM_TYPE.Information, priority=NotificationPriorityLevel.MEDIUM, **self._premiumBonusesDiff)
         becomePremium = self.itemsCache.items.stats.isPremium and not wasPremium
         self.fireEvent(LobbySimpleEvent(LobbySimpleEvent.PREMIUM_BOUGHT, ctx={'arenaUniqueID': arenaUniqueID,
          'becomePremium': becomePremium}))
         self.onWindowClose()
Пример #2
0
    def buyItems(self, cmd):
        responses = []
        items = self._itemsCache.items
        for spec in parseItemsSpec(cmd.items):
            if spec.type in (ShopItemType.DEVICE, ShopItemType.EQUIPMENT,
                             ShopItemType.BATTLE_BOOSTER):
                item = items.getItemByCD(spec.id)
                currency = item.buyPrices.itemPrice.price.getCurrency()
                buyer = ModuleBuyer(item, spec.count, currency)
            elif spec.type == ShopItemType.BOOSTER:
                item = self._goodiesCache.getBooster(spec.id)
                currency = item.buyPrices.itemPrice.price.getCurrency()
                buyer = BoosterBuyer(item, spec.count, currency)
            elif spec.type == ShopItemType.VEHICLE:
                item = items.getItemByCD(spec.id)
                buyer = VehicleBuyer(item,
                                     buySlot=False,
                                     showNotEnoughSlotMsg=False)
            elif spec.type == ShopItemType.PREMIUM:
                daysCount = spec.count
                buyer = PremiumAccountBuyer(
                    daysCount,
                    price=items.shop.getPremiumCostWithDiscount()[daysCount],
                    requireConfirm=False)
            else:
                raise SoftException('Invalid item type: "{}".'.format(
                    spec.type))
            if buyer:
                response = yield buyer.request()
                responses.append(
                    self.__makeResult(spec.type, spec.id, response))
            responses.append(None)

        results = []
        for response in responses:
            status = response['success']
            if status and status.userMsg:
                if response['type'] == ShopItemType.VEHICLE:
                    showVehicleReceivedResultMessages(status)
                else:
                    SystemMessages.pushI18nMessage(status.userMsg,
                                                   type=status.sysMsgType)
                statusData = status.auxData
                if statusData is None or 'errStr' not in statusData or not statusData[
                        'errStr']:
                    result = 'success'
                else:
                    result = statusData['errStr']
                results.append(
                    self.__makeResult(response['type'], response['id'],
                                      status.success, result))
            results.append(
                self.__makeResult(response['type'], response['id'], False))

        yield results
        return
Пример #3
0
 def __premiumBuyRequest(self, days, cost):
     wasPremium = g_itemsCache.items.stats.isPremium
     result = yield PremiumAccountBuyer(days, cost,
                                        self._arenaUniqueID).request()
     if len(result.userMsg):
         SystemMessages.g_instance.pushI18nMessage(result.userMsg,
                                                   type=result.sysMsgType)
     if result.success:
         becomePremium = g_itemsCache.items.stats.isPremium and not wasPremium
         self.onWindowClose()
         self.fireEvent(
             LobbySimpleEvent(LobbySimpleEvent.PREMIUM_BOUGHT,
                              ctx={
                                  'arenaUniqueID': self._arenaUniqueID,
                                  'becomePremium': becomePremium
                              }))