Start main menu
This commit is contained in:
parent
ef7b949895
commit
0d1646e0ff
1 changed files with 18 additions and 11 deletions
27
__main__.py
27
__main__.py
|
@ -1,17 +1,24 @@
|
||||||
from sys import argv
|
from genericpath import isdir
|
||||||
from lib.game import *
|
from lib.game import *
|
||||||
from colorama import init
|
from colorama import init, Back, Fore
|
||||||
|
from os import mkdir, listdir
|
||||||
|
|
||||||
|
|
||||||
def main(): # TODO: Maybe a menu for available text games?
|
def main(): # TODO: Maybe a menu for available text games?
|
||||||
init()
|
init()
|
||||||
if len(argv)<2:
|
if(not isdir("./games")):
|
||||||
print("You need to specify a path to a YAML file")
|
mkdir("./games")
|
||||||
exit(1)
|
games = []
|
||||||
else:
|
for file in listdir("./games"):
|
||||||
game = load(argv[1])
|
if file.endswith("yml") or file.endswith("yaml"):
|
||||||
if(game is None):
|
# finds available games
|
||||||
exit(1)
|
try:
|
||||||
game.main_menu()
|
# try parsing
|
||||||
|
g = load(f"./games/{file}")
|
||||||
|
games.append(g)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"{Back.RED}{Fore.RED}An exception has occured while loading {file}:")
|
||||||
|
print(e)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
Reference in a new issue