path-of-the-loner/controllers/mainController.py
2025-03-03 16:47:07 +01:00

43 lines
1 KiB
Python

# mainController
from controllers.PvpController import PvpController
from controllers.PveController import PveController
from database.mainDB import MainDB
from sty import fg
class MainController:
def __init__(self) -> None:
self.db = MainDB()
self.init()
def init(self):
PVP_MODE = 1
PVE_MODE = 2
game_mode = [PVP_MODE, PVE_MODE]
choice = 0
while choice not in game_mode:
print("Choose your game mode")
print(f"{PVP_MODE}. PVP mode")
print(f"{PVE_MODE}. PVE mode")
try:
choice = int(input("Choose your gamemode: "))
except ValueError:
print(f"{fg.red}Input a valid number{fg.rs}")
continue
if choice == PVP_MODE:
PvpController(self)
elif choice == PVE_MODE:
PveController(self)
else:
raise Exception("An error occured")
def close_game(self):
input("Press any key to quit game")
self.db.close_db()