|
@@ -16,6 +16,7 @@ close_sub_fights = cv2.imread('templates/close_sub_fights.jpg')
|
|
|
close_fight = cv2.imread('templates/close_fight.jpg')
|
|
close_fight = cv2.imread('templates/close_fight.jpg')
|
|
|
fight_button = cv2.imread('templates/i.jpg')
|
|
fight_button = cv2.imread('templates/i.jpg')
|
|
|
end_of_log = cv2.imread('templates/end_of_log.jpg')
|
|
end_of_log = cv2.imread('templates/end_of_log.jpg')
|
|
|
|
|
+end_of_log2 = cv2.imread('templates/end_of_log2.jpg')
|
|
|
|
|
|
|
|
# cursor positions
|
|
# cursor positions
|
|
|
fight_scroll_top = "2494 626"
|
|
fight_scroll_top = "2494 626"
|
|
@@ -24,6 +25,7 @@ titan_fight = "1400 860"
|
|
|
damage_taken = "450 850"
|
|
damage_taken = "450 850"
|
|
|
close_details = "2175 450"
|
|
close_details = "2175 450"
|
|
|
close_titan_fight = "2650 570"
|
|
close_titan_fight = "2650 570"
|
|
|
|
|
+defense_log = "350 870"
|
|
|
|
|
|
|
|
def non_max_suppression(boxes, overlapThresh):
|
|
def non_max_suppression(boxes, overlapThresh):
|
|
|
if len(boxes) == 0:
|
|
if len(boxes) == 0:
|
|
@@ -128,9 +130,13 @@ def tap_button(template):
|
|
|
return
|
|
return
|
|
|
tap(f"{button[0][0]} {button[0][1]}")
|
|
tap(f"{button[0][0]} {button[0][1]}")
|
|
|
|
|
|
|
|
-def is_end_of_log(template):
|
|
|
|
|
- templates = find_templates(template)
|
|
|
|
|
|
|
+def is_end_of_log():
|
|
|
|
|
+ templates = find_templates(end_of_log)
|
|
|
|
|
+ if (len(templates) == 0):
|
|
|
|
|
+ templates = find_templates(end_of_log2)
|
|
|
|
|
+
|
|
|
result = len(templates) > 0
|
|
result = len(templates) > 0
|
|
|
|
|
+
|
|
|
if result:
|
|
if result:
|
|
|
print("reached end of guild war log!")
|
|
print("reached end of guild war log!")
|
|
|
|
|
|
|
@@ -166,14 +172,15 @@ def find_templates(template_image):
|
|
|
coordinates = []
|
|
coordinates = []
|
|
|
|
|
|
|
|
for (startX, startY, endX, endY) in rectangles:
|
|
for (startX, startY, endX, endY) in rectangles:
|
|
|
- # Calculate the center coordinates
|
|
|
|
|
- centerX = round(startX + (endX - startX) / 2)
|
|
|
|
|
- centerY = round(startY + (endY - startY) / 2)
|
|
|
|
|
|
|
+ # Calculate the center coordinates
|
|
|
|
|
+ centerX = round(startX + (endX - startX) / 2)
|
|
|
|
|
+ centerY = round(startY + (endY - startY) / 2)
|
|
|
|
|
|
|
|
- # Append the coordinate pair to the list
|
|
|
|
|
- coordinates.append((centerX, centerY))
|
|
|
|
|
|
|
+ # Append the coordinate pair to the list
|
|
|
|
|
+ coordinates.append((centerX, centerY))
|
|
|
|
|
|
|
|
- return coordinates
|
|
|
|
|
|
|
+ # Sort the coordinates by y value in ascending order
|
|
|
|
|
+ return sorted(coordinates, key=lambda x: x[1])
|
|
|
|
|
|
|
|
def find_max_y_pair(coordinates):
|
|
def find_max_y_pair(coordinates):
|
|
|
# find the coordinate pair with the maximum y value
|
|
# find the coordinate pair with the maximum y value
|
|
@@ -210,7 +217,7 @@ def process_war_log():
|
|
|
swipe(find_max_y_pair(buttons), fight_scroll_top)
|
|
swipe(find_max_y_pair(buttons), fight_scroll_top)
|
|
|
|
|
|
|
|
# start
|
|
# start
|
|
|
-while not is_end_of_log(end_of_log):
|
|
|
|
|
|
|
+while not is_end_of_log():
|
|
|
process_war_log();
|
|
process_war_log();
|
|
|
|
|
|
|
|
# possible duplicates here, but necessary to be sure to get the last fights
|
|
# possible duplicates here, but necessary to be sure to get the last fights
|