Skip to content

Commit

Permalink
Add support for variables inside rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Azelphur committed Dec 11, 2018
1 parent 49bc9a0 commit 551fb2b
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions ivcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,15 @@ async def start(self):
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('KEYCODE_PASTE') # Paste into rename
elif "rename" in actions:
await self.p.send_intent("clipper.set", extra_values=[["text", actions["rename"]]])

if args.touch_paste:
await self.swipe('edit_box', 600)
await self.tap('paste')
else:
await self.p.key('KEYCODE_PASTE') # Paste into 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')
Expand All @@ -164,7 +159,7 @@ async def get_data_from_clipboard(self):
if key in d:
d[key] = float(d[key])
d["iv"] = None
return d
return clipboard, d

raise Exception("Clipboard regex did not match, got " + clipboard)

Expand Down Expand Up @@ -232,13 +227,11 @@ async def check_favorite(self):
return color_count > 500

async def get_actions(self, values):
clipboard_values = None
valid_conditions = [
"name", "iv", "iv_min", "iv_max", "success", "blacklist",
"appraised", "id", "cp", "max_hp", "dust_cost", "level",
"fast_move", "special_move", "gender"
]
clipboard_required = ["iv", "iv_min", "iv_max"]
for ruleset in self.config["actions"]:
conditions = ruleset.get("conditions", {})
# Check if we need to read the clipboard
Expand All @@ -247,9 +240,6 @@ async def get_actions(self, values):
operator = None
if "__" in key:
key, operator = key.split("__")
if key in clipboard_required and clipboard_values is None:
clipboard_values = await self.get_data_from_clipboard()
values = {**values, **clipboard_values}

if isinstance(values[key], str):
if values[key].isnumeric():
Expand Down Expand Up @@ -297,6 +287,9 @@ async def check_pokemon(self):
state = CALCY_RED_BAR
return state, values
else:
clipboard, clipboard_values = await self.get_data_from_clipboard()
values = {**values, **clipboard_values}
values["calcy"] = clipboard
return state, values

match = RE_RED_BAR.match(line)
Expand Down

0 comments on commit 551fb2b

Please sign in to comment.