コード例 #1
0
ファイル: Authentication.py プロジェクト: div0ky/fsb_idle
 def __init__(self):
     log.info(f'{__name__} has been initialized.')
     if not database.license_key:
         self.get_license_key()
         Thread(target=keep_alive, daemon=True, name='Keep Alive').start()
     else:
         self.map_nodes()
         Thread(target=keep_alive, daemon=True, name='Keep Alive').start()
コード例 #2
0
ファイル: MouseLock.py プロジェクト: div0ky/fsb_idle
    def __init__(self):
        log.info(f'{__name__} has been initialized.')
        self.sentinel = False
        self.sWidth, self.sHeight = pyautogui.size()
        self.GAME_REGION = (0, 0, self.sWidth, self.sHeight)
        self.RETURN_COORDS = (self.GAME_REGION[2] / 2, self.GAME_REGION[3] / 2)

        threading.Thread(target=self.lockMouse, name="MouseLock",
                         daemon=True).start()
コード例 #3
0
ファイル: MouseLock.py プロジェクト: div0ky/fsb_idle
 def lockMouse(self):
     log.info("Mouse has been locked down.")
     while True:
         # print("Doing stuff.")
         pos = pyautogui.position()
         if pos[0] < self.GAME_REGION[0] or pos[1] < self.GAME_REGION[1] or pos[0] > self.GAME_REGION[2] or pos[1] > \
                 self.GAME_REGION[3]:
             pyautogui.moveTo(self.RETURN_COORDS)
             log.warning("Mouse was out of bounds and was rebounded.")
         if self.sentinel is True:
             return
         sleep(0.1)
コード例 #4
0
ファイル: Authentication.py プロジェクト: div0ky/fsb_idle
 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')
コード例 #5
0
ファイル: Authentication.py プロジェクト: div0ky/fsb_idle
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)
コード例 #6
0
def guardian_training():
    global last_check
    snooze = timedelta(minutes=5)
    if last_check + snooze <= datetime.utcnow():
        last_check = datetime.utcnow()
        log.info("Checking on Guardian Training")
        upgrade_color = (27, 102, 26)
        tolerance = 5
        time.sleep(0.75)
        pyautogui.click(game_coords.town_coords)
        time.sleep(0.5)
        pyautogui.click(game_coords.magic_quarter)
        time.sleep(0.5)
        if pyautogui.pixelMatchesColor(1030,
                                       790,
                                       upgrade_color,
                                       tolerance=tolerance):
            pyautogui.click(1030, 790)
            time.sleep(0.5)
            pyautogui.click(game_coords.big_close_coords,
                            clicks=2,
                            interval=0.5)
            log.info('Guardian training started. Going home.')
        else:
            log.info("Guardian training isn't ready yet. Going home.")
            pyautogui.click(game_coords.big_close_coords,
                            clicks=2,
                            interval=0.5)
    else:
        log.info("Waiting to check on Guardian Training")
コード例 #7
0
ファイル: Authentication.py プロジェクト: div0ky/fsb_idle
 def get_license_key():
     log.debug('Attempting to get license key from user.')
     database.license_key_needed = True
     root = Tk()
     root.withdraw()
     # database.launch_show_window = False
     lkey = simpledialog.askstring(parent=root, title=f'FIB v{current_version}', prompt='       PLEASE ENTER YOUR LICENSE KEY:       ')
     database.launch_show_window = True
     root.destroy()
     if lkey is not None:
         database.license_key = lkey
         log.info('User entered a license key.')
         return True
     else:
         return False
コード例 #8
0
ファイル: Launcher.py プロジェクト: div0ky/fsb_idle
    def __init__(self):
        log.info(f'{__name__} has been initialized.')
        self.auth_win = None
        self.progress = None
        self.status_text = None
        self.key_entry = None
        self.okay_button = None

        self.startup = Thread(target=self.startup_procedures,
                              daemon=True,
                              name='Authentication GUI').start()
        # self.startup_procedures()
        self.auth = API()
        self.updater = Updater()
        database.updater_finished = True
コード例 #9
0
ファイル: LiteFunctions.py プロジェクト: div0ky/fsb_idle
def guardian_click(clicks=15, speed=1):
    ts = time.time()
    log.info('Resuming guardian duties.')
    if database.guardian == 'Dragon':
        clicks, speed = 15, 1.2
    else:
        clicks, speed = 100, 0.1
    log.debug(f'Will click {clicks} times with a {speed} second interval.')

    for x in range(clicks):
        if database.running:
            pyautogui.click(game_coords.guardian_click_coords)
            log.debug(f"Clicked {x + 1} time/s")
            time.sleep(speed)
    log.debug(
        f"Spent {round(time.time() - ts, 2)} seconds on guardian duties.")
    database.save_stat('total_clicks', database.total_clicks + clicks)
コード例 #10
0
ファイル: LiteFunctions.py プロジェクト: div0ky/fsb_idle
def farm_gold(levels=database.farm_levels):

    button = pyautogui.locateCenterOnScreen(image_path("boss.png"))
    if button is None:
        return
    else:
        log.info(f"It looks like we've failed to beat a boss.")
        count = levels
        log.info("Going back %s levels to farm." % levels)

        while count >= 0:
            if database.running:
                pyautogui.click(game_coords.back_arrow_coords)
                time.sleep(0.5)
                count -= 1
        time.sleep(1.5)
        pyautogui.click(button)
    database.save_stat('total_stages_farmed',
                       database.total_stages_farmed + levels)
    log.info("Lowering upgrade progression to x1.")
    change_upgrade_progression('x1')
コード例 #11
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
コード例 #12
0
ファイル: AdvancedFunctions.py プロジェクト: div0ky/fsb_idle
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
コード例 #13
0
ファイル: AdvancedFunctions.py プロジェクト: div0ky/fsb_idle
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)
コード例 #14
0
    def __init__(self):
        log.info(f'{__name__} has been initialized.')

        self.window = Tk()
        self.window.title(f"FIB v{current_version}")
        self.window.geometry("380x225")
        self.style = Style()
        # if sys.platform == "win32":
        #     self.style.theme_use('winnative')
        self.window.minsize(380, 200)
        self.window.wait_visibility(self.window)
        self.windowWidth = self.window.winfo_reqwidth()
        self.windowHeight = self.window.winfo_reqheight()
        # Gets both half the screen width/height and window width/height
        self.positionRight = int(self.window.winfo_screenwidth() / 2 -
                                 self.windowWidth / 2)
        self.positionDown = int(self.window.winfo_screenheight() / 2 -
                                self.windowHeight / 2)
        self.window.geometry("+{}+{}".format(self.positionRight,
                                             self.positionDown))
        self.window.grid_columnconfigure(0, weight=1)
        self.window.resizable(0, 0)
        self.window.attributes("-topmost", True)

        self.window.protocol("WM_DELETE_WINDOW", self.on_closing)

        self.main_menu = Menu(self.window)

        self.file_menu = Menu(self.main_menu, tearoff=0)
        # self.file_menu.add_command(label="Save")
        self.file_menu.add_command(label="Exit", command=self.menu_exit)

        self.help_menu = Menu(self.main_menu, tearoff=0)
        self.help_menu.add_command(label="About", command=self.menu_about)
        self.help_menu.add_command(label="Change License Key",
                                   command=self.menu_change_license)

        self.main_menu.add_cascade(label="File", menu=self.file_menu)
        self.main_menu.add_cascade(label="Help", menu=self.help_menu)

        self.window.config(menu=self.main_menu)

        self.info_label = Label(self.window,
                                text="STOP BOT: SHIFT + ESC",
                                font=("Helvetica", 16))
        self.info_label.grid(column=0, row=0, padx=15, pady=10, columnspan=2)

        self.btn1 = Button(self.window,
                           text="GENERAL OPTIONS",
                           command=self.options_win,
                           width=50)
        self.btn1.grid(column=0, row=1, padx=15, pady=5, columnspan=2)

        self.btn2 = Button(self.window,
                           text="CONFIGURE PARTY",
                           command=self.party_win,
                           width=50)
        self.btn2.grid(column=0, row=2, padx=15, pady=0, columnspan=2)

        self.gobtn = Button(self.window,
                            text="<---    START    --->",
                            command=self.ready_set_go,
                            width=50)
        self.gobtn.config(foreground="white", background="blue")
        self.gobtn.grid(column=0, row=3, padx=15, pady=20, columnspan=2)

        # self.window.bind('<Control-n>', self.party_win)

        # self.window.after(300, self.status_win)

        self.window.mainloop()
コード例 #15
0
ファイル: LiteFunctions.py プロジェクト: div0ky/fsb_idle
def buy_upgrades():
    log.info('Buying any and all upgrades that we can afford.')
    # TODO: possibly open drawer first time and then start looking for dot
    # if pyautogui.pixelMatchesColor(relCoords(1894), relCoords(619), (244, 0, 0), tolerance=5):  # Upgrades avail bubble
    pyautogui.click(game_coords.upgrade_button)  # Open the upgrade menu
    pyautogui.moveTo(game_coords.guardian_click_coords)

    upgrade_color = (43, 117, 41)
    tolerance = 5
    _slot_1_count = 0
    _slot_2_count = 0
    _slot_3_count = 0
    _slot_4_count = 0
    _slot_5_count = 0
    _slot_6_count = 0
    _slot_7_count = 0

    while True:

        if pyautogui.pixelMatchesColor(
                game_coords.relative_coords(1715),
                game_coords.relative_coords(175),
                upgrade_color,
                tolerance=tolerance) and database.running:  # Party
            pyautogui.click(game_coords.relative_coords(1715, 175))
            _slot_1_count += 1
            pyautogui.moveTo(game_coords.guardian_click_coords)

        elif pyautogui.pixelMatchesColor(
                game_coords.relative_coords(1715),
                game_coords.relative_coords(295),
                upgrade_color,
                tolerance=tolerance) and database.running:  # Guardian
            pyautogui.click(game_coords.relative_coords(1715, 295))
            _slot_2_count += 1
            pyautogui.moveTo(game_coords.guardian_click_coords)

        elif pyautogui.pixelMatchesColor(
                game_coords.relative_coords(1715),
                game_coords.relative_coords(415),
                upgrade_color,
                tolerance=tolerance) and database.running:  # Party 1
            pyautogui.click(game_coords.relative_coords(1715, 415))
            _slot_3_count += 1
            pyautogui.moveTo(game_coords.guardian_click_coords)

        elif pyautogui.pixelMatchesColor(
                game_coords.relative_coords(1715),
                game_coords.relative_coords(540),
                upgrade_color,
                tolerance=tolerance) and database.running:  # Party 2
            pyautogui.click(game_coords.relative_coords(1715, 540))
            _slot_4_count += 1
            pyautogui.moveTo(game_coords.guardian_click_coords)

        elif pyautogui.pixelMatchesColor(
                game_coords.relative_coords(1715),
                game_coords.relative_coords(655),
                upgrade_color,
                tolerance=tolerance) and database.running:  # Party 3
            pyautogui.click(game_coords.relative_coords(1715, 655))
            _slot_5_count += 1
            pyautogui.moveTo(game_coords.guardian_click_coords)

        elif pyautogui.pixelMatchesColor(
                game_coords.relative_coords(1715),
                game_coords.relative_coords(775),
                upgrade_color,
                tolerance=tolerance) and database.running:  # Party 4
            pyautogui.click(game_coords.relative_coords(1715, 775))
            _slot_6_count += 1
            pyautogui.moveTo(game_coords.guardian_click_coords)

        elif pyautogui.pixelMatchesColor(
                game_coords.relative_coords(1715),
                game_coords.relative_coords(895),
                upgrade_color,
                tolerance=tolerance) and database.running:  # Party 5
            pyautogui.click(game_coords.relative_coords(1715, 895))
            _slot_7_count += 1
            pyautogui.moveTo(game_coords.guardian_click_coords)
        else:
            _total_count = _slot_1_count + _slot_2_count + _slot_3_count + _slot_4_count + _slot_5_count + _slot_6_count + _slot_7_count
            log.info(f"There were {_total_count} upgrades available.")
            if _total_count > 0:
                database.save_stat(
                    'total_upgrades_purchased',
                    database.total_upgrades_purchased + _total_count)
            break

    pyautogui.click(game_coords.small_close_coords)
    return
コード例 #16
0
ファイル: LiteFunctions.py プロジェクト: div0ky/fsb_idle
import pyautogui
from bot_internals.GameCoords import game_coords
from bot_internals.DatabaseManager import database
from bot_internals.BotLog import log
from bot_internals.SharedFunctions import image_path, change_upgrade_progression
import time

# Set pyautogui speed so we don't click so fast the game can't respond
pyautogui.PAUSE = 0.1

log.info(f'{__name__} has been initialized.')


# Click the center of the screen to cause damage with your guardian
def guardian_click(clicks=15, speed=1):
    ts = time.time()
    log.info('Resuming guardian duties.')
    if database.guardian == 'Dragon':
        clicks, speed = 15, 1.2
    else:
        clicks, speed = 100, 0.1
    log.debug(f'Will click {clicks} times with a {speed} second interval.')

    for x in range(clicks):
        if database.running:
            pyautogui.click(game_coords.guardian_click_coords)
            log.debug(f"Clicked {x + 1} time/s")
            time.sleep(speed)
    log.debug(
        f"Spent {round(time.time() - ts, 2)} seconds on guardian duties.")
    database.save_stat('total_clicks', database.total_clicks + clicks)
コード例 #17
0
def open_chests():
    if database.chests_timestamp + timedelta(hours=2) <= datetime.now():
        database.chests_timestamp = datetime.now()
        log.info('Opening any available chests.')
        time.sleep(0.5)
        pyautogui.click(game_coords.inventory)
        time.sleep(0.5)
        pyautogui.click(game_coords.chests_tab)
        time.sleep(0.5)
        chests = [
            'inv_common_chest.png', 'inv_uncommon_chest.png',
            'inv_rare_chest.png', 'inv_epic_chest.png'
        ]
        found = []
        for chest in chests:
            img = pyautogui.locateCenterOnScreen(image_path(chest),
                                                 region=(1530, 315, 390, 665),
                                                 confidence=0.9)
            if img is not None:
                found.append(img)
        if found:
            log.info(
                'Looks like we have at least one chest. Opening it and any others.'
            )
            pyautogui.click(found[0])
            time.sleep(0.5)
            while True:
                img = pyautogui.locateCenterOnScreen(image_path(chests[0]),
                                                     region=(1060, 915, 565,
                                                             140))
                if img is not None:
                    pyautogui.click(img)
                    time.sleep(0.5)
                    pyautogui.click(game_coords.big_chest)
                    time.sleep(0.5)
                    pyautogui.click(game_coords.open_chest,
                                    clicks=3,
                                    interval=1)
                    log.info('Opened a common chest.')
                else:
                    log.info('All common chests are opened.')
                    break

            while True:
                img = pyautogui.locateCenterOnScreen(image_path(chests[1]),
                                                     region=(1060, 915, 565,
                                                             140))
                if img is not None:
                    pyautogui.click(img)
                    time.sleep(0.5)
                    pyautogui.click(game_coords.big_chest)
                    time.sleep(0.5)
                    pyautogui.click(game_coords.open_chest,
                                    clicks=5,
                                    interval=1)
                    log.info('Opened an uncommon chest.')
                else:
                    log.info('All uncommon chests are opened.')
                    break

            while True:
                img = pyautogui.locateCenterOnScreen(image_path(chests[2]),
                                                     region=(1060, 915, 565,
                                                             140))
                if img is not None:
                    pyautogui.click(img)
                    time.sleep(0.5)
                    pyautogui.click(game_coords.big_chest)
                    time.sleep(0.5)
                    pyautogui.click(game_coords.open_chest,
                                    clicks=7,
                                    interval=1)
                    log.info('Opened a rare chest.')
                else:
                    log.info('All rare chests are opened.')
                    break

            while True:
                img = pyautogui.locateCenterOnScreen(image_path(chests[3]),
                                                     region=(1060, 915, 565,
                                                             140),
                                                     confidence=0.9)
                if img is not None:
                    pyautogui.click(img)
                    time.sleep(0.5)
                    pyautogui.click(game_coords.big_chest)
                    time.sleep(0.5)
                    pyautogui.click(game_coords.open_chest,
                                    clicks=9,
                                    interval=1)
                    log.info('Opened an epic chest.')
                else:
                    log.info('All epic chests are opened.')
                    break
            log.info("I think we're done with chests for now. Going home.")
            pyautogui.click(game_coords.big_close_coords,
                            clicks=2,
                            interval=0.5)

        time.sleep(0.5)
        pyautogui.click(game_coords.inventory_close)
        time.sleep(0.5)

    else:
        log.info("It isn't time to check the chests again yet.")
コード例 #18
0
ファイル: AdvancedFunctions.py プロジェクト: div0ky/fsb_idle
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')
コード例 #19
0
 def ready_set_go(self):
     self.window.quit()
     self.window.withdraw()
     self.window.destroy()
     database.paused = False
     log.info(f"FIB v{current_version} was started!")
コード例 #20
0
ファイル: Updater.py プロジェクト: div0ky/fsb_idle
    def __init__(self):
        if db.authenticated:
            if db.channel == "Development":
                response = requests.get(
                    "http://div0ky.com/repo/development/latest.txt")
            elif db.channel == "Staging":
                response = requests.get(
                    "http://div0ky.com/repo/staging/latest.txt")
            else:
                response = requests.get(
                    "http://div0ky.com/repo/stable/latest.txt")
            latest = response.text

            print(
                f"Current Version is {current_version}\nLatest Version is {latest}"
            )

            if semver.compare(latest, current_version) > 0:
                root = Tk()
                root.withdraw()
                ask_update = messagebox.askyesno(
                    title=f"FIB v{current_version}",
                    message=
                    f"A new version is availble. You're running v{current_version}. The latest version is v{latest}.\n\nDo you want to download & update?",
                    parent=root)
                root.destroy()

                if ask_update:
                    update = f"http://div0ky.com/repo/Firestone_Bot_v{latest}.exe"
                    with open(
                            os.getenv('LOCALAPPDATA') +
                            f"/Firestone Idle Bot/Firestone_Bot_v{latest}.exe",
                            'wb') as f:
                        response = requests.get(update, stream=True)
                        total_size = response.headers.get('content-length')
                        if total_size is None:
                            f.write(response.content)
                        else:
                            dl = 0
                            total_size = int(total_size)
                            adj_size = round(int(total_size) / 1000, 2)
                            for data in response.iter_content(chunk_size=4096):
                                dl += int(len(data))
                                adj_dl = round(dl / 1000, 2)
                                f.write(data)
                                done = int(100 * dl / total_size)
                                db.launch_progress = done
                                db.launch_text = f"{adj_dl}KB / {adj_size}KB"
                                if not db.launch_running:
                                    break
                                # print("\r[%s%s]" % ('=' * done, ' ' * (50 - done)))
                        if db.launch_running:
                            db.launch_text = "DOWNLOAD COMPLETE"
                        # messagebox.showinfo(title="DOWNLOAD COMPLETE", message="Download Complete. Launching Installer...")
                    if db.launch_running:
                        log.info(f"Updated to v{latest}")
                        os.startfile(
                            os.getenv('LOCALAPPDATA') +
                            f"/Firestone Idle Bot/Firestone_Bot_v{latest}.exe")
                    sys.exit()

                else:
                    db.updater_finished = True