Exemple #1
0
    def perspective_refreshInboxList(self, charName, lastID):
        #Find all the mail since the last update (or first update)..a handful of joins here
        cnt = 0
        mailList = {}
        query = "SELECT id, message_from,subject,message_to,tin,message,time_end,item_proto from MailStore \
                 WHERE id > %d and message_to = '%s';" % (lastID, charName)
        for id, mail_from, subject, mail_to, tin, message, time_end, itemProto in self.conn.execute(
                query):
            cnt += 1
            mailList[id] = MailItem(mail_from, subject, mail_to, tin, message,
                                    time_end, id)
            mailList[id].itemProto = itemProto

        if cnt < 1:
            return None
        else:
            for id, mail in mailList.iteritems():
                if mail.itemProto:
                    item = ItemInstanceReceive(None, True)
                    #Populate the item with instance values
                    item.setItemAH(self.conn, id)
                    #Set Auction values to be used by the world server and client
                    item.auctionID = id
                    item.auctionItemID = mail.itemProto
                    mailList[id].item = item
            return mailList
 def perspective_finishAHBuyout(self, cost,auctionID, iid, charname,seller,bidder_id,bid_cost):
     #Create an ItemInstance.  ItemInstanceReceive is a wrapper to send it to the Mail Server
     item = ItemInstanceReceive(None, True)
     #Populate the item with instance values
     item.setItemAH(self.conn,auctionID)
     #Set Auction values to be used by the world server and client
     item.auctionID = auctionID
     item.auctionItemID = iid
     self.MailServerPerspective.callRemote("MailProxyAvatar","sendWinnings",item,cost,charname,seller)
     
     if bidder_id:
         self.conn.execute("SELECT charname FROM ItemCharacterMapping WHERE id = %s;"%bidder_id)
         lastbidder = self.conn.fetchone()[0]  
         self.MailServerPerspective.callRemote("MailProxyAvatar","refundBidBuyout",bid_cost,lastbidder,item.name) 
     #Update Tables
     self.conn.execute("DELETE from ItemList WHERE id = %s;"%auctionID)
     self.conn.execute("DELETE from ItemInstance WHERE item_list_id = %s;"%auctionID)
     self.conn.execute("DELETE from ItemVariant WHERE item_list_id = %s;"%auctionID)
     # Transaction DB is historic and is not deleted
     self.conn.execute("UPDATE ItemTransactionDB set purchased=1 WHERE item_list_id=%d;"%auctionID) 
     return (auctionID,seller,item.name)
 def perspective_checkRevoke(self, auctionID,charName):
     try:
         iid, bidder_id = self.conn.execute("SELECT item_id, bidder_id FROM ItemList WHERE id = %s;"%auctionID).fetchone()
         
         if not iid:
             return (None,None)
             
         if bidder_id:
             return (None,None)                         
         
         #Create an ItemInstance.  ItemInstanceReceive is a wrapper to send it to the Mail Server
         item = ItemInstanceReceive(None, True)
         #Populate the item with instance values
         item.setItemAH(self.conn,auctionID)
         #Set Auction values to be used by the world server and client
         item.auctionID = auctionID
         item.auctionItemID = iid
         self.MailServerPerspective.callRemote("MailProxyAvatar","sendRevoke",item,charName)
         self.perspective_revokeAHSell(auctionID)
         return (auctionID,item.name)
     except:
         return (None,None)
 def checkTimeStamps(self):
     #Check to make sure Mail Server Connection is up
     if not self.MailServerPerspective:
         self.timeStampSync = reactor.callLater(5,self.checkTimeStamps)
         return
         
     count = 0   
     #Send some mails
     for auctionID,itemProtoID,seller,cost,buyer in self.conn.execute("select item_list_id,item_proto_id,seller,last_bid,last_bidder from ItemTransactionDB WHERE inplay = 1 AND time_end < datetime('now','localtime');"):
         item = ItemInstanceReceive(None, True)
         #Populate the item with instance values
         item.setItemAH(self.conn,auctionID)
         #Set Auction values to be used by the world server and client
         item.auctionID = auctionID
         item.auctionItemID = itemProtoID
         count += 1
         
         #If there was a bid send the item and winnings, if not sent the item back to the seller
         if cost:
             self.MailServerPerspective.callRemote("MailProxyAvatar","sendWinnings",item,cost,buyer,seller)
         else:               
             self.MailServerPerspective.callRemote("MailProxyAvatar","auctionTimeLimit",item,seller)  
     
     if count <= 0:
         self.timeStampSync = reactor.callLater(60,self.checkTimeStamps)
         return
         
     #Update Tables
     self.conn.execute("DELETE from ItemList WHERE id IN (select item_list_id from ItemTransactionDB WHERE inplay = 1 AND time_end < datetime('now','localtime'))" )
     self.conn.execute("DELETE from ItemInstance WHERE item_list_id IN (select item_list_id from ItemTransactionDB WHERE inplay = 1 AND time_end < datetime('now','localtime'))" )
     self.conn.execute("DELETE from ItemVariant WHERE item_list_id IN (select item_list_id from ItemTransactionDB WHERE inplay = 1 AND time_end < datetime('now','localtime'))" )
         
     #Remove the items from being in play
     self.conn.execute("UPDATE ItemTransactionDB set inplay=0 WHERE inplay = 1 AND time_end < datetime('now','localtime');") 
     #Calls itself again in 60 seconds.  Change accordingly if needed.
     self.timeStampSync = reactor.callLater(60,self.checkTimeStamps)
 def perspective_getItemInfo(self, id, iid):
     item = ItemInstanceReceive(None, True)
     item.setItemAH(self.conn,id)
     item.auctionID = id
     item.auctionItemID = iid
     return item