Ejemplo n.º 1
0
 def run(self):
     user_card_info = commons.getMagicInfo(self.myHttpRequest, constant.USERNAME)
     self.user_exchange_box = commons.get_type_info(constant.EXCHANGEBOX, user_card_info)
     self.user_store_box = commons.get_type_info(constant.STOREBOX, user_card_info)
     card_friend_file = open("card_friend.txt", "r")
     accounts = card_friend_file.readlines()
     for account in accounts:
         account = account.replace("\n", "")
         if self.thread_stop:
             break
         if account.strip() != "":
             card_info = commons.getMagicInfo2(self.myHttpRequest, account)
             exchange_box = commons.get_type_info(constant.EXCHANGEBOX, card_info)
             for i, card_id in enumerate(exchange_box):
                 if self.thread_stop:
                     break
                 if int(card_id) != 0:
                     card_info = self.window.database.getCardInfo2(card_id)
                     if self.cardPrice != u"全部":
                         if (
                             card_info[2] == self.cardtheme
                             and card_info[1] == int(self.cardPrice)
                             and (self.cardDetail == -1 or card_info[2] == self.cardDetail)
                         ):
                             if -1 == self.exchange_card(i, card_id, card_info[1], card_info[0], account, 0):
                                 wx.CallAfter(self.window.updateLog, u"未找到对应面值的卡交换")
                                 return
                             pass
                         else:
                             continue
                     else:
                         if -1 == self.exchange_card(i, card_id, card_info[1], card_info[0], account, 0):
                             wx.CallAfter(self.window.updateLog, u"未找到对应面值的卡交换")
                             return
     wx.CallAfter(self.window.updateLog, u"换卡完成")
     pass
Ejemplo n.º 2
0
    def MenuSelectionCb(self, event ):
        print event.GetId()

        card_info = commons.getMagicInfo2(main.RefinedCard.main_http_request,self.selectAccount)

        self.httpRequest = accountManage.AccountManage.account_http_dic[self.selectAccount]

        exchange_box = commons.get_type_info(constant.EXCHANGEBOX,card_info)
        store_box = commons.get_type_info(constant.STOREBOX,card_info)

        dst_card_id = self.windows.select_card_id
        dst_type = 0
        dst_position = -1



        if self.windows.select_card_id in exchange_box:
            dst_position = exchange_box.index(self.windows.select_card_id)
        elif self.windows.select_card_id in store_box:
            src_position = store_box.index(self.windows.select_card_id)
            if 0 in exchange_box:
                dst_position = exchange_box.index(0)
                postData = {
                             'dest':dst_position,
                             'src':src_position,
                             'type':1,
                             'uin':self.selectAccount,
                }
                base_url = commons.getUrl(constant.CARDINPUTSTOREBOX,self.httpRequest)
                self.httpRequest.get_response(base_url,postData).read().decode('utf-8')

        if dst_position != -1:

            base_url1 = commons.getUrl(constant.SETTHEME,self.httpRequest)
            post_data = {
                'themes':0
            }
            self.httpRequest.get_response(base_url1,post_data).read().decode('utf-8')

            dst = str(dst_card_id)+"_"+str(dst_position)+"_"+str(dst_type)
            card_info = self.windows.exchang_card_info_dic[event.GetId()]
            src = str(card_info[2])+"_"+str(card_info[1])+"_"+str(card_info[0])
            base_url = commons.getUrl(constant.EXCHANGECARD,main.RefinedCard.main_http_request)
            post_data ={
                'cmd':1,
                'isFriend':0,
                'frnd':str(self.selectAccount),
                'uin':str(constant.USERNAME),
                'dst':dst,
                'src':src
            }
            page_content =  main.RefinedCard.main_http_request.get_response(base_url,post_data).read().decode('utf-8')
            post_data = {
                'themes':153
            }
            self.httpRequest.get_response(base_url1,post_data).read().decode('utf-8')
            if 'code="0"' in page_content:
                dlg = wx.MessageDialog(None, u"换卡成功", u"提示", wx.OK | wx.ICON_QUESTION)

            else:
                dlg = wx.MessageDialog(None, u"换卡成功", u"提示", wx.OK | wx.ICON_QUESTION)

            if dlg.ShowModal() == wx.ID_YES:
                self.Close(True)
                dlg.Destroy()
        else:
            dlg = wx.MessageDialog(None, u"换卡箱已满或卡片不存在", u"提示", wx.OK | wx.ICON_QUESTION)
            if dlg.ShowModal() == wx.ID_YES:
                self.Close(True)
            dlg.Destroy()


        #accountManage.AccountManage.account_http_dic.items()
        if 1==event.GetId():
            pass