added fruit game support

This commit is contained in:
2022-10-31 16:19:56 +01:00
parent 25f9cb80e0
commit 9931b9804e

View File

@@ -70,22 +70,20 @@ class Fruit(GameBase):
# get an updated image of the game
screenshot = self.capture_window.get_screenshot()
# screenshot = cv.imread("field_farm.jpg")
screenshot = screenshot[180:1030, 540:1870]
# gray = cv.cvtColor(screenshot, cv.COLOR_BGR2GRAY)
# thresh = cv.threshold(gray, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1]
if self.check_for_button_and_execute(screenshot, self.ok_button, 540, 180):
if self.check_for_button_and_execute(screenshot, self.ok_button):
cv.waitKey(500)
screenshot = self.capture_window.get_screenshot()
screenshot = screenshot[180:1030, 540:1870]
if self.check_for_button_and_execute(screenshot, self.reset_board, 540, 180):
if self.check_for_button_and_execute(screenshot, self.reset_board):
cv.waitKey(500)
screenshot = self.capture_window.get_screenshot()
screenshot = screenshot[180:1030, 540:1870]
if self.check_for_button_and_execute(screenshot, self.reset_confirm, 540, 180):
if self.check_for_button_and_execute(screenshot, self.reset_confirm):
cv.waitKey(500)
screenshot = self.capture_window.get_screenshot()
screenshot = screenshot[180:1030, 540:1870]
screenshot = screenshot[180:1030, 540:1870]
# cv.imshow("screenshot", screenshot)
# cv.waitKey(150)
# continue
@@ -138,13 +136,15 @@ class Fruit(GameBase):
def check_pairs(self, state, e, i, color):
try:
#
offset_left = 540
offset_down = 180
if state[e, i] == color and state[e + 1, i] == color:
click_pt = self.get_click_point(self.data_coordinates[e, i])
self.dig_point(click_pt[0], click_pt[1], 100)
self.dig_point(click_pt[0] + offset_left, click_pt[1] + offset_down, 100)
return True
elif state[e, i] == color and state[e, i + 1] == color:
click_pt = self.get_click_point(self.data_coordinates[e, i])
self.dig_point(click_pt[0], click_pt[1], 100)
self.dig_point(click_pt[0] + offset_left, click_pt[1] + offset_down, 100)
return True
return False
except: