def main(): # remove_friends(get_app(my_loginId, my_password, init=True), # (get_app(loginId, password, init=True) for loginId in b_loginIds)) # return #root = get_app(my_loginId, my_password) users = list(get_app(loginId, password) for loginId, password in root_users) #users = [get_app(loginId, password)] #users = [root] # add_friends(get_app(my_loginId, my_password, init=True), users) while True: for user in users: try: # import pdb;pdb.set_trace() if len(user.cards) > 180: logic.update_ap_bc(user, all_ap=True) logic.gacha_buy(user, keep_point=9000) logic.card_sell(user) user.logger.debug(user_info(user)) if not check_fairy(user): find_fairy(user) else: time.sleep(30 * b()) except HeaderError, e: user.logger.error("%s %s sleep for 15sec" % (e.code, e.message)) time.sleep(15 * b()) continue except Exception, e: user.logger.error("出错:%s. %s" % (e.message, traceback.format_exc())) time.sleep(15 * b()) except KeyboardInterrupt: save_app(user) break
def main(user, cname): global battle_time, last_id user.logger.info(user_info(user)) card = find_card(user, cname) cards = [card.serial_id] cost = card.cost if not last_id: last_id = random.randint(10000, 299999) last_id += random.randint(1, 10000) while True: try: logic.card_sell(user) if user.bc < KEEP_BC: if user.next_exp >= user.bc_max * 60 / cost and user.redtee > KEEP_REDTEE: user.logger.info("use redtee") user.userItem(REDTEE) if user.bc == user.bc_max: continue user.logger.error(" not enough redtee") continue if not battle_battle(user, last_id, cards=cards, desk_cost=cost): last_id += 15 continue except KeyboardInterrupt: save_app(user) break except HeaderError as e: if u"现在无法进行战斗" == e.message: user.logger.info(u"%s 现在无法进行战斗" % last_id) elif u"指定的玩家不存在" == e.message: user.logger.info(u"%s 指定的玩家不存在" % last_id) elif e.code == 9000: time.sleep(OUT_TIME * b()) user.login() else: user.logger.info("HeaderError:%s, sleep %ss %s" % (e.message, 60, traceback.format_exc())) time.sleep(OUT_TIME * b()) time.sleep(LOCKER_TIME) except Exception as e: time.sleep(LOCKER_TIME) user.logger.info("ERROR:%s, sleep %ss %s" % (e.message, 60, traceback.format_exc())) last_id += 1