From aa26e42d4c049358b1d9fbd9173f6d3822542ca9 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 30 Mar 2023 21:07:52 +0200 Subject: [PATCH] Ask user for multiple cheats --- main.py | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/main.py b/main.py index becd926..b0c8075 100644 --- a/main.py +++ b/main.py @@ -361,37 +361,40 @@ if __name__ == "__main__": # Cheat c = Cheat() - # # Cheat list - # print("Enter 0 to exit.") - # print("Available cheats:") - # for idx, cheat in enumerate(c.cheats_list): - # print(f"#{idx + 1} - {cheat}") + # Cheat list + print("Enter 0 to exit.") + print("You can run multiples cheat at once, separate your choices with a space.") + print("Available cheats:") + for idx, cheat in enumerate(c.cheats_list): + print(f"#{idx + 1} - {cheat}") - # # Select cheat - # c_id = None - # while c_id == None: - # try: - # match int(input("Enter ID: #")): - # case 0: - # exit(0) - # case i if i > len(c.cheats_list): - # raise IndexError - # case _ as i: - # c_id = i - 1 - # except KeyboardInterrupt: - # print("??\nBye.") - # exit(1) - # except: - # print("Invalid ID.") - - # Run cheat - # getattr(c, c.cheats_list[c_id])() + # Select cheat + c_id = None + while c_id == None: + try: + response = [int(i) for i in input("Enter ID: ").split(" ")] + c_id = [] + for i in response: + match i: + case 0: + exit(0) + case j if j > len(c.cheats_list): + raise IndexError + case _: + c_id.append(i - 1) + except KeyboardInterrupt: + print("??\nBye.") + exit(1) + except: + print("Invalid ID.") # Instanciate and run threads - for fn in c.cheats_list: + for fn in [c.cheats_list[i] for i in c_id]: + print(f"Running {fn}...") t = Thread(target=getattr(c, fn)) t.daemon = True t.start() + # Don't close the main thread as cheats are daemons while True: sleep(1000000)