Beispiel #1
0
 def monitor(self):
     _, SH = get_screen_size()
     lo = (30, 30, 30)
     hi = (255, 255, 255)
     self.change_event.set()
     while self.is_active:
         sc = screenshot(0, SH - 200, 200, 200)
         img = features_util.convert_to_cv2(sc)
         rgb = features_util.split_channels(img)
         if self.lights_on:
             if not features_util.color_in_range(self.pixel, rgb, lo, hi):
                 if self.bomb_exploded(rgb):  # We died :(
                     self.is_active = False
                     self.exit_after_explosion()
                 else:
                     log("Lights in the room are turned off. Pausing execution temporarily..."
                         )
                     self.lights_on = False
                     self.change_event.clear()
                     sleep(1)
         else:
             if features_util.color_in_range(self.pixel, rgb, lo, hi):
                 log("Lights in the room are turned back on. Resuming...")
                 self.change_event.set()
                 self.lights_on = True
                 sleep(1)
         sleep(0.25)
Beispiel #2
0
def get_module_characters():
    SW, SH = win_util.get_screen_size()
    sc = screenshot(int(SW * 0.524), int(SH * 0.547), 36, 25)
    img = cv2.cvtColor(np.array(sc), cv2.COLOR_RGB2BGR)
    thresh = get_threshold(img)
    masks = get_masked_images(thresh)
    if len(masks) == 1 and masks[0].shape[1] > 20:
        mask1 = masks[0][:, :masks[0].shape[1]//2]
        mask2 = masks[0][:, masks[0].shape[1]//2:]
        masks = [mask1, mask2]
    return masks
Beispiel #3
0
def inspect_bomb(num_modules=None):
    sw, sh = win_util.get_screen_size()
    mid_x = sw // 2
    mid_y = sh // 2
    win_util.click(mid_x, mid_y + (mid_y // 8))
    sleep(0.5)
    # Inspect front of bomb.
    front_img = screenshot(460, 220, 1000, 640)
    sleep(0.2)
    # Rotate bomb.
    win_util.mouse_down(mid_x, mid_y, btn="right")
    sleep(0.2)
    # Inspect right side.
    right_img = inspect_side(sw - int(sw / 2.74), mid_y + int(mid_y / 8), 755,
                             60, 480, 900)
    # Inspect left side.
    left_img = inspect_side(int(sw / 2.76), mid_y + int(mid_y / 8), 755, 60,
                            480, 900)
    # Inspect top side.
    top_img = inspect_side(int(sw / 2.75), sh, 720, 0, 480, sh)
    # Inspect bottom side.
    bottom_img = inspect_side(int(sw / 2.75), 0, 720, 0, 480, sh)
    # Inspect back of bomb.
    win_util.mouse_up(mid_x, mid_y, btn="right")
    sleep(0.5)
    return_tupl = (front_img, left_img, right_img, top_img, bottom_img)
    if num_modules is None or num_modules > 5:
        flip_bomb(sw, sh)
        back_img = screenshot(460, 220, 1000, 640)
        sleep(0.4)
        win_util.mouse_up(mid_x, mid_y, btn="right")
        return_tupl = (back_img, ) + return_tupl
    else:
        win_util.click(200, 200, btn="right")
        sleep(0.4)
        win_util.click(mid_x, mid_y + (mid_y // 8))
        sleep(0.5)
    return return_tupl
Beispiel #4
0
def get_duration_characters():
    SW, SH = win_util.get_screen_size()
    sc = screenshot(int(SW * 0.47), int(SH * 0.54), 80, 38)
    img = cv2.cvtColor(np.array(sc), cv2.COLOR_RGB2BGR)
    thresh = get_threshold(img)
    return get_masked_images(thresh)
Beispiel #5
0
def screenshot_module():
    SW, SH = win_util.get_screen_size()
    x = int(SW * 0.43)
    y = int(SH * 0.36)
    return screenshot(x, y, 300, 300), x, y
Beispiel #6
0
def inspect_side(mx, my, sx, sy, sw, sh):
    win_util.mouse_move(mx, my)
    sleep(0.5)
    SC = screenshot(sx, sy, sw, sh)
    sleep(0.2)
    return SC