amamic1803/Autofish-Fishing-Planet

Time

invahak opened this issue · 3 comments

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.

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. 😄

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 секунд перед следующей итерацией

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?