Ask user for multiple cheats
This commit is contained in:
parent
fe14f5f094
commit
aa26e42d4c
1 changed files with 28 additions and 25 deletions
53
main.py
53
main.py
|
@ -361,37 +361,40 @@ if __name__ == "__main__":
|
||||||
# Cheat
|
# Cheat
|
||||||
c = Cheat()
|
c = Cheat()
|
||||||
|
|
||||||
# # Cheat list
|
# Cheat list
|
||||||
# print("Enter 0 to exit.")
|
print("Enter 0 to exit.")
|
||||||
# print("Available cheats:")
|
print("You can run multiples cheat at once, separate your choices with a space.")
|
||||||
# for idx, cheat in enumerate(c.cheats_list):
|
print("Available cheats:")
|
||||||
# print(f"#{idx + 1} - {cheat}")
|
for idx, cheat in enumerate(c.cheats_list):
|
||||||
|
print(f"#{idx + 1} - {cheat}")
|
||||||
|
|
||||||
# # Select cheat
|
# Select cheat
|
||||||
# c_id = None
|
c_id = None
|
||||||
# while c_id == None:
|
while c_id == None:
|
||||||
# try:
|
try:
|
||||||
# match int(input("Enter ID: #")):
|
response = [int(i) for i in input("Enter ID: ").split(" ")]
|
||||||
# case 0:
|
c_id = []
|
||||||
# exit(0)
|
for i in response:
|
||||||
# case i if i > len(c.cheats_list):
|
match i:
|
||||||
# raise IndexError
|
case 0:
|
||||||
# case _ as i:
|
exit(0)
|
||||||
# c_id = i - 1
|
case j if j > len(c.cheats_list):
|
||||||
# except KeyboardInterrupt:
|
raise IndexError
|
||||||
# print("??\nBye.")
|
case _:
|
||||||
# exit(1)
|
c_id.append(i - 1)
|
||||||
# except:
|
except KeyboardInterrupt:
|
||||||
# print("Invalid ID.")
|
print("??\nBye.")
|
||||||
|
exit(1)
|
||||||
# Run cheat
|
except:
|
||||||
# getattr(c, c.cheats_list[c_id])()
|
print("Invalid ID.")
|
||||||
|
|
||||||
# Instanciate and run threads
|
# 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 = Thread(target=getattr(c, fn))
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
|
# Don't close the main thread as cheats are daemons
|
||||||
while True:
|
while True:
|
||||||
sleep(1000000)
|
sleep(1000000)
|
||||||
|
|
Reference in a new issue