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_command(command, session_state)

Send a game command to the backend for execution.

refresh_display(session_state)

Refresh both room and chat displays by fetching current data.

get_status(session_state)

Retrieve and format player status information.

logout(session_state)

Handle user logout and return result tuple for Gradio.

create(session_state)

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:
  • command (str) – Command string to execute

  • session_state (dict) – User’s session state dictionary containing session_id

Returns:

Command result string or error message

Return type:

str

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:

tuple[str, str]

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:

str

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:

tuple

Examples

>>> session = {"session_id": "abc123", "logged_in": True}
>>> result = logout(session)
>>> isinstance(result, tuple) and len(result) >= 2
True
mud_server.admin_gradio.tabs.game_tab.create(session_state)[source]

Create the Game tab with full gameplay interface.

Parameters:

session_state – Gradio State component for session tracking

Returns:

(game_tab, logout_btn) - Tab component and logout button for top-level event wiring

Return type:

tuple