# Path: bot/providers/duellinks.py
# class Event(object):
# class DuelLinksInfo(object):
# class EventExecutor(object):
# class DuelLinks(object):
# class DuelError(Exception):
#     def __init__(self, func, *args, **kwargs):
#     def func(self):
#     def args(self):
#     def kwargs(self):
#     def __init__(self, x, y, page, status):
#     def x(self):
#     def y(self):
#     def page(self):
#     def status(self):
#     def name(self):
#     def x(self, value):
#     def y(self, value):
#     def page(self, value):
#     def status(self, value):
#     def name(self, value):
#     def __init__(self):
#     def do_event(self, _event):
#     def current_thread(self):
#     def current_thread(self, thread):
#     def register_thread(self, thread):
#     def auto_duel_box(self):
#     def current_run(self):
#     def current_run(self, run):
#     def sleep_factor(self):
#     def sleep_factor(self, value):
#     def wait_for_ui(self, amount):
#     async def async_wait_for_ui(self, amount):
#     def auto(self):
#     def debug_battle(self):
#     def check_battle_is_running(self):
#     def check_battle(self):
#     def scan(self):
#     def method_name(self):
#     def compare_with_cancel_button(self, corr=HIGH_CORR, info=None, img=None):
#     def compare_with_back_button(self, corr=HIGH_CORR, info=None, img=None):
#     def scan_for_ok(self, corr=HIGH_CORR, info=None, img=None):
#     def scan_for_close(self, corr=HIGH_CORR, info=None, img=None):
#     def get_current_page(self, img):
#     def click_auto_duel(self):
#     def determine_autoduel_status(self, img):
#     def battle(self, info=None, check_battle=None):
#     def check_if_battle(self, img):
#     def verify_battle(self, img=None, log=True):
#     def pass_through_initial_screen(self):
#     def wait_for(self, word, try_scanning=False):
#     def wait_for_auto_duel(self):
#     def wait_for_white_bottom(self):
#     def __init__(self, value):
#     def __str__(self):
# 
# Path: bot/common.py
# def crop_image(img, left=0, top=0, width=0, height=0):
#     left, top, width, height = tuple(np.asanyarray([left, top, width, height], np.uint64).tolist())
#     crop_img = img[top:(top + height), left:(left + width)].copy()
#     return crop_img


import logging
from abc import abstractmethod
from bot.providers.duellinks import DuelLinksInfo, alphabet
from bot.common import crop_image
    alphabet_set = ''.join(set(looking_for)).replace(' ', '')

    def is_occurrence(self, img=None):
        if img is None:
            img = self.provider.get_img_from_screen_shot()
        street_replay = self.provider.predefined.street_replay
        img = crop_image(img, **street_replay)
        word = self.provider.img_to_string(img, self.alphabet_set, mask_area=([200], [255]))
        matched = list(set(word.lower().split(' ')) & set(self.looking_for.lower().split(' ')))
        if len(matched) > 0:
            return True
        return False

    def event_condition(self, dl_info: DuelLinksInfo, img=None):
        return self.provider.predefined.street_replay_location == dl_info.page \
               and self.is_occurrence(img)

    def event_occurred(self, dl_info: DuelLinksInfo, img=None):
        dl_info.status = "street replay cancelling"
        self.provider.compare_with_cancel_button(info=dl_info, img=img)


class RankedDuelsQuickStart(AbstractIgnoreEvent):
    looking_for = 'Ranked Duels Quick Start'
    alphabet_set = ''.join(set(looking_for)).replace(' ', '')

    def is_occurrence(self, img=None):
        if img is None:
            img = self.provider.get_img_from_screen_shot()
        quick_ranked_area = self.provider.predefined.quick_rankduel_area

# Path: bot/providers/duellinks.py
# class Event(object):
# class DuelLinksInfo(object):
# class EventExecutor(object):
# class DuelLinks(object):
# class DuelError(Exception):
#     def __init__(self, func, *args, **kwargs):
#     def func(self):
#     def args(self):
#     def kwargs(self):
#     def __init__(self, x, y, page, status):
#     def x(self):
#     def y(self):
#     def page(self):
#     def status(self):
#     def name(self):
#     def x(self, value):
#     def y(self, value):
#     def page(self, value):
#     def status(self, value):
#     def name(self, value):
#     def __init__(self):
#     def do_event(self, _event):
#     def current_thread(self):
#     def current_thread(self, thread):
#     def register_thread(self, thread):
#     def auto_duel_box(self):
#     def current_run(self):
#     def current_run(self, run):
#     def sleep_factor(self):
#     def sleep_factor(self, value):
#     def wait_for_ui(self, amount):
#     async def async_wait_for_ui(self, amount):
#     def auto(self):
#     def debug_battle(self):
#     def check_battle_is_running(self):
#     def check_battle(self):
#     def scan(self):
#     def method_name(self):
#     def compare_with_cancel_button(self, corr=HIGH_CORR, info=None, img=None):
#     def compare_with_back_button(self, corr=HIGH_CORR, info=None, img=None):
#     def scan_for_ok(self, corr=HIGH_CORR, info=None, img=None):
#     def scan_for_close(self, corr=HIGH_CORR, info=None, img=None):
#     def get_current_page(self, img):
#     def click_auto_duel(self):
#     def determine_autoduel_status(self, img):
#     def battle(self, info=None, check_battle=None):
#     def check_if_battle(self, img):
#     def verify_battle(self, img=None, log=True):
#     def pass_through_initial_screen(self):
#     def wait_for(self, word, try_scanning=False):
#     def wait_for_auto_duel(self):
#     def wait_for_white_bottom(self):
#     def __init__(self, value):
#     def __str__(self):
# 
# Path: bot/common.py
# def crop_image(img, left=0, top=0, width=0, height=0):
#     left, top, width, height = tuple(np.asanyarray([left, top, width, height], np.uint64).tolist())
#     crop_img = img[top:(top + height), left:(left + width)].copy()
#     return crop_img


# Path: bot/modes/SpecialEvents.py
import logging
from abc import abstractmethod
from bot.providers.duellinks import DuelLinksInfo, alphabet
from bot.common import crop_image

    alphabet_set = ''.join(set(looking_for)).replace(' ', '')

    def is_occurrence(self, img=None):
        if img is None:
            img = self.provider.get_img_from_screen_shot()
        street_replay = self.provider.predefined.street_replay
        img = crop_image(img, **street_replay)
        word = self.provider.img_to_string(img, self.alphabet_set, mask_area=([200], [255]))
        matched = list(set(word.lower().split(' ')) & set(self.looking_for.lower().split(' ')))
        if len(matched) > 0:
            return True
        return False

    def event_condition(self, dl_info: DuelLinksInfo, img=None):
        return self.provider.predefined.street_replay_location == dl_info.page \
               and self.is_occurrence(img)

    def event_occurred(self, dl_info: DuelLinksInfo, img=None):
        dl_info.status = "street replay cancelling"
        self.provider.compare_with_cancel_button(info=dl_info, img=img)


class RankedDuelsQuickStart(AbstractIgnoreEvent):
    looking_for = 'Ranked Duels Quick Start'
    alphabet_set = ''.join(set(looking_for)).replace(' ', '')

    def is_occurrence(self, img=None):
        if img is None:
            img = self.provider.get_img_from_screen_shot()
        quick_ranked_area = self.provider.predefined.quick_rankduel_area

        img = crop_image(img, **quick_ranked_area)