amamic1803 / Autofish-Fishing-Planet

A fishing bot for automatically catching fish in Fishing Planet
MIT License
40 stars 26 forks source link

Time #10

Open invahak opened 11 months ago

invahak commented 11 months ago

Friend, everything works except for finding the next morning button, I tried replacing the picture, didn't help.

Oh yeah, also doesn't release more fish than the cage can hold.

amamic1803 commented 11 months ago

Hi, thanks for bringing this up. I don't know why finding next morning button fails, but the part of the bot that deals with time warp is unfortunately pretty bad/almost non existant so it may have to do something with that. The intended behaviour for when the cage gets filled should be to try to time warp or to stop running bot (if time warp option wasn't enabled). If the bot continued to catch more fish after the cage keepnet/stringer was already full, then it is also a bug. If you do find out the reason it fails, feel free to fix and open pull request. πŸ˜„

invahak commented 11 months ago

After filling sodka, the bot includes a window "rewind time" and then on the button "next morning" does not click, if I forcefully click myself, the bot stops catching fish, apparently you made it so that after rewinding time was sent "true" and it was not sent, and the bot endlessly waiting).

I wrote my code that finds all these buttons, it rewinds the time, but your bot does not want to fish when the next day comes, I can not find the reason )

My code:

import pyautogui
import cv2
import time
import keyboard
import threading
from plyer import notification

# Установи ΠΏΠΎΡ€ΠΎΠ³ для опрСдСлСния совпадСния
threshold = 0.8

# Π—Π°Π³Ρ€ΡƒΠ·ΠΈ изобраТСния ΠΊΠ½ΠΎΠΏΠΎΠΊ
button_images = [
    cv2.imread("zabrat.png"),
    cv2.imread("zakrit_ispitanie.png"),
    cv2.imread("lvlup1.png"),
    cv2.imread("lvlup2.png"),
    cv2.imread("buy.png"),
    cv2.imread("time.png"),
    cv2.imread("nezabrat.png"),
    cv2.imread("time2.png")
]

# Π£ΠΊΠ°ΠΆΠΈ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Ρ‹ областСй поиска для ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΊΠ½ΠΎΠΏΠΊΠΈ
search_areas = [
    ((957, 907), (1236, 1000)),
    ((357, 730), (696, 837)),
    ((791, 864), (1127, 974)),
    ((510, 863), (844, 966)),
    ((690, 855), (955, 925)),
    ((788, 850), (1130, 930)),
    ((957, 907), (1236, 1000)),
    ((666, 795), (1080, 900))
]

while True:
    for i, button_image in enumerate(button_images):
        search_area_top_left, search_area_bottom_right = search_areas[i]

        # Π‘Π½ΠΈΠΌΠΈ ΡΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚ ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ области экрана
        screenshot = pyautogui.screenshot(region=(search_area_top_left[0], search_area_top_left[1], 
                                                  search_area_bottom_right[0] - search_area_top_left[0],
                                                  search_area_bottom_right[1] - search_area_top_left[1]))
        screenshot.save(f"screenshot{i}.png")

        # Π—Π°Π³Ρ€ΡƒΠ·ΠΈ ΡΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚
        screenshot = cv2.imread(f"screenshot{i}.png")

        # Π˜Ρ‰ΠΈ ΠΊΠ½ΠΎΠΏΠΊΡƒ Π½Π° ΡΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚Π΅
        result = cv2.matchTemplate(screenshot, button_image, cv2.TM_CCOEFF_NORMED)
        _, max_val, _, max_loc = cv2.minMaxLoc(result)

        if max_val >= threshold:
            button_x, button_y = max_loc
            button_center_x = button_x + int(button_image.shape[1] / 2)
            button_center_y = button_y + int(button_image.shape[0] / 2)
            print(f"Кнопка {i+1} найдСна!")

            if i == 4:
                click_x = 1630
                click_y = 82
            elif i == 5:
                click_x = button_center_x + search_area_top_left[0]
                click_y = button_center_y + search_area_top_left[1]
                pyautogui.click(click_x, click_y)
                time.sleep(3)  # ΠŸΠΎΠ΄ΠΎΠΆΠ΄Π°Ρ‚ΡŒ 3 сСкунды

                click_x = 800
                click_y = 660
            elif i == 6:
                click_x = button_center_x + search_area_top_left[0]
                click_y = button_center_y + search_area_top_left[1]
            else:
                click_x = button_center_x + search_area_top_left[0]
                click_y = button_center_y + search_area_top_left[1]

            # Π’Ρ‹ΠΏΠΎΠ»Π½ΠΈ ΠΊΠ»ΠΈΠΊ
            pyautogui.click(click_x, click_y)
        else:
            print(f"Кнопка {i+1} нС найдСна.")

    time.sleep(5)  # ПодоТди 5 сСкунд ΠΏΠ΅Ρ€Π΅Π΄ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰Π΅ΠΉ ΠΈΡ‚Π΅Ρ€Π°Ρ†ΠΈΠ΅ΠΉ
Kroonos77 commented 9 months ago

After filling sodka, the bot includes a window "rewind time" and then on the button "next morning" does not click, if I forcefully click myself, the bot stops catching fish, apparently you made it so that after rewinding time was sent "true" and it was not sent, and the bot endlessly waiting).

I wrote my code that finds all these buttons, it rewinds the time, but your bot does not want to fish when the next day comes, I can not find the reason )

My code:

import pyautogui
import cv2
import time
import keyboard
import threading
from plyer import notification

# Установи ΠΏΠΎΡ€ΠΎΠ³ для опрСдСлСния совпадСния
threshold = 0.8

# Π—Π°Π³Ρ€ΡƒΠ·ΠΈ изобраТСния ΠΊΠ½ΠΎΠΏΠΎΠΊ
button_images = [
    cv2.imread("zabrat.png"),
    cv2.imread("zakrit_ispitanie.png"),
    cv2.imread("lvlup1.png"),
    cv2.imread("lvlup2.png"),
    cv2.imread("buy.png"),
    cv2.imread("time.png"),
    cv2.imread("nezabrat.png"),
    cv2.imread("time2.png")
]

# Π£ΠΊΠ°ΠΆΠΈ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Ρ‹ областСй поиска для ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΊΠ½ΠΎΠΏΠΊΠΈ
search_areas = [
    ((957, 907), (1236, 1000)),
    ((357, 730), (696, 837)),
    ((791, 864), (1127, 974)),
    ((510, 863), (844, 966)),
    ((690, 855), (955, 925)),
    ((788, 850), (1130, 930)),
    ((957, 907), (1236, 1000)),
    ((666, 795), (1080, 900))
]

while True:
    for i, button_image in enumerate(button_images):
        search_area_top_left, search_area_bottom_right = search_areas[i]

        # Π‘Π½ΠΈΠΌΠΈ ΡΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚ ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ области экрана
        screenshot = pyautogui.screenshot(region=(search_area_top_left[0], search_area_top_left[1], 
                                                  search_area_bottom_right[0] - search_area_top_left[0],
                                                  search_area_bottom_right[1] - search_area_top_left[1]))
        screenshot.save(f"screenshot{i}.png")

        # Π—Π°Π³Ρ€ΡƒΠ·ΠΈ ΡΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚
        screenshot = cv2.imread(f"screenshot{i}.png")

        # Π˜Ρ‰ΠΈ ΠΊΠ½ΠΎΠΏΠΊΡƒ Π½Π° ΡΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚Π΅
        result = cv2.matchTemplate(screenshot, button_image, cv2.TM_CCOEFF_NORMED)
        _, max_val, _, max_loc = cv2.minMaxLoc(result)

        if max_val >= threshold:
            button_x, button_y = max_loc
            button_center_x = button_x + int(button_image.shape[1] / 2)
            button_center_y = button_y + int(button_image.shape[0] / 2)
            print(f"Кнопка {i+1} найдСна!")

            if i == 4:
                click_x = 1630
                click_y = 82
            elif i == 5:
                click_x = button_center_x + search_area_top_left[0]
                click_y = button_center_y + search_area_top_left[1]
                pyautogui.click(click_x, click_y)
                time.sleep(3)  # ΠŸΠΎΠ΄ΠΎΠΆΠ΄Π°Ρ‚ΡŒ 3 сСкунды

                click_x = 800
                click_y = 660
            elif i == 6:
                click_x = button_center_x + search_area_top_left[0]
                click_y = button_center_y + search_area_top_left[1]
            else:
                click_x = button_center_x + search_area_top_left[0]
                click_y = button_center_y + search_area_top_left[1]

            # Π’Ρ‹ΠΏΠΎΠ»Π½ΠΈ ΠΊΠ»ΠΈΠΊ
            pyautogui.click(click_x, click_y)
        else:
            print(f"Кнопка {i+1} нС найдСна.")

    time.sleep(5)  # ПодоТди 5 сСкунд ΠΏΠ΅Ρ€Π΅Π΄ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰Π΅ΠΉ ΠΈΡ‚Π΅Ρ€Π°Ρ†ΠΈΠ΅ΠΉ

this code still work for next morning click button?