def finish(self):
        if self.inventoryId is None:
            inventoryId = self.neededObjects.get('setInventoryId')
            if inventoryId is not None:
                self.inventoryId = inventoryId[0]
            elif not self.neededObjects.has_key('setInventoryId'):
                self.askForObjectField('DistributedPlayerPirateAI',
                                       'setInventoryId', self.avatarId)

            return None

        for (key, category) in self.newDoId.items():
            doId = self.neededObjects.get('newDoId_%s' % (key, ))
            if doId is not None:
                self.giveDoId(category, doId)
                del self.newDoId[key]
                continue

        if len(self.newDoId) or not (self.readyToSend):
            return None

        if not self.isTradeSent():
            self._sendTrade()
            return None

        AsyncRequest.finish(self)
    def _sendTrade(self):
        context = self.air.allocateContext()

        try:
            self._normalizeTrade()
        except AITradeException:
            e = None
            self.notify.warning(
                'trade rejected by _normalizeTrade or _checkRules %s' % (e, ))
            self.air.writeServerEvent(
                'failedNormalizeTrade', self.inventoryId,
                '%s|%s|%s|%s' % (self.giving, self.taking, e, context))
            self.rejectApprovedTrade(None, 1)
            return None

        if len(self.giving) or len(self.taking):
            self.neededObjects[self.responseKey] = None
            self.acceptOnce(self.rejectTradeMsg(context),
                            Functor(self.rejectApprovedTrade, context), [])
            self.acceptOnce(self.approvedTradeMsg(context),
                            Functor(self.approvedTradeResponse, context), [])
            origin = self.getOrigin()
            self.air.getInventoryMgr(self.avatarId).sendApprovedTrade(
                0, self.inventoryId, self.giving, self.taking, context, origin,
                self.unequippables)
        else:
            AsyncRequest.finish(self)
Пример #3
0
 def finish(self):
     #print "AddGiftRequestFR FINISH"
     """
     gift = self.distObj.avatarIdToGifts.get(self.avatarId)
     if gift == None:
         gift=self.neededObjects.get("setGiftSchedule")[0]
     gift.append(self.newGift)
     self.distObj.writeGift(self.avatarId, gift, self.replyToChannelId)
     AsyncRequest.finish(self)
     """
     giftBlob = self.distObj.avatarIdToGifts.getData(self.avatarId)
     if giftBlob == None:
         giftBlob = self.neededObjects.get("setGiftSchedule")[0]
     giftItem = CatalogItemList.CatalogItemList(
         self.newGift,
         store=CatalogItem.Customization | CatalogItem.DeliveryDate)
     giftList = CatalogItemList.CatalogItemList(
         giftBlob,
         store=CatalogItem.Customization | CatalogItem.DeliveryDate)
     giftList.append(giftItem[0])
     giftBlob = giftList.getBlob(CatalogItem.Customization
                                 | CatalogItem.DeliveryDate)
     self.distObj.writeGiftFR(self.avatarId, giftBlob,
                              self.replyToChannelId, self.senderId,
                              self.context, self.retcode)
     AsyncRequest.finish(self)
Пример #4
0
    def finish(self):
        #print "AddGiftRequestFR FINISH"
        """
        gift = self.distObj.avatarIdToGifts.get(self.avatarId)
        if gift == None:
            gift=self.neededObjects.get("setGiftSchedule")[0]
        gift.append(self.newGift)
        self.distObj.writeGift(self.avatarId, gift, self.replyToChannelId)
        AsyncRequest.finish(self)
        """
        giftBlob = self.distObj.avatarIdToGifts.getData(self.avatarId)
        if giftBlob == None:
            giftBlob = self.neededObjects.get("setGiftSchedule")[0]
        giftItem = CatalogItemList.CatalogItemList(
            self.newGift,
            store=CatalogItem.Customization | CatalogItem.DeliveryDate)
        giftList = CatalogItemList.CatalogItemList(
            giftBlob,
            store=CatalogItem.Customization | CatalogItem.DeliveryDate)
        if giftItem[0].giftCode != ToontownGlobals.GIFT_RAT:
            #print("Gift Item not RAT")
            giftList.append(giftItem[0])
            giftBlob = giftList.getBlob(CatalogItem.Customization
                                        | CatalogItem.DeliveryDate)
        else:
            #print("Gift Item is RAT")
            giftBlob = AccumRATBeans(giftItem[0], giftBlob)
        self.distObj.writeGift(self.avatarId, giftBlob, self.replyToChannelId)
        giftList.append(giftItem[0])
        giftBlob = giftList.getBlob(CatalogItem.Customization
                                    | CatalogItem.DeliveryDate)
        self.distObj.writeGift(self.avatarId, giftBlob, self.replyToChannelId)

        AsyncRequest.finish(self)
Пример #5
0
    def rejectApprovedTrade(self, context, reasonId):
        if context != None:
            self.ignore(self.approvedTradeMsg(context))
        for failureInfo in self.failureCallback:
            apply(failureInfo[0], failureInfo[1] + [self] + [reasonId])

        AsyncRequest.finish(self)
Пример #6
0
    def finish(self):
        #print("PurchaseGiftRequest FINISH")
        sAv = self.neededObjects[self.senderId]
        rAv = self.neededObjects[self.receiverId]
        self.item = CatalogItem.getItem(self.itemBlob, store = CatalogItem.Customization)
        retcode = None
        #put neat stuff here
        #-----------------------------------------------------------------------------
        retcode = self.checkGift(retcode)
        retcode = self.checkCatalog(retcode)
        #retcode = self.checkMoney(retcode)
        retcode = self.checkGender(retcode)
        retcode = self.checkPurchaseLimit(retcode)
        retcode = self.checkMailbox(retcode)
        if (retcode != None):
                self.distObj.sendUpdateToChannel(self.replyToChannelId, "receiveRejectPurchaseGift",
                [self.senderId, self.context, retcode, self.cost])
        else:
            now = (int)(time.time() / 60 + 0.5)
            deliveryTime = self.item.getDeliveryTime() / self.distObj.timeScale
            if deliveryTime < 2:
                deliveryTime = 2
            self.item.deliveryDate = int(now + deliveryTime)
            #self.item.giftTag = self.senderId
            itemList = CatalogItemList.CatalogItemList([self.item])
            itemBlob = itemList.getBlob(store = CatalogItem.Customization | CatalogItem.DeliveryDate)
            retcode = ToontownGlobals.P_ItemOnOrder
            self.distObj.addGiftFR(self.receiverId, itemBlob, self.senderId, self.context, retcode, self.replyToChannelId)
        #-----------------------------------------------------------------------------

        AsyncRequest.finish(self)
    def finish(self):
        if self.inventoryId is None:
            inventoryId = self.neededObjects.get("setInventoryId")
            if inventoryId is not None:
                self.inventoryId = inventoryId[0]
            elif not self.neededObjects.has_key("setInventoryId"):
                self.askForObjectField("DistributedPlayerPirateAI", "setInventoryId", self.avatarId)

            return None

        for (key, category) in self.newDoId.items():
            doId = self.neededObjects.get("newDoId_%s" % (key,))
            if doId is not None:
                self.giveDoId(category, doId)
                del self.newDoId[key]
                continue

        if len(self.newDoId) or not (self.readyToSend):
            return None

        if not self.isTradeSent():
            self._sendTrade()
            return None

        AsyncRequest.finish(self)
Пример #8
0
    def finish(self):

        giftListBlob=self.neededObjects.get("setGiftSchedule")[0]
        giftList = CatalogItemList.CatalogItemList(giftListBlob, store = CatalogItem.Customization | CatalogItem.DeliveryDate)
        delivered, remaining = giftList.extractDeliveryItems(self.time)
        giftBlob = remaining.getBlob(CatalogItem.Customization | CatalogItem.DeliveryDate)
        self.distObj.writeGiftField(self.avatarId, giftBlob, self.replyToChannelId)
        AsyncRequest.finish(self)
    def rejectApprovedTrade(self, context, reasonId):
        if context != None:
            self.ignore(self.approvedTradeMsg(context))

        for failureInfo in self.failureCallback:
            apply(failureInfo[0], failureInfo[1] + [self] + [reasonId])

        AsyncRequest.finish(self)
Пример #10
0
 def finish(self):
     """Report back on all the toon database objects that we got."""
     replyString = str(self.neededObjects)
     #self.browserReplyTo.respond(replyString)
     self.awardManagerDo.gotTheToons(self._isDcRequest, self._dcId,
                                     self.neededObjects, self.item,
                                     self.specialEventId,
                                     self.browserReplyTo,
                                     self.specialCommands, self.echoBack)
     AsyncRequest.finish(self)
Пример #11
0
    def finish(self):
        #print("AddItem FINISH")
        rAv = self.neededObjects[self.receiverId]
        self.item = CatalogItem.getItem(self.itemBlob, store = CatalogItem.Customization)

        now = (int)(time.time() / 60 + 0.5)
        deliveryTime = self.item.getDeliveryTime() / self.distObj.timeScale
        #if deliveryTime < 2:
        #    deliveryTime = 2
        deliveryTime = 2
        self.item.deliveryDate = int(now + deliveryTime)
        itemList = CatalogItemList.CatalogItemList([self.item])
        itemBlob = itemList.getBlob(store = CatalogItem.Customization | CatalogItem.DeliveryDate)
        retcode = ToontownGlobals.P_ItemOnOrder
        self.distObj.addGift(self.receiverId, itemBlob, self.replyToChannelId)
        #-----------------------------------------------------------------------------

        AsyncRequest.finish(self)
Пример #12
0
    def _sendTrade(self):
        context = self.air.allocateContext()
        
        try:
            self._normalizeTrade()
        except AITradeException:
            e = None
            self.notify.warning('trade rejected by _normalizeTrade or _checkRules %s' % (e,))
            self.air.writeServerEvent('failedNormalizeTrade', self.inventoryId, '%s|%s|%s|%s' % (self.giving, self.taking, e, context))
            self.rejectApprovedTrade(None, 1)
            return None

        if len(self.giving) or len(self.taking):
            self.neededObjects[self.responseKey] = None
            self.acceptOnce(self.rejectTradeMsg(context), Functor(self.rejectApprovedTrade, context), [])
            self.acceptOnce(self.approvedTradeMsg(context), Functor(self.approvedTradeResponse, context), [])
            origin = self.getOrigin()
            self.air.getInventoryMgr(self.avatarId).sendApprovedTrade(0, self.inventoryId, self.giving, self.taking, context, origin, self.unequippables)
        else:
            AsyncRequest.finish(self)
Пример #13
0
                '%s|%s|%s|%s' % (self.giving, self.taking, e, context))
            self.rejectApprovedTrade(None, 1)
            return
        else:
            if len(self.giving) or len(self.taking):
                self.neededObjects[self.responseKey] = None
                self.acceptOnce(self.rejectTradeMsg(context),
                                Functor(self.rejectApprovedTrade, context), [])
                self.acceptOnce(self.approvedTradeMsg(context),
                                Functor(self.approvedTradeResponse, context),
                                [])
                origin = self.getOrigin()
                self.air.getInventoryMgr(self.avatarId).sendApprovedTrade(
                    0, self.inventoryId, self.giving, self.taking, context,
                    origin, self.unequippables)
            AsyncRequest.finish(self)

        return

    def rejectTradeMsg(self, context):
        return 'rejectApprovedTrade-%s' % (context, )

    def approvedTradeMsg(self, context):
        return 'approvedTradeResponse-%s' % (context, )

    def isGift(self, inventoryType):
        for gift in self.giving:
            if gift[0] == inventoryType:
                return 1

        return 0
Пример #14
0
 def finish(self):
     avatar = self.neededObjects[self.avatarId]
     #put neat stuff here
     AsyncRequest.finish(self)