Azelphur / PokemonGo-CalcyIV-Renamer

Uses adb to send fake tap events to your phone, alongside Calcy IV to automatically rename all your pokemon.
GNU General Public License v3.0
77 stars 32 forks source link

Whenever CalcyIV goes crazy, the scripts either fails or executes action based on previous clipboard #32

Closed esauvisky closed 5 years ago

esauvisky commented 5 years ago

Sometimes, it seems that the scripts sends the intent too soon, probably after a slow 'next_pokémon' tap, and Calcy returns a Bulbassaur with all values equal to zero and doesn't set a clipboard.

This causes our script to wrongly assume that the pokémon was correctly identified and the clipboard is ok, making it execute the action based on the current clipboard. In my case, if the last pokémon used my rename-prefix custom action (see example below), the script merely fails and shuts down.

Maybe this is exclusive to my setup, but as it's an intermittent issue I think it might happen to other people as well, so I'm opening an issue.

An easy fix would be to add another check alongside the if -1 in values[...] for checking a level zero, which is impossible in the game.

See the log below:

2018-11-09 22:18:23,384 - ivcheck - DEBUG - logcat line received: D/MainService( 3419): Received values: Id: 0 (Bulbasaur), Nr: 1, CP: 0, Max HP: 0, Dust cost: 0, Level: 0.0, FastMove Wrap, SpecialMove Wrap, Gender 0, Level-up false:
2018-11-09 22:18:23,384 - ivcheck - DEBUG - RE_CALCY_IV matched
2018-11-09 22:18:23,384 - PokemonGo - INFO - Sending intent: am broadcast -a clipper.get
2018-11-09 22:18:23,384 - PokemonGo - DEBUG - Running ['adb', '-s', '10.42.0.41:5555', 'shell', 'am broadcast -a clipper.get']
2018-11-09 22:18:23,616 - PokemonGo - DEBUG - Return code 0
2018-11-09 22:18:23,618 - PokemonGo - INFO - RE_CLIPBOARD_TEXT matched.
2018-11-09 22:18:23,618 - ivcheck - DEBUG - Device clipboard is: ⁺
2018-11-09 22:18:23,618 - ivcheck - DEBUG - Normalized clipboard is: +
/usr/lib/python3.7/asyncio/unix_events.py:861: RuntimeWarning: A loop is being detached from a child watcher with pending handlers
  RuntimeWarning)
Traceback (most recent call last):
  File "ivcheck.py", line 342, in <module>
    asyncio.run(Main(args).start())
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete
    return future.result()
  File "ivcheck.py", line 92, in start
    actions = await self.get_actions(values)
  File "ivcheck.py", line 251, in get_actions
    clipboard_values = await self.get_data_from_clipboard()
  File "ivcheck.py", line 169, in get_data_from_clipboard
    raise Exception("Clipboard regex did not match, got " + clipboard)
Exception: Clipboard regex did not match, got ⁺