def back(self): ''' Take ONE fleet back. ''' request = game.port_expedition_back() utils.random_sleep(1) self.decks = request.body["api_deck_port"] return self.port
def find_lat_long(self, location): print('Attempting to find coordinates...') d = self.driver d.get('https://www.google.com/') # opens google random_sleep() d.find_element_by_xpath( '/html/body/div[2]/div[3]/form/div[2]/div[1]/div[1]/div/div[2]/input' ).send_keys(location + ' latitude and longitude' + Keys.RETURN) sleep(1) try: text = d.find_element_by_xpath( '//div[@class=\'Z0LcW XcVN5d\']' ).text # lat and lon shows up in two forms - res = True sleep(1) except NoSuchElementException: res = False try: data = d.find_element_by_xpath( '//*[@data-attrid="kc:/location/location:coordinates"]' ) # - so these account for both forms text = data.get_attribute('data-entityname') res = True sleep(1) except NoSuchElementException: res = False if res == False: print('Coordinates could not be found.') text = '' else: print('Coordinates found.') print( '-------------------------------------------------------------------------------' ) return text
def wait(self): end = 2145888000 # 2038-01-01 for t in self.exp_time: if t is not None and t < end: end = t utils.random_sleep_until(end - 50, end + 30, 60) if time.time() > self.stop_time: print("Reach running hours limit.") return None if datetime.datetime.now().hour < 6 or datetime.datetime.now( ).hour > 2: print('Skipping midnight to avoid possible \'201\'s') LOCAL_TZ = datetime.datetime.now( datetime.timezone(datetime.timedelta(0))).astimezone().tzinfo target = datetime.datetime.now().replace(tzinfo=LOCAL_TZ, hour=6, minute=0) utils.random_sleep_until(calendar.timegm(target.utctimetuple())) # Clear API server to avoid affect by player's action. api_server.empty() request = game.dock_back_to_port() utils.random_sleep(2) self.decks = request.body["api_deck_port"] utils.random_sleep(2) return self.port
def auto_destroy(): game.set_foremost() while True: print("!! auto destroy") game.factory_destroy_select_first() game.factory_destroy_do_destory() utils.random_sleep(0.4)
def port_open_panel_sortie(): random_sleep(2.1) port_open_main_sortie() point = random_point(Point(144, 175), Point(313, 335)) point.click() wait("/kcsapi/api_get_member/mapinfo") random_sleep(2.5) # 动画时间
def change_field(text): wait_element(self.driver, '//span[@class="editable-clear-x"]', timeout=2) click(self.driver, self.driver.find_element_by_class_name('editable-clear-x')) random_sleep() self.driver.find_element_by_class_name('input-large').send_keys(str(text)) click(self.driver, self.driver.find_element_by_xpath("//button[@class='btn btn--green editable-submit']")) random_sleep(delay=0.5)
def combat_retreat(): print("combat_retreat") combat_button_right() request = wait("/kcsapi/api_port/port") wait("/kcsapi/api_get_member/useitem") random_sleep(1.2) # 动画时间 return request
def get_profiles(self, button_xpath: str, count_xpath: str): d = self.driver profile_list = [] actions = ActionChains(d) press_tab = actions.send_keys(Keys.TAB) self.open_link(config.user_profile) # open user proile self.click_button(button_xpath) # click follow(er/ing) button num = int(self.save_number(count_xpath)) # save number follow(er/ing) press_tab.perform() # skips 'x' button # scroll through dialog, collecting profile links while len(profile_list) < num - 10: try: profiles_in_view = self.save_links(xpaths.profile_link, '.com/') [ profile_list.append(x) for x in profiles_in_view if x not in profile_list ] for _ in range(len(profiles_in_view) * 3): press_tab.perform() sleep(0.5) except NoSuchElementException: continue print(len(profile_list)) random_sleep() return profile_list
def port_open_panel_expedition(): print("port_open_panel_expedition") random_click(Point(161, 211), Point(238, 298)) random_sleep(1) random_click(Point(594, 140), Point(765, 300)) wait("/kcsapi/api_get_member/mission") random_sleep(1.2) # 动画时间
def port(self): hasBack = hasSupply = hasDepart = False for deck in self.decks: i = deck["api_id"] - 2 if i < 0: continue if self.exp_no[i] is not None: if deck["api_mission"][0] == 1: self.fleet_status[i] = 1 self.exp_time[i] = deck["api_mission"][2] / 1000 if deck["api_mission"][0] == 2: hasBack = True self.fleet_status[i] = 2 self.exp_time[i] = deck["api_mission"][2] / 1000 if self.fleet_status[i] == 0: hasDepart = True if self.fleet_status[i] == 2: hasSupply = True utils.random_sleep(1) if hasBack: return self.back if hasSupply: return self.supply if hasDepart: return self.depart else: return self.wait
def port(self): game.poi_switch_panel_main() utils.random_sleep(2) # 动画时间 game.port_open_panel_supply() game.supply_current_fleet() return None
def factory_destroy_do_destory(): print("factory_destroy_do_destory") point = random_point(Point(641, 420), Point(743, 452)) point.click() random_sleep(4) wait(("/kcsapi/api_req_kousyou/destroyship", "/kcsapi/api_req_kousyou/destroyitem2"))
def dung_compiler(code_num=50): """ > コンパイルが動いている風コード """ while True: print("".join([str(int(random() * 10)) for _ in range(code_num)])) random_sleep(0.1, 0.5)
def port_open_panel_expedition(): random_sleep(1) port_open_main_sortie() print("port_open_panel_expedition") random_click(Point(594, 170), Point(750, 340)) wait("/kcsapi/api_get_member/mission") random_sleep(2.2) # 动画时间
def dock_back_to_port(): print("dock_back_to_port") point = random_point(Point(30, 35), Point(75, 70)) point.click() request = wait("/kcsapi/api_port/port") random_sleep(1) return request
def combat_advance(): print("combat_advance") combat_button_left() req_ship_deck = wait("/kcsapi/api_get_member/ship_deck") req_next = wait("/kcsapi/api_req_map/next") random_sleep(1) # 动画时间 return req_ship_deck, req_next
def combat_retreat_flagship_damaged(): print("combat_retreat_flagship_damaged") random_sleep(4) combat_button_retreat_flagship_damaged() request = wait("/kcsapi/api_port/port") wait("/kcsapi/api_get_member/useitem") random_sleep(1.2) # 动画时间 return request
def port_open_panel_sortie(): print("port_open_panel_sortie") point = random_point(Point(161, 211), Point(238, 298)) point.click() random_sleep(1) point.click() wait("/kcsapi/api_get_member/mapinfo") random_sleep(1.2) # 动画时间
def supply_first_ship(): print("supply_first_ship") point = random_point(Point(175, 150), Point(300, 180)) point.click() random_sleep(0.8) point = random_point(Point(660, 430), Point(748, 455)) point.click() wait("/kcsapi/api_req_hokyu/charge") random_sleep(1) # 动画时间
def sortie_confirm(): print("sortie_confirm") point = random_point(Point(638, 450-22), Point(712, 481-22)) point.click() random_sleep(0.6) point.click() request = wait("/kcsapi/api_req_map/start") random_sleep(1) # 动画时间 return request
def sortie_confirm(): print("sortie_confirm") point = random_point(Point(593, 466), Point(768, 490)) point.click() random_sleep(1.6) point = random_point(Point(534, 466), Point(694, 490)) point.click() request = wait("/kcsapi/api_req_map/start") random_sleep(1) # 动画时间 return request
def expedition_select_fleet(i): print("expedition_select_fleet", i) if not (2 <= i <= 4): raise ValueError() select_fleet = globals()["expedition_select_fleet_%d" % i] if callable(select_fleet): select_fleet() random_sleep(1) else: raise NotImplementedError()
def supply_select_fleet(i): print("supply_select_fleet", i) if not (1 <= i <= 4): raise ValueError() select_fleet = globals()["supply_select_fleet_%d" % i] if callable(select_fleet): random_sleep(1) select_fleet() random_sleep(1) else: raise NotImplementedError()
def deliever_card(): """投递名片""" for hunter in hunters: hc = HunterAssistant(hunter) hc.deliver_card() # 切换账号 random_sleep(60) # 投递完成 log_q.put('今日所有猎头任务完成!') # 点击退出销毁窗口 btn.configure(text='退出', command=root.destroy)
def sortie_select(area, map): print("sortie_select: %d-%d" % (area, map)) if area > 30: area = 'ex' select_area = globals()["sortie_select_area_{}".format(area)] select_map = globals()["sortie_select_map_{}".format(map)] if callable(select_area) and callable(select_map): select_area() random_sleep(0.6) select_map() random_sleep(1) else: raise NotImplementedError()
def poi_refresh_page(): print("poi_refresh_page") point = Point(755, 495) point.click() random_sleep(0.4) system = platform.system() if system == "Windows": pyautogui.press('f5') if system == "Linux": pyautogui.hotkey('ctrl', 'r') if system == "Darwin": pyautogui.hotkey('command', 'r')
def dung_status_change(sharp_num=50): """ > ステータスが変化してる風コード """ counter = 0 while True: if counter < sharp_num: print("#", end="", flush=True) else: print(" done!!") counter = -1 counter += 1 random_sleep(0.01, 0.1)
def supply(self): ''' Supply all. ''' game.port_open_panel_supply() for i in range(3): if self.exp_no[i] is not None and self.fleet_status[i] == 2: game.supply_select_fleet(i + 2) game.supply_current_fleet() self.fleet_status[i] = 0 request = game.dock_back_to_port() utils.random_sleep(1) self.decks = request.body["api_deck_port"] return self.port
def _deliever_card(self, managers, delivered_count): # 剩余投递数 remaining = self.max_deliver_count - delivered_count # 投递 while remaining > 0 and len(managers) > 0: manager = managers.pop() if self.recommend(manager, self.case_id) is True: print('递送成功!经理人id:', manager) remaining -= 1 log_q.put('{} 递送成功!剩余任务量{}'.format(self.username, remaining)) else: print('递送失败!经理人id:', manager) log_q.put('{} 递送失败!经理人id:{}'.format(self.username, manager)) random_sleep(20)
def start(self): request = api_server.wait("/kcsapi/api_port/port") self.decks = request.body["api_deck_port"] for deck in self.decks: i = deck["api_id"] - 2 if i < 0: continue mission = deck["api_mission"] if mission[0] in (1, 2) and mission[1] > 0: self.exp_no[i] = mission[1] print("Expedition:", self.exp_no) utils.random_sleep(1) return self.port