Exemple #1
0
 def map_nodes():
     response = requests.get(f'{api_address}/map?key={database.license_key}')
     print(response.text)
     message = response.json()
     if message['success']:
         log.info('Succesfully loaded in latest map nodes.')
         _nodes = message['nodes']
         if _nodes != database.map_nodes:
             database.save_option('map_nodes', message['nodes'])
         else:
             log.info('We appear to have the latest map nodes.')
     else:
         log.error('Unable to access latest map nodes from API')
Exemple #2
0
def keep_alive():
    while True:
        response = requests.get(f'{api_address}/alive?key={database.license_key}')
        # print(response.text)
        message = response.json()
        if message['success']:
            if database.license_key_needed:
                database.save_option('license_key', database.license_key)
            log.info(message['message'])
            if database.edition != '':
                database.save_option('edition', message['edition'])
        else:
            log.error(message['message'])
        time.sleep(180)
Exemple #3
0
    def options_save(self, e=None):
        database.save_option('prestige_level', self.prestige_level.get())
        # config['OPTIONS']['in_guild'] = str(self.guild_state.get())
        database.save_option('auto_prestige', self.prestige_state.get())
        database.save_option('guild_missions', self.guild_missions_state.get())
        database.save_option('guardian', self.guardian_choice.get())

        self.window.deiconify()
        self.options_win.destroy()
Exemple #4
0
    def party_save(self):
        heroes = database.heroes.copy()
        selections = []
        selections.extend([
            self.party2.get(),
            self.party3.get(),
            self.party4.get(),
            self.party5.get()
        ])
        print(selections)

        party_slot_1 = self.party1.get()
        if party_slot_1 in heroes and party_slot_1 not in selections:
            database.save_option('party_slot_1', party_slot_1)
            heroes.remove(party_slot_1)
        else:
            messagebox.showerror(
                title="ERROR",
                message="PARTY SLOT 1: Invalid selection choice.")

        selections = []
        selections.extend([
            self.party1.get(),
            self.party3.get(),
            self.party4.get(),
            self.party5.get()
        ])
        print(selections)

        party_slot_2 = self.party2.get()
        if party_slot_2 in heroes and party_slot_2 not in selections:
            database.save_option('party_slot_2', party_slot_2)
            heroes.remove(party_slot_2)
        else:
            messagebox.showerror(
                title="ERROR",
                message="PARTY SLOT 2: Invalid selection choice.")

        selections = []
        selections.extend([
            self.party1.get(),
            self.party2.get(),
            self.party4.get(),
            self.party5.get()
        ])
        print(selections)

        party_slot_3 = self.party3.get()
        if party_slot_3 in heroes and party_slot_3 not in selections:
            database.save_option('party_slot_3', party_slot_3)
            heroes.remove(party_slot_3)
        else:
            messagebox.showerror(
                title="ERROR",
                message="PARTY SLOT 3: Invalid selection choice.")

        selections = []
        selections.extend([
            self.party1.get(),
            self.party2.get(),
            self.party3.get(),
            self.party5.get()
        ])
        print(selections)

        party_slot_4 = self.party4.get()
        if party_slot_4 in heroes and party_slot_4 not in selections:
            database.save_option('party_slot_4', party_slot_4)
            heroes.remove(party_slot_4)
        else:
            messagebox.showerror(
                title="ERROR",
                message="PARTY SLOT 4: Invalid selection choice.")

        selections = []
        selections.extend([
            self.party1.get(),
            self.party2.get(),
            self.party3.get(),
            self.party4.get()
        ])
        print(selections)

        party_slot_5 = self.party5.get()
        if party_slot_5 in heroes and party_slot_5 not in selections:
            database.save_option('party_slot_5', party_slot_5)
            heroes.remove(party_slot_5)
        else:
            messagebox.showerror(
                title="ERROR",
                message="PARTY SLOT 5: Invalid selection choice.")

        database.save_option('party_size', self.party_size.get())

        self.window.deiconify()
        self.party_win.destroy()
Exemple #5
0
def guild_expeditions():
    if datetime.now(
    ) > database.guild_mission_time_left and database.guild_missions:
        log.info("Checking on Guild Expedition status.")
        sleep(0.5)
        pyautogui.click(game_coords.town_coords)
        sleep(0.5)
        pyautogui.click(game_coords.guild_coords)
        sleep(0.5)
        pyautogui.click(game_coords.guild_expeditions_coords)
        sleep(0.5)
        # Take a screenshot of the mission timer
        pyautogui.screenshot(database.ocr_image,
                             region=(game_coords.relative_coords(
                                 600, 345, 200, 40)))
        sleep(0.5)
        # Attempt to read the time using OCR
        result = ocr(database.ocr_image)
        # If it doesn't say "Completed" but it's also not blank... it's probably a number?

        if result == "Completed":
            database.save_option(
                'ocr_succeed_count',
                int(database.read_option('ocr_succeed_count')) + 1)
            log.info("Current mission was completed.")
            # Click on the "Claim" button.
            pyautogui.click(game_coords.relative_coords(1345, 335))
            sleep(2)  # Wait for it to process
            pyautogui.click(game_coords.relative_coords(
                1185, 720))  # Click OK on the popup that occurs
            log.info("Claimed.")
            sleep(2)  # Wait for it to process.
            pyautogui.click(game_coords.relative_coords(
                1335, 335))  # Click to start new expedition
            sleep(0.5)
            pyautogui.click(game_coords.big_close_coords,
                            clicks=3,
                            interval=0.5)  # Go back to main screen
            return

        elif is_num(result):
            database.save_option(
                'ocr_succeed_count',
                int(database.read_option('ocr_succeed_count')) + 1)
            time_left = int(
                result.partition(":")[0]
            ) + 1  # Add one minute to whatever minutes are left to be safe
            snooze = datetime.now() + timedelta(minutes=time_left)
            database.save_option('guild_mission_time_left', snooze)
            log.info(
                f"Current mission should complete in {time_left}min. Going Home."
            )
            pyautogui.click(game_coords.big_close_coords,
                            clicks=3,
                            interval=0.5)  # Go back to main screen
            sleep(0.5)
            return

        else:
            # If we can't tell, let's make sure it's not saying there are none.
            log.info("Checking to see if we're out of guild expeditions.")
            pyautogui.screenshot(database.ocr_image,
                                 region=(game_coords.relative_coords(
                                     625, 520, 690, 65)))
            sleep(0.5)  # Give it time to save the image
            result = ocr(database.ocr_image)  # attempt to read it

            if result == "There are no pending expeditions.":
                database.save_option(
                    'ocr_succeed_count',
                    int(database.read_option('ocr_succeed_count')) + 1)
                log.info("There are no more expeditions available right now.")
                pyautogui.screenshot(database.ocr_image,
                                     region=(game_coords.relative_coords(
                                         1030, 145, 145, 35)))
                sleep(0.5)
                result = ocr(database.ocr_image)

                if is_num(result):
                    database.save_option(
                        'ocr_succeed_count',
                        int(database.read_option('ocr_succeed_count')) + 1)
                    if len(result.partition(":")) > 1:
                        # TODO: This math is off, it needs to consider 3 part timecodes and not just 2 re: partition
                        hours = int(result.partition(":")[0]) * 60
                        print(hours)
                        temp = result.partition(":")[2]
                        min = (int(temp.partition(":")[0]) + 1) * 60
                        print(min)

                        time_left = hours + min
                        print(time_left)
                    else:
                        time_left = int(result.partition(":")[0]) * 60

                    snooze = datetime.now() + timedelta(minutes=time_left)
                    database.save_option('guild_mission_time_left',
                                         snooze)  # Set timer
                    log.info(
                        f"More missions available in {time_left / 60}min. Returning home."
                    )
                    pyautogui.click(game_coords.big_close_coords,
                                    clicks=3,
                                    interval=0.5)  # Go back to main screen
                    return
                else:
                    database.save_option(
                        'ocr_fail_count',
                        int(database.read_option('ocr_fail_count')) + 1)
                    # TODO: Determine if this is still necessary. DISABLED for now.
                    # if db.ocr_f_pct > 50:
                    #     pyautogui.screenshot(os.path.expanduser("~") + f"/Documents/Firestone Bot/OCR/Fail_{db.ocr_fail_count}_{round(time(), 5)}.png")
                    log.warning(
                        "I wasn't able to determine expedition renewal time. Returning home."
                    )
                    pyautogui.click(game_coords.big_close_coords,
                                    clicks=3,
                                    interval=0.5)  # Go back to main screen
                    return

        database.save_option('ocr_fail_count',
                             int(database.read_option('ocr_fail_count')) + 1)
        # TODO: Determine if this is still necessary. DISABLED for now.
        # if db.ocr_f_pct > 50:
        #     pyautogui.screenshot(
        #         os.path.expanduser("~") + f"/Documents/Firestone Bot/OCR/Fail_{db.ocr_fail_count}_{round(time(), 5)}.png")
        log.warning("Unable to ascertain the current mission status.")
        log.info("Trying to start a new expedition anyway.\nReturning home.")
        pyautogui.click(game_coords.relative_coords(
            1335, 335))  # Click to start new expedition
        sleep(0.5)
        pyautogui.click(game_coords.big_close_coords, clicks=3,
                        interval=0.5)  # Go back to main screen
        sleep(0.5)
        return
Exemple #6
0
def auto_prestige():
    if database.auto_prestige and database.prestige_check_time <= datetime.now(
    ):
        time.sleep(0.5)
        pyautogui.click(game_coords.town_coords)
        time.sleep(0.5)
        pyautogui.click(game_coords.temple_of_eternals_coords)
        time.sleep(0.5)
        pyautogui.click(game_coords.relative_coords(1359,
                                                    560))  # Open prestige menu
        time.sleep(0.5)

        pyautogui.screenshot(database.ocr_image,
                             region=(game_coords.relative_coords(
                                 1070, 745, 160, 70)))
        result = ocr(database.ocr_image)

        # while not isNum(result, 2):
        #     pyautogui.screenshot(database.OCR_IMAGE, region=(relCoords(1070, 745, 160, 70)))
        #     result = ocr(database.OCR_IMAGE)

        if is_num(result, 2):
            database.save_option(
                'ocr_succeed_count',
                int(database.read_option('ocr_succeed_count')) + 1)

            prestige_level = round(float(result[1:]), 2)

        else:
            database.save_option(
                'ocr_fail_count',
                int(database.read_option('ocr_fail_count')) + 1)
            log.warning("Wasn't able to ascertain our current prestige level.")
            # TODO: Determine if this is still necessary. DISABLED for now.
            # if db.ocr_f_pct > 50:
            #     pyautogui.screenshot(os.path.expanduser("~") + f"/Documents/Firestone Bot/OCR/Fail_{db.ocr_fail_count}_{round(time(), 5)}.png")

        if prestige_level:
            progress = round(
                (prestige_level / int(database.prestige_level)) * 100)
            log.info(
                f"Current earnings are at {prestige_level}x which is {progress}% of our goal."
            )
            time.sleep(0.5)

            snooze = ((progress - 100) / (0 - 100)) * ((60 - 1) + 1) * 1000
            if snooze <= 1000:
                snooze = 1000
            elif snooze >= 60000:
                snooze = 60000
            database.save_option('prestige_check_time',
                                 datetime.now() + timedelta(seconds=snooze))
            log.info(
                f"Will wait {round((snooze / 1000), 2)}min before checking Prestige progress again."
            )
            time.sleep(0.5)

            if prestige_level >= int(database.prestige_level):
                log.info("Firestone earnings are satisfactory. Prestiging...")
                pyautogui.click(game_coords.relative_coords(
                    1160, 525))  # Click on FREE prestige option
                time.sleep(15)  # Wait for prestige to finish

                pyautogui.click(
                    game_coords.guardian_click_coords, clicks=20,
                    interval=1.1)  # Let's get some gold to buy party with

                setup_party()
                change_upgrade_progression('Milestone')

        log.info("Going back to home screen. Prestige not ready.")
        pyautogui.click(game_coords.big_close_coords, clicks=3,
                        interval=0.5)  # Go home because we're not prestiging
Exemple #7
0
def setup_party():
    log.info("Setting up the party.")
    time.sleep(0.5)
    pyautogui.click(game_coords.party_coords)

    if database.party_size >= 1:
        time.sleep(0.5)
        log.info("Buying first party slot.")
        pyautogui.click(game_coords.relative_coords(
            802, 795))  # Buy fist party slot
    if database.party_size >= 2:
        time.sleep(0.5)
        log.info("Buying second party slot.")
        pyautogui.click(game_coords.relative_coords(775,
                                                    540))  # Buy second slot
    if database.party_size >= 3:
        time.sleep(0.5)
        log.info("Buying third party slot.")
        pyautogui.click(game_coords.relative_coords(
            575, 815))  # Buying third party slot
    if database.party_size >= 4:
        time.sleep(0.5)
        log.info("Buying fourth party slot.")
        pyautogui.click(game_coords.relative_coords(
            550, 445))  # Buying fourth party slot
    if database.party_size >= 5:
        time.sleep(0.5)
        log.info("Buying fifth party slot.")
        pyautogui.click(game_coords.relative_coords(
            510, 630))  # Buying fifth party slot

    if database.party_size >= 1:
        time.sleep(0.5)
        img = pyautogui.locateCenterOnScreen(
            image_path('hero_' + database.party_slot_1.lower() + '.png'))
        pyautogui.click(img)
    if database.party_size >= 2:
        time.sleep(0.5)
        img = pyautogui.locateCenterOnScreen(
            image_path('hero_' + database.party_slot_2.lower() + '.png'))
        pyautogui.click(img)
    if database.party_size >= 3:
        time.sleep(0.5)
        img = pyautogui.locateCenterOnScreen(
            image_path('hero_' + database.party_slot_3.lower() + '.png'))
        pyautogui.click(img)
    if database.party_size >= 4:
        time.sleep(0.5)
        img = pyautogui.locateCenterOnScreen(
            image_path('hero_' + database.party_slot_4.lower() + '.png'))
        pyautogui.click(img)
    if database.party_size >= 5:
        time.sleep(0.5)
        img = pyautogui.locateCenterOnScreen(
            image_path('hero_' + database.party_slot_5.lower() + '.png'))
        pyautogui.click(img)

    time.sleep(0.5)
    pyautogui.click(game_coords.relative_coords(1160,
                                                95))  # Click to save changes
    time.sleep(0.5)
    pyautogui.click(game_coords.big_close_coords)
    time.sleep(0.5)
    database.save_option('upgrade_status', 'x1')
    change_upgrade_progression('Milestone')
    time.sleep(0.5)
Exemple #8
0
def map_missions():
    spawn_points = [
        ast.literal_eval(i)
        for i in re.split('(?<=\)),(?=\()', str(database.map_nodes))
    ]

    pyautogui.click(game_coords.map_coords)  # Open the map
    time.sleep(1.5)

    pyautogui.screenshot(database.ocr_image,
                         region=(game_coords.relative_coords(825, 30, 100,
                                                             38)))
    result = ocr(database.ocr_image)

    if is_num(result, 3):
        database.save_option('map_troops', int(result[0]))
        log.info(f"We appear to have {database.map_troops} troops available.")

    # claim any completed map missions
    _map_mission_count = 0
    while True:
        if pyautogui.pixelMatchesColor(game_coords.relative_coords(232),
                                       game_coords.relative_coords(315),
                                       (247, 163, 66),
                                       tolerance=10):
            log.info("Claiming a map mission.")
            pyautogui.click(game_coords.relative_coords(232, 315))
            _map_mission_count += 1
            time.sleep(0.5)
            pyautogui.moveTo(game_coords.guardian_click_coords)
            pyautogui.press('esc')
            time.sleep(0.5)
        else:
            if _map_mission_count > 0:
                database.save_stat(
                    'total_map_missions',
                    database.total_map_missions + _map_mission_count)
            break

    if database.map_troops > 0:
        log.info("Entered map missions loop")
        for x in spawn_points:
            if database.map_troops > 0:
                log.debug(f"Clicking @ {x[0], x[1]}")
                pyautogui.click(x)  # Click known spawn points
                time.sleep(0.5)
                if pyautogui.pixelMatchesColor(
                        game_coords.relative_coords(830),
                        game_coords.relative_coords(960), (11, 161, 8),
                        tolerance=5):
                    pyautogui.click(game_coords.relative_coords(830, 960))
                    log.info("Started a mission.")
                    time.sleep(0.5)
                    pyautogui.press('esc')
                    time.sleep(0.5)
                    database.save_option('map_troops', database.map_troops - 1)
                    continue
                elif pyautogui.pixelMatchesColor(
                        game_coords.relative_coords(743),
                        game_coords.relative_coords(934), (231, 77, 66),
                        tolerance=5):
                    pyautogui.press('esc')
                else:
                    # pyautogui.press('esc')
                    # time.sleep(0.5)
                    continue
            else:
                break
    else:
        log.info("Going home.")

    pyautogui.press('esc')