refactoring

bug fix equip multi
This commit is contained in:
2022-10-22 12:05:45 +02:00
parent 4bfa9aa408
commit f1bde80746
4 changed files with 71 additions and 65 deletions

View File

@@ -78,10 +78,12 @@ class GameBase:
def init_breaks(self):
breaks = []
if int(self.breaks) == 0:
return breaks
#breaks.append(7)
for i in range(1, int(self.breaks) + 1, 1):
avr_in_sec = int(self.stop_time) * 60 * 60 / int(self.breaks)
breaks.append(random.randint(i * avr_in_sec * 0.60, i * avr_in_sec))
breaks.append(random.randint(int(i * avr_in_sec * 0.60), int(i * avr_in_sec)))
return breaks
def check_breaks(self, start_time, breaks):
@@ -178,21 +180,24 @@ class GameBase:
continue
return False
def is_direction_in_bounce_and_same_color(self, state, loc, color):
@staticmethod
def is_direction_in_bounce_and_same_color(state, loc, color):
x, y = loc
if x <= 7 and x >= 0 and y <= 13 and y >= 0:
if state[x, y] == color:
return 1
return 0
def local_pos_check(self, state, e, i, e_check, i_check, needle):
@staticmethod
def local_pos_check(state, e, i, e_check, i_check, needle):
if e + e_check >= 0 and e + e_check <= 7 and i + i_check >= 0 and i + i_check <= 13:
if state[e + e_check, i + i_check] == needle:
return True
else:
return False
def local_pos_checks(self, state, e, i, e_check, i_check, needles):
@staticmethod
def local_pos_checks(state, e, i, e_check, i_check, needles):
if e + e_check >= 0 and e + e_check <= 7 and i + i_check >= 0 and i + i_check <= 13:
for needle in needles:
if state[e + e_check, i + i_check] == needle:
@@ -201,7 +206,8 @@ class GameBase:
continue
return False
def get_click_point(self, rectangle):
@staticmethod
def get_click_point(rectangle):
# Loop over all the rectangles
x, y, w, h = rectangle
# Determine the center position
@@ -237,7 +243,8 @@ class GameBase:
for pointi in pointis:
self.dig_point(pointi[0], pointi[1], 150)
def dig_point(self, point1, point2, dig_time):
@staticmethod
def dig_point(point1, point2, dig_time):
pydirectinput.moveTo(point1, point2)
cv.waitKey(dig_time)
pydirectinput.mouseDown()
@@ -245,7 +252,8 @@ class GameBase:
cv.waitKey(w)
pydirectinput.mouseUp()
def move_to(self, x, y):
@staticmethod
def move_to(x, y):
point_src = (1113, 598)
pydirectinput.moveTo(point_src[0], point_src[1])
pydirectinput.mouseDown()