def do_time_line(): global time_line, res, petst # dummy events = filter(lambda k: k< now(), time_line.keys()) for keys in events: if key not in time_line: continue # fix dowhat, parms = time_line[keys] print dowhat, parms, if dowhat== 'STEAL': print u"[偷鱼]:", while True: petst = req_safe(gameService, "getPetStatusAMF", uid, *parms) if petst['status']== u'b' and (not petst['is_stolen']): res = req_safe(gameService, "stealAMF", uid, *parms) if res.get('fish', 0): print_fish(res['fish']) break else: print u"失败" break elif petst['status']== u'c' and ((petst['rest_time'] or 1)<= 120): print '.', sys.stdout.flush() time.sleep(0.8) continue else: print u"失败" break elif dowhat== 'SHOCK': tank = req_safe(productsService, "getMyFishTankObjectListAMF", uid, *parms) # f['id']. tk['id'] is_worth_shock, is_need_feed = worth_shock(tank) if is_worth_shock: print u"[电鱼]:", #{'error': u'no remain time error'} if is_need_feed: print u"(喂食2)", req_fail(productsService, "feedAMF", uid, *(list(parms)+[2])) time.sleep(0.1) while True: res = req_safe(productsService, "shockAMF", uid, *parms) if res.get('get_shells', 0): print u"获得", res['get_shells'], u"贝壳", time_line[now()+240*60-random.randint(0, 3)-20] = ('SHOCK', parms) # need fix print "[EVENT Registered]" break else: if res.get('remain_time', 1000)<= 2: print ".", sys.stdout.flush() if parms[0]== 16: # 本句代码送给可爱的管理员 time.sleep(0.1) else: time.sleep(5) continue print u"失败", res time_line[now()+ res.get('remain_time', 240)*60 - 60] = ('SHOCK', parms) break elif dowhat== 'HARVEST': pet_dispath() elif dowhat== 'SYNTH': print u"[合成]:", # here can't assert always right, but bug res = req_safe(syntheticService, "getSynthesizeInfoAMF", uid) # dummy? res = syntheticService.compeleteSynthesizeAMF(uid, *parms) if res.get('error', False): print u"某错误发生. 重设所有合成鱼事件." for k in [i for i in time_line if time_line[i][0]== 'SYNTH']: del time_line[k] res = req_safe(syntheticService, "getSynthesizeInfoAMF", uid) process_synthetic_info(res) continue # noneed to go on and del elif res['result']: # success print u"获得%s %d经验" % (res['fish_name'], res['get_exp']) else: print u"合成失败, 渔民杯具了" res = req_safe(syntheticService, "addSynthesizeAMF", uid, formula_id) tl = [e for e in time_line if time_line[e][0]== 'SYNTH'] # bad, but Works t = max(tl) if tl else now() res = req_safe(syntheticService, "getSynthesizeInfoAMF", uid) # 上条多次重试时会导致出错,故加入 if res.get('synth_list', []): time_line[t+5+res['synth_list'][-1]['need_time']] = ('SYNTH', (res['synth_list'][-1]['synth_id'],)) print u"[EVENT Registered]" else: print u"自动合成出错, 可能是材料不足" else: print u"错误" del time_line[keys]
continue print '==', print_userinfo(info) if not synthinfo.get('error', False): print_synth_item(synthinfo) # 帮助好友提高成功率 ^_^ if synthinfo['helper_num']< 10: print u"帮助好友提高成功率:", res = req_safe(syntheticService, "addRateFriendAMF", uid, f['id'], synthinfo['synth_id']) print res.get('success_rate', res.get('error', "ERRPR")) # 偷鱼 if petst['status']== u'b' and (not petst['is_stolen']): print u"偷鱼:", res = gameService.stealAMF(uid, f['id']) if res['fish']: print_fish(res['fish']) else: print u"失败" elif petst['status']== u'c': print u"偷鱼:", print "[EVENT Registered]" time_line[now()+petst['rest_time']-12] = ('STEAL', (f['id'],)) req_fail(pubseaService, "getPubSeaInfoAMF", uid) userinfo = req_safe(membersService, "getUserInfoAMF", uid, uid) req_fail(productsService, "getMyFishTankListAMF", uid, uid) time.sleep(0.1) for tk in random_order(ftanks): userinfo = req_safe(membersService, "getUserInfoAMF", uid, uid) if random.randint(0,2)== 0: # dummy req req_fail(pubseaService, "getPubSeaInfoAMF", uid) req_fail(productsService, "getMyFishTankListAMF", uid, f['id'])