From 13063b112bab183ca6f3b07f1393ed8fe89c524b Mon Sep 17 00:00:00 2001 From: LazoCoder Date: Tue, 25 Apr 2017 11:10:37 -0400 Subject: [PATCH] Added method to check what the current pokemon is Useful if someone uses random, then wants to know what it was changed to. --- Scripts/background.scpt | 2 +- extractor.py | 11 +++++++++++ main.py | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Scripts/background.scpt b/Scripts/background.scpt index 37087da..a1bf185 100644 --- a/Scripts/background.scpt +++ b/Scripts/background.scpt @@ -1,5 +1,5 @@ tell application "iTerm" tell current session of current window - set background image to "/Users/Laki/GitHub/Pokemon-Terminal-Themes/Images/Generation IV - Sinnoh/478.png" + set background image to "/Users/Laki/GitHub/Pokemon-Terminal-Themes/Images/Generation IV - Sinnoh/390.png" end tell end tell \ No newline at end of file diff --git a/extractor.py b/extractor.py index c9c98a7..9d752cb 100644 --- a/extractor.py +++ b/extractor.py @@ -43,3 +43,14 @@ def pokemon_containing(word): if word in trimmed: result.append(printer.add_zeroes(pokemon)) return result + + +# Get the current Pokemon that is in the background. +def current_pokemon(): + content = open(os.get_exec_path()[0] + "/Scripts/background.scpt", "r+").readlines() + pokemon_id = content[2][len(content[2])-9:-6] + all_pokemon = load_names() + for pokemon in all_pokemon: + if int(pokemon.split(' ')[0]) == int(pokemon_id): + print(pokemon[:-1]) # Remove the new line at the end. + break diff --git a/main.py b/main.py index 3637f9d..a54d711 100755 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from sys import argv import backchanger +import extractor import printer import random import sys @@ -27,7 +28,7 @@ if __name__ == "__main__": print("No command line arguments specified. Try typing in a Pokemon name or number.") elif len(argv) == 2: arg = argv[1].lower() - if len(arg) == 1 and not arg.isdigit(): + if len(arg) == 1 and arg.isalpha(): printer.print_pokemon_starting_with(arg) elif arg == "regions": printer.print_regions() @@ -47,6 +48,8 @@ if __name__ == "__main__": debug() elif arg == "rand" or arg == "random": backchanger.change_background(random.randint(1, 494)) + elif arg == "?" or arg == "current": + extractor.current_pokemon() else: backchanger.change_background(arg) else: