mud_server.admin_gradio.tabs.game_tab
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
|
Send a game command to the backend for execution. |
|
Refresh both room and chat displays by fetching current data. |
|
Retrieve and format player status information. |
|
Handle user logout and return result tuple for Gradio. |
|
Create the Game tab with full gameplay interface. |
Module Contents
- mud_server.admin_gradio.tabs.game_tab.send_command(command, session_state)[source]
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.
- Parameters:
- Returns:
Command result string or error message
- Return type:
Examples
>>> session = {"session_id": "abc123", "logged_in": True} >>> result = send_command("look", session) >>> isinstance(result, str) True
- mud_server.admin_gradio.tabs.game_tab.refresh_display(session_state)[source]
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.
- Parameters:
session_state (dict) – User’s session state dictionary containing session_id
- Returns:
Tuple of (room_description, chat_messages) both as strings
- Return type:
Examples
>>> session = {"session_id": "abc123", "logged_in": True} >>> room, chat = refresh_display(session) >>> isinstance(room, str) and isinstance(chat, str) True
- mud_server.admin_gradio.tabs.game_tab.get_status(session_state)[source]
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.
- Parameters:
session_state (dict) – User’s session state dictionary containing session_id, username, role
- Returns:
Formatted status string
- Return type:
Examples
>>> session = {"session_id": "abc123", "username": "alice", "role": "player", "logged_in": True} >>> result = get_status(session) >>> isinstance(result, str) True
- mud_server.admin_gradio.tabs.game_tab.logout(session_state)[source]
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.
- Parameters:
session_state (dict) – 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
- Return type:
Examples
>>> session = {"session_id": "abc123", "logged_in": True} >>> result = logout(session) >>> isinstance(result, tuple) and len(result) >= 2 True