Ejemplo n.º 1
0
    def go_to_dungeon(self, party):
        if party:
            d = Detector(config.OkButton.path, Window()).detect()
            x, y, w, h = d
            x, y = Window().relative((x, y))
            Rect((x, y, w, h)).click().make_click()
            Click(x, y).make_click()

        Navigator.touch_npc(config.DungeonNpc)
        Wait(1).delay()
        HandleNpc().select_menu(config.CircusDungeonMenu)
        Wait(1).delay()
        x, y, w, h = config.StarIcon.roi
        x, y = Window().relative((x, y))
        Wait(1).delay()
        Detector(config.StarIcon.menu, Window()).detect()
        Rect((x, y, w, h)).click().make_click()
        npc = get_npc(config.CircusNpc)

        Navigator.click_at_npc(npc, config.CircusNpc)
        Wait(1).delay()

        npc_menu = HandleNpc().select_menu(config.CircusNpcMenu,
                                           quality='threshold')
        if not npc_menu:
            return None

        Wait(1).delay()
        npc_menu = HandleNpc().select_menu(config.FirstCircus)
        return npc_menu
Ejemplo n.º 2
0
    def select_menu(self, config, quality='minmax'):
        Wait(DELAY).delay()
        e = Extruder(screenshot(Window().rect))
        template = cv2.imread(config.path)
        menu = e.match_by_template(template, roi=config.roi, method=quality)
        if not menu:
            return None

        point = Rect(menu).center()
        x, y = Window().relative(point)
        Click(x, y).make_click()
        return x, y
Ejemplo n.º 3
0
def draw_corners(times=10):
    window = Window()
    rx, ry, w, h = StartPointConfig.roi
    for i in range(times):
        # image = cv2.imread('assets/data/after_turn_around/' + str(i) + '.png')
        image = np.array(screenshot(window.rect))
        e = Extruder(image)
        roi = e.threshold(StartPointConfig)
        show_image(roi)
        roi = e.clear(roi)
        corners = e.corners(roi)

        # if corners is not None:
        #     #  search start point
        #     plain_corners = [c.ravel() for c in corners]
        #     plain_corners.sort(key = lambda x: x[0], reverse=True)
        #     right = plain_corners[0]
        #     plain_corners.sort(key = lambda x: x[1], reverse=True)
        #     bottom = plain_corners[0]

        #     print(right, bottom)
        #     # for c in corners:
        #     #     x,y = c.ravel()
        #     #     print(x,y)
        #     #     image = cv2.circle(image, (rx+x,ry+y), 3, 255, -1)
        #     cv2.circle(image, (window.x + rx + right[0], window.y + ry + right[1]), 3, 150, -1)
        from shapes.rect import Rect
        cx, cy = Rect(StartPointConfig.roi).center()
        Click(window.x + cx, window.y + cy).make_click()
Ejemplo n.º 4
0
 def __init__(self):
     self.config = Config()
     self.config.enable()
     self.roundFrequency = 30
     self.window = Window()
     self.roundStart = self.window.center()
     self.rountEnd = self.roundStart[0] + 100, self.roundStart[1]
Ejemplo n.º 5
0
def move_to_npc(times=10, imagepath='assets/data/npc_extruded_by_char_color/'):
    template = cv2.imread(TEMPLATE)
    window = Window()

    for i in range(times):
        image = u.screenshot(region=window.rect)
        extruded = Extruder(image)
        title_roi = extruded.match_by_template(
            template, image=extruded.filtredImgByColor(CharTitleConfig))
        print(title_roi)
        Navigator.move_to_npc(title_roi)
Ejemplo n.º 6
0
 def _go_to_selector(self):
     mode = self._setup_buff_mode()
     if mode:
         wx, wy = Window().center()
         Wait(0.5).delay()
         Click(wx, wy).make_click()
         dx, dy = self.config['markers']['confirm_logout_point']
         dx, dy = wx + int(dx), wy + int(dy)
         Wait(1).delay()
         Click(dx, dy).make_click()
     return Recognizer(self.selector, None).recognize()
Ejemplo n.º 7
0
def menu_region_recognize():
    window = Window()
    center = window.center()

    @timerfunc
    def recognize():
        region = (int(center[0]), int(center[1]), int(window.width / 2),
                  int(window.height / 2))
        Recognizer(__asset_path(buff_config, 'menu'), region).recognize()

    recognize()
Ejemplo n.º 8
0
    def __init__(self, actions, timings):
        self.action_params = actions
        self.frequences = timings
        self.config = Config()
        self.config.enable()
        self.roundFrequency = 10

        self.generate_actions()
        self.init_skills_state()
        self.init_actions_time()
        print(self.actions, self.action_params, timings)

        self.window = Window()
        self.roundStart = self.window.center()
        self.rountEnd = self.roundStart[0] + 100, self.roundStart[1]
Ejemplo n.º 9
0
def get_tempalate_roi(config, image=None):
    rect = Window().rect
    if not image:
        image = screenshot(rect)

    extruder = Extruder(image)

    # roi = extruder.get_template_rect(config)
    # import cv2
    # from utils.cv2_utils import show_image
    # import numpy as np
    # rected = np.array(image)
    # rected = cv2.cvtColor(rected, cv2.COLOR_RGB2BGR)
    # rected = cv2.rectangle(rected, roi[:2], (roi[0] + roi[2], roi[1] + roi[3]), 255,2)
    # show_image(rected)

    return extruder.get_template_rect(config)
Ejemplo n.º 10
0
def fetch_window(times, delay=2, dir='assets/data/screens/'):
    window = Window()
    id = 0
    while id < times:
        time.sleep(delay)

        @timerfunc
        def screen():
            return screenshot(window.rect)

        screen()

        @timerfunc
        def save():
            img = np.array(screen())
            cv2.imwrite(dir + str(id) + '.png',
                        cv2.cvtColor(img, cv2.COLOR_BGR2RGB))

        save()
        id = id + 1
Ejemplo n.º 11
0
def camera_height(npc):
    npcC = _center(npc)
    return Window().relative_center()[1] - 10 - npcC[1]
Ejemplo n.º 12
0
def run(times=10):
    # make_extruder_env()
    window = Window()
    config = Config()
    config.initialize_configs('navigator.config.yml')
    CircusHandler().go_to_dungeon()
Ejemplo n.º 13
0
 def move_to_npc(npc_roi, npc=None):
     npc_x, npc_y = circus_npc_point(npc_roi)
     wx, wy = Window().position()
     Click(wx + npc_x + npc.nav_x_shift,
           wy + npc_y + npc.nav_y_shift,
           process='dclick').make_click()
Ejemplo n.º 14
0
 def turn_around():
     x, y = Window().center()
     Move().fromTo((x, y), (x + TURN_AROUND_DISTANCE, y))
Ejemplo n.º 15
0
 def click_at_npc(npc_roi, npc):
     npc_x, npc_y = circus_npc_point(npc_roi)
     wx, wy = Window().position()
     Click(wx + npc_x + npc.click_x_shift,
           wy + npc_y + npc.click_y_shift,
           process='dclick').make_click()
Ejemplo n.º 16
0
 def __init__(self, xChecker, yChecker):
     self.move = Move()
     self.xChecker = xChecker
     self.yChecker = yChecker
     self.window = Window().center()
Ejemplo n.º 17
0
 def test_init(self):
     result = Window()
     self.assertIsInstance(result, Window)
Ejemplo n.º 18
0
def camera_angle_width(npc):
    npcC = _center(npc)
    screenC = Window().relative_center()
    return npcC[0] - screenC[0] + 15 # calibrate coef
Ejemplo n.º 19
0
import logging

from processes.click import Click
from shapes.window import Window
from utils.cv2_utils import screenshot
from jobs.helpers.extruder import Extruder
from utils.config import Config
from processes.wait import Wait
from processes.move import Move
from shapes.rect import Rect

Y_OFFSET_FROM_START_POSITION = 70
TURN_AROUND_DISTANCE = 500

window = Window()
config = Config()
log = logging.getLogger('navigator')


class Navigator:
    @staticmethod
    def move_to_npc(npc_roi, npc=None):
        npc_x, npc_y = circus_npc_point(npc_roi)
        wx, wy = Window().position()
        Click(wx + npc_x + npc.nav_x_shift,
              wy + npc_y + npc.nav_y_shift,
              process='dclick').make_click()

    @staticmethod
    def click_at_npc(npc_roi, npc):
        npc_x, npc_y = circus_npc_point(npc_roi)
Ejemplo n.º 20
0
 def __init__(self):
     self.window = Window()
Ejemplo n.º 21
0
 def test_center(self):
     result = Window().center()
     self.assertEqual(result, (940, 765))
Ejemplo n.º 22
0
 def test_position(self):
     result = Window().position()
     self.assertEqual(result, (100, 240))
Ejemplo n.º 23
0
 def test_relative(self):
     result = Window().relative((100, 100))
     self.assertEqual(result, (200, 340))
Ejemplo n.º 24
0
def init_window():
    return Window()