|
@@ -1,4 +1,5 @@
|
|
|
import cv2
|
|
import cv2
|
|
|
|
|
+import os
|
|
|
import time
|
|
import time
|
|
|
import numpy as np
|
|
import numpy as np
|
|
|
from helper import (
|
|
from helper import (
|
|
@@ -9,6 +10,8 @@ from helper import (
|
|
|
get_current_screen,
|
|
get_current_screen,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+fire_vs_earth = os.getenv("FIRE_VS_EARTH", "earth").lower()
|
|
|
|
|
+
|
|
|
# templates
|
|
# templates
|
|
|
templates = {
|
|
templates = {
|
|
|
"to_battle": cv2.imread("templates/dungeon/to_battle.png"),
|
|
"to_battle": cv2.imread("templates/dungeon/to_battle.png"),
|
|
@@ -22,6 +25,7 @@ templates = {
|
|
|
tpl_mixed = cv2.imread("templates/dungeon/mixed.png")
|
|
tpl_mixed = cv2.imread("templates/dungeon/mixed.png")
|
|
|
tpl_water = cv2.imread("templates/dungeon/water.png")
|
|
tpl_water = cv2.imread("templates/dungeon/water.png")
|
|
|
tpl_earth = cv2.imread("templates/dungeon/earth.png")
|
|
tpl_earth = cv2.imread("templates/dungeon/earth.png")
|
|
|
|
|
+tpl_fire = cv2.imread("templates/dungeon/fire.png")
|
|
|
tpl_angus = cv2.imread("templates/dungeon/angus.png")
|
|
tpl_angus = cv2.imread("templates/dungeon/angus.png")
|
|
|
tpl_moloch = cv2.imread("templates/dungeon/moloch.png")
|
|
tpl_moloch = cv2.imread("templates/dungeon/moloch.png")
|
|
|
tpl_angus2 = cv2.imread("templates/dungeon/angus2.png")
|
|
tpl_angus2 = cv2.imread("templates/dungeon/angus2.png")
|
|
@@ -32,13 +36,13 @@ tpl_dead = cv2.imread("templates/dungeon/dead.png")
|
|
|
def low_health(element, name):
|
|
def low_health(element, name):
|
|
|
left = element[0] - 113
|
|
left = element[0] - 113
|
|
|
right = element[0] + 108
|
|
right = element[0] + 108
|
|
|
- top = element[1] + 158
|
|
|
|
|
|
|
+ top = element[1] + 138
|
|
|
bottom = top + 11
|
|
bottom = top + 11
|
|
|
|
|
|
|
|
screen = read_screen()
|
|
screen = read_screen()
|
|
|
|
|
|
|
|
health_bar = screen[top:bottom, left:right]
|
|
health_bar = screen[top:bottom, left:right]
|
|
|
- cv2.imwrite("test/health_bar.png", health_bar)
|
|
|
|
|
|
|
+ # cv2.imwrite("test/health_bar.png", health_bar)
|
|
|
|
|
|
|
|
health_bar_hsv = cv2.cvtColor(health_bar, cv2.COLOR_BGR2HSV)
|
|
health_bar_hsv = cv2.cvtColor(health_bar, cv2.COLOR_BGR2HSV)
|
|
|
green_lower = np.array([40, 40, 40]) # Lower end of green in HSV
|
|
green_lower = np.array([40, 40, 40]) # Lower end of green in HSV
|
|
@@ -90,13 +94,20 @@ while True:
|
|
|
tap(name, *locations[0])
|
|
tap(name, *locations[0])
|
|
|
continue
|
|
continue
|
|
|
if name in ["auto_battle"]:
|
|
if name in ["auto_battle"]:
|
|
|
- dead = first_template(tpl_dead)
|
|
|
|
|
|
|
+ dead = os.getenv(
|
|
|
|
|
+ "STOP_AT_FIRST_DEATH", "False"
|
|
|
|
|
+ ).lower() == "true" and first_template(tpl_dead)
|
|
|
if dead:
|
|
if dead:
|
|
|
print("++++++++ at least one titan is dead. stopping")
|
|
print("++++++++ at least one titan is dead. stopping")
|
|
|
break
|
|
break
|
|
|
if is_mixed:
|
|
if is_mixed:
|
|
|
moloch = first_template(tpl_moloch)
|
|
moloch = first_template(tpl_moloch)
|
|
|
- if moloch and moloch[1] < 1000 and low_health(moloch, "moloch"):
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ moloch
|
|
|
|
|
+ and moloch[1] > 450
|
|
|
|
|
+ and moloch[1] < 1350
|
|
|
|
|
+ and low_health(moloch, "moloch")
|
|
|
|
|
+ ):
|
|
|
angus = first_template(tpl_angus2)
|
|
angus = first_template(tpl_angus2)
|
|
|
if angus:
|
|
if angus:
|
|
|
tap("remove angus", angus)
|
|
tap("remove angus", angus)
|
|
@@ -108,7 +119,12 @@ while True:
|
|
|
break
|
|
break
|
|
|
else:
|
|
else:
|
|
|
angus = first_template(tpl_angus)
|
|
angus = first_template(tpl_angus)
|
|
|
- if angus and angus[1] < 1000 and low_health(angus, "angus"):
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ angus
|
|
|
|
|
+ and moloch[1] > 450
|
|
|
|
|
+ and angus[1] < 1350
|
|
|
|
|
+ and low_health(angus, "angus")
|
|
|
|
|
+ ):
|
|
|
moloch = first_template(tpl_moloch2)
|
|
moloch = first_template(tpl_moloch2)
|
|
|
if moloch:
|
|
if moloch:
|
|
|
tap("remove moloch", moloch)
|
|
tap("remove moloch", moloch)
|
|
@@ -135,7 +151,10 @@ while True:
|
|
|
is_mixed = False
|
|
is_mixed = False
|
|
|
element = first_template(tpl_water)
|
|
element = first_template(tpl_water)
|
|
|
if element is None:
|
|
if element is None:
|
|
|
- element = first_template(tpl_earth)
|
|
|
|
|
|
|
+ if fire_vs_earth == "earth":
|
|
|
|
|
+ element = first_template(tpl_earth)
|
|
|
|
|
+ else:
|
|
|
|
|
+ element = first_template(tpl_fire)
|
|
|
|
|
|
|
|
tap(name, element[0], locations[0][1])
|
|
tap(name, element[0], locations[0][1])
|
|
|
continue
|
|
continue
|