LVPWB/lvpwb/cli.py

43 lines
1.5 KiB
Python

from __future__ import annotations
import json
import lvpwb as app
def main() -> int:
app.refresh_custom_games()
print(app.color("LVPWB — Light Virtual Pro-Wrestling Booker", app.CYAN))
while True:
try:
choice = app.ask_choice(
"Main menu", ["new", "random", "season", "load", "byog", "exit"],
labels=["Create a new three-match card", "Create a fully randomized show",
"Season Mode", "Load / resume a saved card", "BYOG / Manage Games",
"Exit"],
)
if choice == 0:
app.resume_card(app.create_card())
elif choice == 1:
app.resume_card(app.create_random_card())
elif choice == 2:
app.season_mode()
elif choice == 3:
path = app.select_card_path()
if path is None:
continue
try:
card = app.load_card(path)
go_to_season = app.resume_card(card)
if go_to_season:
app.run_season(app.load_season(str(card["season_id"])))
except (OSError, ValueError, json.JSONDecodeError) as exc:
print(f"Could not load card: {exc}")
elif choice == 4:
app.manage_games()
else:
return 0
except (KeyboardInterrupt, EOFError):
print("\nGoodbye.")
return 0
__all__ = ['main']