This repository has been archived on 2023-09-02. You can view files and clone it, but cannot push or open issues or pull requests.
csh/main.py
2023-04-01 16:11:56 +02:00

58 lines
1.7 KiB
Python

from sys import argv
from threading import Thread
from cheat import Cheat, sleep
if __name__ == "__main__":
c_id = []
args = {}
if (len(argv) > 1):
# User wanna use offline offsets
if "--offline" in argv:
args["offline"] = True
# User gave a list of cheats
# Will bypass the interactive selection
c_id = [int(j) for j in [i for i in argv if i.startswith(
"--list=")][0][7:].split(",")]
# Load cheat class
c = Cheat(**args)
# Interactive selection
if (c_id == []):
# 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}")
while c_id == []:
try:
response = [int(i) for i in input("Enter ID: ").split(" ")]
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[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)