Start main menu

This commit is contained in:
Matyáš Caras 2022-03-22 11:22:50 +01:00 committed by GitHub
parent ef7b949895
commit 0d1646e0ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()
main()