def setItem(self, furnitureMgrId, blob):
     self.furnitureMgr = self.cr.doId2do.get(furnitureMgrId)
     if self.furnitureMgr:
         self.furnitureMgr.dfitems.append(self)
         self.item = CatalogItem.getItem(blob, store=CatalogItem.Customization)
         self.assign(self.loadModel())
         interior = self.furnitureMgr.getInteriorObject()
         self.reparentTo(interior.interior)
示例#2
0
 def setItem(self, furnitureMgrId, blob):
     self.furnitureMgr = self.cr.doId2do.get(furnitureMgrId)
     if self.furnitureMgr:
         self.furnitureMgr.dfitems.append(self)
         self.item = CatalogItem.getItem(blob,
                                         store=CatalogItem.Customization)
         self.assign(self.loadModel())
         interior = self.furnitureMgr.getInteriorObject()
         self.reparentTo(interior.interior)
示例#3
0
    def attemptPurchase(self, context, av, blob, optional, gifting=False):
        avId = av.doId
        item = CatalogItem.getItem(blob, CatalogItem.Customization)

        if isinstance(item, CatalogInvalidItem.CatalogInvalidItem):
            self.air.writeServerEvent('suspicious', avId,
                                      'tried purchasing invalid item')
            self.notify.warning('%d tried purchasing invalid item' % avId)
            return ToontownGlobals.P_NotInCatalog
        elif (
                not item.hasEmblemPrices()
        ) and item not in av.backCatalog and item not in av.weeklyCatalog and item not in av.monthlyCatalog:
            self.air.writeServerEvent('suspicious', avId,
                                      'tried purchasing non-existing item')
            self.notify.warning('%d tried purchasing non-existing item' % avId)
            return ToontownGlobals.P_NotInCatalog

        if gifting and not item.isGift():
            return ToontownGlobals.P_NotAGift

        price = item.getPrice(CatalogItem.CatalogTypeBackorder if item in
                              av.backCatalog else 0)

        if price > av.getTotalMoney() or (
                item.hasEmblemPrices()
                and not av.isEnoughEmblemsToBuy(item.getEmblemPrices())):
            return ToontownGlobals.P_NotEnoughMoney

        if item.getDeliveryTime() or gifting:
            deliveryTime = 0 if config.GetBool(
                'want-instant-delivery', False) else item.getDeliveryTime()
            item.deliveryDate = int(time.time() / 60. + deliveryTime + .5)

        if gifting:
            return self.requestGiftAvatarOperation(avId, gifting,
                                                   [context, item, price],
                                                   self.attemptGiftPurchase)
        else:
            returnCode = self.checkPurchaseLimit(av, item)

            if returnCode != ToontownGlobals.P_ItemOnOrder:
                return returnCode

            if item.getDeliveryTime():
                self.chargeAvatar(av, price, item.getEmblemPrices())
                av.onOrder.append(item)
                av.b_setDeliverySchedule(av.onOrder)
            else:
                returnCode = item.recordPurchase(av, optional)

                if returnCode == ToontownGlobals.P_ItemAvailable:
                    self.chargeAvatar(av, price, item.getEmblemPrices())

            return returnCode

        return None
    def attemptPurchase(self, context, av, blob, optional, gifting=False):
        avId = av.doId
        item = CatalogItem.getItem(blob, CatalogItem.Customization)
        
        if isinstance(item, CatalogInvalidItem.CatalogInvalidItem):
            self.air.writeServerEvent('suspicious', avId, 'tried purchasing invalid item')
            self.notify.warning('%d tried purchasing invalid item' % avId)
            return ToontownGlobals.P_NotInCatalog
        elif (not item.hasEmblemPrices()) and item not in av.backCatalog and item not in av.weeklyCatalog and item not in av.monthlyCatalog:
            self.air.writeServerEvent('suspicious', avId, 'tried purchasing non-existing item')
            self.notify.warning('%d tried purchasing non-existing item' % avId)
            return ToontownGlobals.P_NotInCatalog
        
        if gifting and not item.isGift():
            return ToontownGlobals.P_NotAGift

        price = item.getPrice(CatalogItem.CatalogTypeBackorder if item in av.backCatalog else 0)
        
        if price > av.getTotalMoney() or (item.hasEmblemPrices() and not av.isEnoughEmblemsToBuy(item.getEmblemPrices())):
            return ToontownGlobals.P_NotEnoughMoney
        
        if item.getDeliveryTime() or gifting:
            deliveryTime = 0 if config.GetBool('want-instant-delivery', False) else item.getDeliveryTime()
            item.deliveryDate = int(time.time() / 60. + deliveryTime + .5)
        
        if gifting:
            return self.requestGiftAvatarOperation(avId, gifting, [context, item, price], self.attemptGiftPurchase)
        else:
            returnCode = self.checkPurchaseLimit(av, item)
            
            if returnCode != ToontownGlobals.P_ItemOnOrder:
                return returnCode
            
            if item.getDeliveryTime():
                self.chargeAvatar(av, price, item.getEmblemPrices())
                av.onOrder.append(item)
                av.b_setDeliverySchedule(av.onOrder)
            else:
                returnCode = item.recordPurchase(av, optional)
                
                if returnCode == ToontownGlobals.P_ItemAvailable:
                    self.chargeAvatar(av, price, item.getEmblemPrices())
            
            return returnCode

        return None