def loop(client, user, max_hours, exit_if_both_not_zero): puts("Working in stables for {0} hours".format(max_hours)) done_hours = 0 while True: wait_time = 3610 log_in(client, user, "Checking if we can log in") check_notifications(client) job_menu = SELECTORS.get_job_menu(client) if (job_menu): job_menu.click() job_do = SELECTORS.get_job_do(client) if (job_do): if (SELECTORS.get_points(client) != 0 or SELECTORS.get_dungeon_points(client) != 0 and exit_if_both_not_zero): puts("Exiting script because we can do fighting".format( done_hours)) return job_do.click() done_hours += 1 puts("Starting Job") else: puts("Already was working, waiting") wait_time = SELECTORS.get_job_cooldown_time(client) delay(wait_time) if (done_hours == max_hours): puts("Exiting script after working for {0} hours".format( done_hours)) return
def get_arena_provinciarum_enemy(client, enemy_selection): time.sleep(1) puts("Selected {0} enemy".format(enemy_selection)) try: return client.find_elements_by_class_name("attack")[enemy_selection - 1] except: puts("Cannot select enemy {0}".format(str(enemy_selection))) return False
def get_event_fight_enemy(client, enemy_selection): time.sleep(1) puts("Selected {0} enemy".format(enemy_selection)) try: return client.find_element_by_css_selector( "div.expedition_box:nth-child({0}) > div:nth-child(2) > button:nth-child(1)" .format(str(enemy_selection))) except: puts("Cannot select enemy {0}".format(str(enemy_selection))) return False
def get_location(client, location_selection): puts("Selected {0} location".format(location_selection)) try: client.execute_script("switchMenu(2)") time.sleep(1) return client.find_element_by_css_selector( "#submenu2 > a:nth-child({0})".format(str(location_selection))) except: puts("Cannot select place {0}".format(str(location_selection))) return False
def loop(client, user, enemy_selection, max_hp, exit_on_no_food, max_arenas): done_arenas = 0 log_in(client, user, "Checking if we can log in") # If cannot determine cooldown time, must be working or somethings wrong. Exit script if not (SELECTORS.get_arena_cooldown_time(client, True)): puts("Exiting arena provinciarum") return puts("Entering arena provinciarum") while True: wait_time = 60 log_in(client, user, "Checking if we can log in") check_notifications(client) # Check if we need to eat if check_hp(client, max_hp): arena_bar = SELECTORS.get_arena_bar(client) if (arena_bar): arena_bar.click() # Get go to tab tab = SELECTORS.get_arena_provinciarum_tab(client) if (tab): tab.click() if SELECTORS.is_arena_provinciarum_on_cooldown(client): puts("Arena on cooldown") wait_time = SELECTORS.get_arena_cooldown_time(client, False) else: puts("Starting arena") enemy = SELECTORS.get_arena_provinciarum_enemy( client, enemy_selection) if (enemy): enemy.click() done_arenas += 1 wait_time = 5 * 60 else: # Eat food wait_time = 0 if not (eat_food(client)): # no food if (exit_on_no_food): return else: wait_time = 30 * 60 if (done_arenas == max_arenas): puts("Exiting script after {0} arenas".format(max_arenas)) return delay(wait_time)
def loop(client, user, enemy_selection, max_hp, exit_on_zero_points, exit_on_no_food, max_events): done_events = 0 log_in(client, user, "Checking if we can log in") puts("Entering fight event") while True: wait_time = 60 log_in(client, user, "Checking if we can log in") check_notifications(client) # Check if we need to eat if check_hp(client, max_hp): # Go to expeditions expedition_bar = SELECTORS.get_expedition_bar(client) if (expedition_bar): expedition_bar.click() time.sleep(1) puts("Entering fight events") # Get go to location location = SELECTORS.get_event_fight_location(client) if (location): location.click() puts("Getting cooldowns") if SELECTORS.get_event_fight_cooldown_time(client, False): puts("Fight event on cooldown") wait_time = SELECTORS.get_event_fight_cooldown_time( client, False) else: puts("Starting fight event") enemy = SELECTORS.get_event_fight_enemy( client, enemy_selection) if (enemy): enemy.click() done_events += 1 wait_time = 5 * 60 else: # Eat food wait_time = 0 if not (eat_food(client)): # no food if (exit_on_no_food): return else: wait_time = 30 * 60 if (done_events == max_events): puts("Exiting script after {0} events".format(max_events)) return delay(wait_time)
def get_event_fight_location(client): try: return client.find_elements_by_class_name("menuitem")[-1] except: puts("Cannot go to fight events") return False
def loop(client, user, location_selection, exit_on_zero_points, max_dungeon_fights): done_dungeon_fights = 0 log_in(client, user,"Checking if we can log in") # If cannot determine cooldown time, must be working or somethings wrong. Exit script if not (SELECTORS.get_expedition_cooldown_time(client, True)): puts("Exiting dungeons") return puts("Doing dungeons") while True: wait_time = 60 log_in(client, user,"Checking if we can log in") check_notifications(client) # Check if we need to exit before delay if (SELECTORS.get_dungeon_points(client) == 0 and exit_on_zero_points): puts("Exiting dungeon script") return # Go to dungeons puts("Entering dungeons") dungeon_bar = SELECTORS.get_dungeon_bar(client) if (dungeon_bar): dungeon_bar.click() # Go to location location = SELECTORS.get_location(client, location_selection) if (location): location.click() # Go to dungeon tab puts("Clicking on dungeon tab") tab = SELECTORS.get_dungeon_tab(client) if (tab): tab.click() # Dificulty 1 puts("Selecting first difficulty") dif1 = SELECTORS.get_dungeon_dif1(client) if(dif1): dif1.click() else: puts("Couldn't select first difficulty, maybe already in a dungeon?") if SELECTORS.is_dungeon_on_cooldown(client): puts("Dungeon on cooldown") wait_time = SELECTORS.get_dungeon_cooldown_time(client, False) else: # Select first found label and click attack puts("Fighting in dungeon") areas = SELECTORS.get_dungeon_areas(client) if(areas): areas[0].click() done_dungeon_fights += 1 wait_time = 5 * 60 if (done_dungeon_fights == max_dungeon_fights): puts("Exiting script after {0} dungeons".format(done_dungeon_fights)) return delay(wait_time)
def loop(client, user, location_selection, enemy_selection, max_hp, exit_on_zero_points, exit_on_no_food, max_expeditions): done_expeditions = 0 log_in(client, user, "Checking if we can log in") # If cannot determine cooldown time, must be working or somethings wrong. Exit script if not (SELECTORS.get_expedition_cooldown_time(client, True)): puts("Exiting expeditions") return puts("Entering expeditions") while True: wait_time = 60 log_in(client, user, "Checking if we can log in") check_notifications(client) # Check if we need to exit before delay if (SELECTORS.get_points(client) == 0 and exit_on_zero_points): puts("Exiting expedition script") return # Check if we need to eat if check_hp(client, max_hp): # Go to expeditions expedition_bar = SELECTORS.get_expedition_bar(client) if (expedition_bar): expedition_bar.click() # Get go to location location = SELECTORS.get_location(client, location_selection) if (location): location.click() puts("Getting cooldowns") if SELECTORS.is_expedition_on_cooldown(client): puts("Expedition on cooldown") wait_time = SELECTORS.get_expedition_cooldown_time( client, False) else: puts("Starting expedition") enemy = SELECTORS.get_enemy(client, enemy_selection) if (enemy): enemy.click() done_expeditions += 1 wait_time = 5 * 60 else: # Eat food wait_time = 0 if not (eat_food(client)): # no food if (exit_on_no_food): return else: wait_time = 30 * 60 if (done_expeditions == max_expeditions): puts( "Exiting script after {0} expeditions".format(max_expeditions)) return delay(wait_time)