mud_server.admin_gradio.tabs.game_tab ===================================== .. py:module:: mud_server.admin_gradio.tabs.game_tab .. autoapi-nested-parse:: Game Tab for MUD Client. This module provides the main gameplay interface with room view, chat, status panel, movement controls, and auto-refresh functionality. Visible only when logged in. Migration Notes: - Migrated from old api_client.py to new modular structure - Uses GameAPIClient for game operations (send_command, get_chat, get_status, refresh_display) - Uses AuthAPIClient for logout - Wrapper functions extract session_id, username, and role from session_state - refresh_display returns dict with {"room": str, "chat": str} instead of tuple - All other functions return strings for Gradio display Functions --------- .. autoapisummary:: mud_server.admin_gradio.tabs.game_tab.send_command mud_server.admin_gradio.tabs.game_tab.refresh_display mud_server.admin_gradio.tabs.game_tab.get_status mud_server.admin_gradio.tabs.game_tab.logout mud_server.admin_gradio.tabs.game_tab.create Module Contents --------------- .. py:function:: send_command(command, session_state) Send a game command to the backend for execution. Sends request to backend via GameAPIClient and returns command result. This function wraps the new GameAPIClient.send_command() method to maintain compatibility with the Gradio interface while using the new modular API. :param command: Command string to execute :param session_state: User's session state dictionary containing session_id :returns: Command result string or error message .. admonition:: Examples >>> session = {"session_id": "abc123", "logged_in": True} >>> result = send_command("look", session) >>> isinstance(result, str) True .. py:function:: refresh_display(session_state) Refresh both room and chat displays by fetching current data. Sends request to backend via GameAPIClient and returns room and chat data. This function wraps the new GameAPIClient.refresh_display() method to maintain compatibility with the Gradio interface while using the new modular API. :param session_state: User's session state dictionary containing session_id :returns: Tuple of (room_description, chat_messages) both as strings .. admonition:: Examples >>> session = {"session_id": "abc123", "logged_in": True} >>> room, chat = refresh_display(session) >>> isinstance(room, str) and isinstance(chat, str) True .. py:function:: get_status(session_state) Retrieve and format player status information. Sends request to backend via GameAPIClient and returns formatted status. This function wraps the new GameAPIClient.get_status() method to maintain compatibility with the Gradio interface while using the new modular API. :param session_state: User's session state dictionary containing session_id, username, role :returns: Formatted status string .. admonition:: Examples >>> session = {"session_id": "abc123", "username": "alice", "role": "player", "logged_in": True} >>> result = get_status(session) >>> isinstance(result, str) True .. py:function:: logout(session_state) Handle user logout and return result tuple for Gradio. Sends logout request to backend via AuthAPIClient and returns result tuple matching the expected format from old api_client. This function wraps the new AuthAPIClient.logout() method to maintain compatibility with the Gradio interface while using the new modular API. Note: This function is called from game_tab but the full logout flow with tab visibility updates is handled in app.py's logout_and_hide_tabs() function. :param session_state: User's session state dictionary containing session_id :returns: Tuple matching old API format for compatibility with app.py logout handler Format: (session_state, message, blank, ...) The app.py handler extracts result[1] for the message .. admonition:: Examples >>> session = {"session_id": "abc123", "logged_in": True} >>> result = logout(session) >>> isinstance(result, tuple) and len(result) >= 2 True .. py:function:: create(session_state) Create the Game tab with full gameplay interface. :param session_state: Gradio State component for session tracking :returns: (game_tab, logout_btn) - Tab component and logout button for top-level event wiring :rtype: tuple