gs = GameState() # Central game state object
gs.WORD_SETS = assets.load_words(app_config.WORDS_FILE)
# Initialize fonts and store them in GameState
initialized_fonts = assets.initialize_fonts()
for name, font_obj in initialized_fonts.items():
gs.set_font(name, font_obj)
# Initial screen setup for the menu
gs.WIDTH = app_config.DEFAULT_WIDTH
gs.HEIGHT = app_config.DEFAULT_HEIGHT
gs.update_display_mode() # Sets screen and caption
# --- Main Program Loop ---
while True:
# 1. Show Main Menu and get user's choice
difficulty_choice = ui.show_main_menu_display(gs, app_config)
if difficulty_choice is None: # Should only happen if user quits from menu (handled by sys.exit there)
print("Menu exited without selection. Quitting.")
break
# 2. If 'custom', prompt for custom settings
if difficulty_choice == 'custom':
ui.prompt_custom_difficulty_settings(gs, app_config)
# gs.difficulty, gs.custom_guesses_count, gs.custom_mode_active,
# gs.WIDTH, gs.HEIGHT are now updated by the prompt function.
# 3. Initialize the game session based on the choice
# For 'custom', difficulty_choice is 'custom', but gs object already has the specific settings.
game_manager.initialize_game_session_logic(gs, app_config, difficulty_choice)
# 4. Run the game session loop
game_manager.run_game_session_loop(gs, app_config)
# After a game session ends (win, loss, or back to menu),
# the loop continues, and the main menu is shown again.