Ejemplo n.º 1
0
 def __init__(self, args):
     with open(args.config, "r") as f:
         self.config = yaml.load(f)
     self.args = args
     tools = pyocr.get_available_tools()
     self.tool = tools[0]
     self.p = PokemonGo()
Ejemplo n.º 2
0
    async def start(self):
        self.p = PokemonGo()
        await self.p.set_device(self.args.device_id)
        logger.error('Oh.. eggy eggy eggies...')

        # forces the first round to do the checks and switching
        last_check_time = time.time() - self.config['times']['on_world']
        last_switch_time = time.time()  # - self.config['times']['on_each_app']
        last_refill_time = time.time()  # - self.config['times']['on_each_app']

        while True:
            screencap = await self.p.screencap()
            self.state = await self.get_current_state(screencap)
            time_now = time.time()

            if self.state == 'on_hatching':
                await self.watch_the_egg_hatch()
            elif self.state == 'on_world':
                pass
            elif self.state == 'on_eggs':
                await self.tap('pokeball_button')
            else:
                # wtf... a gps or weather dialog perhaps?
                await self.deal_with_blocking_dialogs()
                continue

            if args.refill and time_now - last_refill_time >= self.config[
                    'times']['refill_each'] and self.state == 'on_world':
                await self.stop_pokemon_goplus(120)
                last_refill_time = time_now
                # if await self.stop_pokemon_goplus(120):
                #     last_refill_time = time_now
                # else:
                #     await self.deal_with_blocking_dialogs()

            if self.args.switch and self.state == 'on_world':
                if time_now - last_switch_time >= self.config['times'][
                        'on_each_app']:
                    logger.warning('OK, TIME TO CHECK OUR FRIEND!')
                    await self.switch_app()
                    last_switch_time = time_now
                    last_check_time = time.time(
                    ) - self.config['times']['on_world']
                    continue

            if time_now - last_check_time >= self.config['times'][
                    'on_world'] and self.state == 'on_world':
                # if we spent more than allowed on the world
                #   check the freaking eggs
                if await self.check_my_eggs():
                    last_check_time = time_now
                else:
                    await self.deal_with_blocking_dialogs()

            await asyncio.sleep(10)
Ejemplo n.º 3
0
    def __init__(self, args):
        with open(args.config, "r") as f:
            self.config = yaml.load(f)
        self.args = args
        tools = pyocr.get_available_tools()
        self.tool = tools[0]
        self.p = PokemonGo()
        self.i = 2

        self.CHECK_STRING = self.config['names']['name_check']
        self.SEARCH_STRING = self.config['names']['search_string']
Ejemplo n.º 4
0
    async def start(self):
        self.p = PokemonGo()
        await self.p.set_device(self.args.device_id)
        await self.p.start_logcat()
        num_errors = 0
        while True:
            blacklist = False
            state, values = await self.check_pokemon()
            await self.p.seek_to_end(
            )  # just in case any additional lines are present
            if values["name"] in self.config["blacklist"]:
                blacklist = True
            elif state == CALCY_SUCCESS:
                num_errors = 0
            elif state == CALCY_RED_BAR:
                continue
            elif state == CALCY_SCAN_INVALID:
                num_errors += 1
                if num_errors < args.max_retries:
                    continue
                num_errors = 0

            values["success"] = True if state == CALCY_SUCCESS else False
            values["blacklist"] = blacklist

            actions = await self.get_name(values)

            if "rename" in actions or "rename-calcy" in actions:
                if values["success"] is False:
                    await self.tap('close_calcy_dialog')  # it gets in the way
                await self.tap('rename')
                if "rename-calcy" in actions:
                    if args.touch_paste:
                        await self.swipe('edit_box', 600)
                        await self.tap('paste')

                    else:
                        await self.p.key(279)  # Paste into rename
                elif "rename" in actions:
                    await self.p.text(actions["rename"])

                await self.tap('keyboard_ok')
                await self.tap('rename_ok')
            if "favorite" in actions:
                if await self.check_favorite():
                    await self.tap('favorite_button')
            await self.tap('next')
Ejemplo n.º 5
0
    async def setup(self):
        self.p = PokemonGo()
        if self.args.device_id is None:
            await self.p.get_device()
        else:
            await self.p.set_device(self.args.device_id)
        if self.args.copy_calcy:
            await self.p.send_intent("clipper.set", extra_values=[["text", CALCY_STRING]])
            return False

        path = "config.yaml"
        device_path = await self.p.get_device()+".yaml"
        if self.args.config is None and os.path.exists(device_path):
            path = device_path
        elif self.args.config is not None:
            path = self.args.config

        with open(path, "r") as f:
            self.config = yaml.load(f, Loader)
        await self.p.start_logcat()
Ejemplo n.º 6
0
    async def start(self):
        self.p = PokemonGo()
        await self.p.start_logcat()
        num_errors = 0
        while True:
            try:
                values = await self.check_pokemon()
                num_errors = 0
            except RedBarError:
                continue
            except CalcyIVError:
                num_errors += 1
                if num_errors > args.max_retries:
                    self.tap('next')
                    num_errors = 0
                continue

            await self.tap('dismiss_calcy')
            await self.tap('rename')
            await self.p.key(279)  # Paste into rename
            await self.tap('keyboard_ok')
            await self.tap('rename_ok')
            await self.tap('next')
Ejemplo n.º 7
0
    async def start(self):
        self.p = PokemonGo()
        await self.p.set_device(self.args.device_id)
        await self.p.start_logcat()
        num_errors = 0
        while True:
            blacklist = False
            state, values = await self.check_pokemon()
            await self.p.seek_to_end(
            )  # just in case any additional lines are present

            if values["name"] in self.config["blacklist"]:
                blacklist = True
            elif state == CALCY_SUCCESS:
                num_errors = 0
            elif state == CALCY_RED_BAR:
                continue
            elif state == CALCY_SCAN_INVALID:
                num_errors += 1
                if num_errors < args.max_retries:
                    continue
                num_errors = 0

            values[
                "success"] = True if state == CALCY_SUCCESS and blacklist == False else False
            values["blacklist"] = blacklist
            values["appraised"] = False

            actions = await self.get_actions(values)
            if "appraise" in actions:
                await self.tap("pokemon_menu_button")
                await self.tap("appraise_button")
                await self.p.send_intent("tesmath.calcy.ACTION_ANALYZE_SCREEN",
                                         "tesmath.calcy/.IntentReceiver",
                                         [["silentMode", True]])
                for i in range(0, 3):
                    await self.tap("continue_appraisal")
                while await self.check_appraising():
                    await self.tap("continue_appraisal")
                await self.tap("calcy_appraisal_save_button")
                values["appraised"] = True
                actions = await self.get_actions(values)
                await self.tap("dismiss_calcy")

            if "rename" in actions or "rename-calcy" in actions:
                if values["success"] is False:
                    await self.tap('close_calcy_dialog')  # it gets in the way
                await self.tap('rename')
                if "rename-calcy" in actions:
                    if args.touch_paste:
                        await self.swipe('edit_box', 600)
                        await self.tap('paste')

                    else:
                        await self.p.key(279)  # Paste into rename
                elif "rename" in actions:
                    await self.p.text(actions["rename"])

                await self.tap('keyboard_ok')
                await self.tap('rename_ok')
            if "favorite" in actions:
                if not await self.check_favorite():
                    await self.tap('favorite_button')
            await self.tap('next')
Ejemplo n.º 8
0
    async def start(self):
        self.p = PokemonGo()
        await self.p.set_device(self.args.device_id)
        await self.p.start_logcat()
        num_errors = 0
        while True:
            blacklist = False
            state, values = await self.check_pokemon()

            if values["name"] in self.config["blacklist"]:
                blacklist = True
            elif state == CALCY_SUCCESS:
                num_errors = 0
            elif state == CALCY_RED_BAR:
                continue
            elif state == CALCY_SCAN_INVALID:
                num_errors += 1
                if num_errors < args.max_retries:
                    continue
                num_errors = 0

            values[
                "success"] = True if state == CALCY_SUCCESS and blacklist is False else False
            values["blacklist"] = blacklist
            values["appraised"] = False
            actions = await self.get_actions(values)
            if "appraise" in actions:
                await self.tap("pokemon_menu_button")
                await self.tap("appraise_button")
                await self.p.send_intent("tesmath.calcy.ACTION_ANALYZE_SCREEN",
                                         "tesmath.calcy/.IntentReceiver",
                                         [["silentMode", True]])
                for i in range(
                        0, 4
                ):  # we can do it four times before beggining to screencap
                    await self.tap("continue_appraisal")
                while await self.check_appraising():
                    await self.tap("continue_appraisal")
                await self.tap("calcy_appraisal_save_button")
                values["appraised"] = True
                actions = await self.get_actions(values)
                await self.tap("dismiss_calcy")

            if "rename" in actions or "rename-calcy" in actions:
                if values["success"] is False:
                    await self.tap('close_calcy_dialog')  # it gets in the way
                await self.tap('rename')

                if actions.get(
                        "rename", "{calcy}"
                ) != "{calcy}":  # Don't bother setting clipboard if we don't need to change it
                    await self.p.send_intent(
                        "clipper.set",
                        extra_values=[[
                            "text", actions["rename"].format(**values)
                        ]])

                if args.touch_paste:
                    await self.swipe('edit_box', 600)
                    await self.tap('paste')
                else:
                    await self.p.key('KEYCODE_PASTE')  # Paste into rename
                # await self.tap('keyboard_ok')  # Instead of yet another tap, use keyevents for reliability
                await self.p.key('KEYCODE_TAB')
                await self.p.key('KEYCODE_ENTER')
                await self.tap('rename_ok')
            if "favorite" in actions:
                if not await self.check_favorite():
                    await self.tap('favorite_button')
            await self.tap('next')
Ejemplo n.º 9
0
#!/usr/bin/env python3.7
import logging
import asyncio
from PIL import Image
import colorsys

from pokemonlib import PokemonGo
p = PokemonGo()


async def hue_affinity(hue1, hue2):
    '''Checks the affinity, in percentual terms,
    of the average median im hue against hue1 and
    hue2.

    Input values are in range 0-255, instead of
    the common 0-360° used for HSL and HSV images.

    Arguments:
        image {Image}   -- PIL.Image
        hue1  {int}     -- 0-255
        hue2  {int}     -- 0-255

    Returns:
        {tuple}   -- A tuple containing the relative
                        percentages lenghts of the arcs
                        between im's median hue against
                        hue1 and hue2, respectively.
    '''
    ## Image filtering mumbojumbo
    im = await p.screencap()