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 colorama import init
|
||||
from colorama import init, Back, Fore
|
||||
from os import mkdir, listdir
|
||||
|
||||
|
||||
def main(): # TODO: Maybe a menu for available text games?
|
||||
init()
|
||||
if len(argv)<2:
|
||||
print("You need to specify a path to a YAML file")
|
||||
exit(1)
|
||||
else:
|
||||
game = load(argv[1])
|
||||
if(game is None):
|
||||
exit(1)
|
||||
game.main_menu()
|
||||
if(not isdir("./games")):
|
||||
mkdir("./games")
|
||||
games = []
|
||||
for file in listdir("./games"):
|
||||
if file.endswith("yml") or file.endswith("yaml"):
|
||||
# finds available games
|
||||
try:
|
||||
# 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__":
|
||||
main()
|
Reference in a new issue