def do_show_status(self, section, *args, **kwargs): r = alldata_client.get_alldata(self.account_info['sid']) item_mapping = { # 2: '魂力果實', # 3: '復活果實', # 5: '超魂力果實', 7: '轉蛋卷', 10: "金幣", 11: '聖靈幣', 13: '戒指', 15: '賭場幣', 20: '轉蛋幣', } data_list = r['body'][8]['data'] # logger.info(json.dumps(data_list, sort_keys=True, indent=2)) for data in data_list: try: self.logger.debug("{0} = {1}".format(item_mapping[data['item_id']], data['cnt'])) except KeyError: pass user_info = r['body'][4]['data'] for key, data in user_info.iteritems(): self.logger.debug(u"{0} = {1}".format(key, data))
def find_best_idx_to_explorer(self, area_pickup_list, except_card_id=[]): # for pickup in pickup_list: # self.logger.debug(pickup) # card_list = self.CC_GetAllData()['body'][6]['data'] card_list = alldata_client.get_alldata(self.account_info['sid'])['body'][6]['data'] self.logger.debug("Pickup attribute home: {0}".format(area_pickup_list['home'])) self.logger.debug("Pickup attribute job type: {0}".format(area_pickup_list['jobtype'])) self.logger.debug("Pickup attribute weapontype: {0}".format(area_pickup_list['weapontype'])) temp_idx = None for card in card_list: if card['id'] in except_card_id: self.logger.debug(u"跳過保留不去探索的卡片: {0}".format(card['id'])) continue if card['type'] == 0: temp_idx = card['idx'] card_doc = self.db.charainfo.find_one({"cid": card['id']}) if card_doc: # self.logger.debug("home:{0}, {1}".format(card_doc['home'], type(card_doc['home']))) # self.logger.debug("jobtype:{0}".format(card_doc['jobtype'])) # TODO: bug here, weapon type is not equal to battletype # how to solve it due to mongodb has no weapon type record # self.logger.debug("weapontype:{0}".format(card_doc['battletype'])) if (int(area_pickup_list['home']) == card_doc['home']) or ( int(area_pickup_list['jobtype']) == card_doc['jobtype']) or ( int(area_pickup_list['weapontype']) == card_doc['battletype']): temp_idx = card['idx'] if card_doc['rarity'] == 5: continue self.logger.debug(u"Found pickup card! {0}".format(card_doc['name'])) self.logger.debug(u"{0} is picked to eplorer".format(temp_idx)) return temp_idx else: # this card does not fit pick up criteria continue else: # DB has no record to do matching continue # self.logger.error("Cannot find card id {0} in database, please update DB".format(card['id'])) # self.logger.debug("{0} is picked to eplorer".format(temp_idx)) else: # card is not character continue self.logger.warning(u"找不到適合的探索角色,使用[{0}]".format(card_doc['name'])) return temp_idx
def do_show_all_cards(self, section, *args, **kwargs): """ 只列出四星/五星角色卡 """ r = alldata_client.get_alldata(self.account_info['sid']) card_list = r['body'][6]['data'] # logger.info(json.dumps(data_list, sort_keys=True, indent=2)) for card in card_list: if card['type'] != 0: # not character card continue try: cid = int(card['id']) card_dict = utils.card_helper.find_card_by_id(cid) if card_dict and card_dict['rarity'] >= 4: self.logger.debug(u"{0}, 界限突破:{1}, 等級: {2}, 稀有度: {3}".format( card_dict['name'], card['limit_break'], card['lv'], card_dict['rarity'])) except KeyError: raise except TypeError: raise
def do_subjugation(self, section, *args, **kwargs): parameter = dict() parameter['jid'] = self.config.getint(section, 'Jid') parties = self.config.options_with_prefix(section, 'pt_') parameter['pt_cids'] = list() for party in parties: parameter['pt_cids'].append(self.config.getlist(section, party)) # self.logger.debug(u"取得討伐戰資料") # r = subjugation_client.check_participant(parameter, self.account_info['sid']) # if != 0: # self.logger.debug(r) # return # get ecnt r = alldata_client.get_alldata(self.account_info['sid']) # r_json = simplejson.dumps(r, indent=2) # print r_json try: ecnt = r['body'][18]['data']['reached_expedition_cnt'] + 1 parameter['ecnt'] = ecnt except KeyError: self.logger.debug("Cant get ecnt data") parameter['ecnt'] = 1 try: rare_expedition_cnt = r['body'][18]['data']['rare_expedition']['expedition_cnt'] except: pass try: trying = r['body'][18]['data']['trying'] except: trying = False if parameter['ecnt'] > 40: parameter['ecnt'] = 40 # parameter['ecnt'] = 40 self.logger.info(u"第{0}次討伐".format(parameter['ecnt'])) self.logger.debug(u"取得討伐戰資料") if trying is False: r = subjugation_client.try_subjugation(parameter, self.account_info['sid']) if r['res'] == 0: self.logger.debug(u"進入討伐戰") data_idx = 1 else: self.logger.error(r['msg']) return else: self.logger.warning(u"已經在討伐中") data_idx = 19 self.logger.debug(u"取得關卡id") base_id_list = list() wave_list = list() rare_base_id = None rare_max_wave = None # print simplejson.dumps(r['body'][data_idx]['data']) for data in r['body'][data_idx]['data']: try: is_rare = data['rare'] except: is_rare = False if is_rare: # rare base id should be played in the end rare_base_id = data['base_id'] rare_max_wave = data['max_wave'] else: base_id_list.append(data['base_id']) wave_list.append(data['max_wave']) # append rare id in the end if rare_base_id is not None: base_id_list.append(rare_base_id) wave_list.append(rare_max_wave) parameter['wave_list'] = wave_list self.logger.debug(u"關卡id = {0}".format(base_id_list)) self.logger.debug(u"wave_list = {0}".format(wave_list)) # sys.exit(0) # Start # base_id_list = [6] # wave_list = [3] for idx, bid in enumerate(base_id_list): # self.logger.debug(u"Using Party {0}".format(idx)) self.logger.debug(u'討伐關卡: {0}'.format(bid)) parameter['bid'] = bid parameter['pt'] = idx parameter['wave'] = wave_list[idx] parameter['pt_cid'] = parameter['pt_cids'][idx] # Start entry # print parameter r = subjugation_client.start_subjugation(parameter, self.account_info['sid']) if r['res'] == 0: pass elif r['res'] == 1919: self.logger.debug(u"already finished") continue elif r['res'] == 1905: self.logger.debug(r) continue else: self.logger.debug(r) return # result = simplejson.dumps(r, indent=2) # print result # self.logger.debug("Start entry = {0}".format(r)) # Get Result r = subjugation_client.finish_subjugation(parameter, self.account_info['sid']) if r['res'] == 0: self.logger.debug(u'討伐關卡: {0} 完成'.format(bid)) else: self.logger.debug(r) return
def do_show_all_data(self, section, *args, **kwargs): r = alldata_client.get_alldata(self.account_info['sid']) print(simplejson.dumps(r, sort_keys=True, indent=2))