Пример #1
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
Пример #2
0
 def __requestForBuy(self, data):
     vehicle = g_itemsCache.items.getItem(GUI_ITEM_TYPE.VEHICLE, self.nationID, self.inNationID)
     if data.buySlot:
         result = yield VehicleSlotBuyer(showConfirm=False, showWarning=False).request()
         if len(result.userMsg):
             SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType)
         if not result.success:
             return
     if data.rentId == -1:
         result = yield VehicleBuyer(vehicle, data.buySlot, data.buyAmmo, data.crewType).request()
     else:
         result = yield VehicleRenter(vehicle, data.rentId, data.buyAmmo, data.crewType).request()
     if len(result.userMsg):
         SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType)
     self.as_setEnabledSubmitBtnS(True)
     if result.success:
         self.storeSettings(data.isHasBeenExpanded)
         self.onWindowClose()
Пример #3
0
 def _getObtainVehicleProcessor(self, vehicle, data):
     return VehicleBuyer(vehicle, data.buySlot, data.buyAmmo, data.crewType)
Пример #4
0
 def __getObtainVehicleProcessor(self, crewType):
     equipmentBlock = self.viewModel.equipmentBlock
     isWithAmmo = equipmentBlock.ammo.getIsSelected()
     isWithSlot = equipmentBlock.slot.getIsSelected()
     return VehicleBuyer(self.__vehicle, isWithSlot, isWithAmmo, crewType)