games.clue.ui¶

Clue rich UI visualization module.

This module provides a visually appealing terminal UI for Clue games, with styled components, animations, and comprehensive game information.

It uses the Rich library to create a console-based UI with:
  • Game board visualization with players, suspects, weapons, and rooms

  • Guess history with detailed responses

  • Player cards and deduction notes

  • Game status and information

  • Thinking animations and guess visualization

Example

>>> from haive.games.clue.ui import ClueUI
>>> from haive.games.clue.state import ClueState
>>>
>>> ui = ClueUI()
>>> state = ClueState.initialize()
>>> ui.display_state(state)  # Display the initial game state
>>>
>>> # Show thinking animation for player
>>> ui.show_thinking("player1")
>>>
>>> # Display a guess
>>> from haive.games.clue.models import ClueGuess, ValidSuspect, ValidWeapon, ValidRoom
>>> guess = ClueGuess(
>>>     suspect=ValidSuspect.COLONEL_MUSTARD,
>>>     weapon=ValidWeapon.KNIFE,
>>>     room=ValidRoom.KITCHEN
>>> )
>>> ui.show_guess(guess, "player1")

Classes¶

ClueUI

Rich UI for beautiful Clue game visualization.

Module Contents¶

class games.clue.ui.ClueUI¶

Rich UI for beautiful Clue game visualization.

This class provides a visually appealing terminal UI for Clue games, with styled components, animations, and comprehensive game information.

Features:
  • Game board visualization with suspects, weapons, and rooms

  • Guess history with detailed responses

  • Player cards and deduction notes

  • Game status and information

  • Thinking animations and guess visualization

console¶

Rich console for output

Type:

Console

layout¶

Layout manager for UI components

Type:

Layout

colors¶

Color schemes for different UI elements

Type:

dict

Examples

>>> ui = ClueUI()
>>> state = ClueState.initialize()
>>> ui.display_state(state)  # Display the initial game state

Initialize the Clue UI with default settings.

display_state(state)¶

Display the current game state with rich formatting.

Renders the complete game state including suspects, weapons, rooms, guess history, player cards, and game information in a formatted layout.

Parameters:

state (Union[ClueState, Dict[str, Any]]) – Current game state

Returns:

None

Return type:

None

Example

>>> ui = ClueUI()
>>> state = ClueState.initialize()
>>> ui.display_state(state)
show_game_over(state)¶

Display game over message with result.

Shows a game over panel with the winner highlighted in their color, and reveals the solution.

Parameters:

state (ClueState) – Final game state

Returns:

None

Return type:

None

Example

>>> ui = ClueUI()
>>> state = ClueState.initialize()
>>> state.game_status = "player1_win"
>>> state.winner = "player1"
>>> ui.show_game_over(state)
show_guess(guess, player)¶

Display a guess being made.

Shows a formatted message indicating which player made a guess, including the suspect, weapon, and room.

Parameters:
  • guess (ClueGuess) – The guess being made

  • player (str) – Player making the guess (“player1” or “player2”)

Returns:

None

Return type:

None

Example

>>> ui = ClueUI()
>>> guess = ClueGuess(
...     suspect=ValidSuspect.COLONEL_MUSTARD,
...     weapon=ValidWeapon.KNIFE,
...     room=ValidRoom.KITCHEN
... )
>>> ui.show_guess(guess, "player1")
show_response(response, player)¶

Display a response to a guess.

Shows a formatted message indicating the response to a guess, including which player responded and what card was shown.

Parameters:
  • response (ClueResponse) – The response to the guess

  • player (str) – Player who made the guess (“player1” or “player2”)

Returns:

None

Return type:

None

Example

>>> ui = ClueUI()
>>> response = ClueResponse(
...     is_correct=False,
...     responding_player="player2",
...     refuting_card=ClueCard(name="Knife", card_type=CardType.WEAPON)
... )
>>> ui.show_response(response, "player1")
show_thinking(player, message='Thinking...')¶

Display a thinking animation for the current player.

Shows a spinner animation with player-colored text to indicate that the player is thinking about their guess.

Parameters:
  • player (str) – Current player (“player1” or “player2”)

  • message (str, optional) – Custom message to display. Defaults to “Thinking…”.

Returns:

None

Return type:

None

Example

>>> ui = ClueUI()
>>> ui.show_thinking("player1", "Analyzing clues...")