# Interface UiRenderer

All Known Implementing Classes:
  `GuiRenderer`, `TuiRenderer`

public interface UiRenderer
This interface defines the methods for any User Interface (UI) in the application. It provides methods for displaying various game elements, handling game phases, and managing user interactions and notifications.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `customCardPrintMyTurn(int turnType)`
  Prints a custom message related to a card when it's the current player's turn.
  `void`
  `customCardPrintNotMyTurn(String currentPlayer)`
  Prints a custom message related to a card when it's not the current player's turn.
  `void`
  `drawShip(Ship ship)`
  Renders a ship on the UI.
  `void`
  `effectResolution()`
  Displays effect resolution information.
  `void`
  `endAssemblingPhase()`
  Ends the assembling phase in the UI.
  `void`
  `handleConnectionResponse(ConnectionResponse response)`
  Handles and displays the response received after a connection attempt.
  `void`
  `handleUpdateMessage(UpdateMessage msg)`
  Handles and processes an update message received from the server.
  `void`
  `newLeader(boolean isNewLeader)`
  Notifies the UI if the current player has become the new leader.
  `void`
  `newPlayerJoined(String nickname)`
  Notifies the UI that a new player has joined the game.
  `void`
  `notifyDefeat(int loseType)`
  Notifies the user of a defeat, specifying the type of loss.
  `void`
  `onError(String message)`
  Displays an error message to the user.
  `void`
  `onInfo(String message)`
  Displays a general informational message to the user.
  `void`
  `printPromptSymbol()`
  Prints the prompt symbol in the UI, indicating readiness for user input.
  `void`
  `reportException(Exception e)`
  Reports an exception to the user interface.
  `void`
  `roundResult(boolean roundWon)`
  Displays the result of a game round, indicating whether it was won or lost.
  `void`
  `runUi(VirtualView client, VirtualServer server, ClientModel clientModel)`
  Starts and runs the UI.
  `void`
  `setNickname()`
  Prompts the user to set their nickname.
  `void`
  `setUUID(UUID clientId)`
  Sets the ID for the client in the UI.
  `void`
  `showCard(Card card)`
  Displays a specific game card to the user.
  `void`
  `showDiceResult(int diceResult)`
  Displays the result of a dice roll to the user.
  `void`
  `showFaceUpComponentList(List<Component> componentList)`
  Displays a list of face-up components available in the game.
  `void`
  `showFinalRanking(Map<Player,Integer> ranking)`
  Displays the final ranking of players at the end of the game.
  `void`
  `showGameList(List<Integer> gameList)`
  Displays a list of available games that the user can join.
  `void`
  `showPlayersList(List<String> players)`
  Displays the list of players currently in the game.
  `void`
  `showRocketsPosition(List<Player> players, int level)`
  Shows the current positions of rockets for all players.
  `void`
  `showsDrawnComponent(Component component)`
  Displays a newly drawn game component to the user.
  `void`
  `showSecondsLeft(int count, int secondsLeft)`
  Shows a countdown of seconds left.
  `void`
  `showSecondsLeftForGui(int count, int secondsLeft)`
  Shows a countdown of seconds left, specifically for GUI updates.
  `void`
  `showSubDeck(List<Card> subDeck)`
  Displays a sub-deck of cards to the user.
  `void`
  `startAssemblingPhase()`
  Starts and displays the assembling phase in the UI.
  `void`
  `startCrewPlacingPhase(Ship ship, Map<Integer,Integer> positions)`
  Displays the crew placing phase information.
  `void`
  `startFlightPhase(Ship ship, Map<Integer,Integer> positions)`
  Displays the flight phase information.

- ## Method Details

  - ### runUi

    void runUi(VirtualView client, VirtualServer server, ClientModel clientModel)
    Starts and runs the UI.
    Parameters:
      `client` - The virtual view representing the client.
      `server` - The virtual server representing the server.
      `clientModel` - The client-side model containing the current state of the game for this client.

  - ### showsDrawnComponent

    void showsDrawnComponent(Component component)
    Displays a newly drawn game component to the user.
    Parameters:
      `component` - The component that was drawn.

  - ### showFaceUpComponentList

    void showFaceUpComponentList(List<Component> componentList)
    Displays a list of face-up components available in the game.
    Parameters:
      `componentList` - A list of components to be displayed.

  - ### drawShip

    void drawShip(Ship ship) throws Exception
    Renders a ship on the UI.
    Parameters:
      `ship` - The ship to be drawn.
    Throws:
      `Exception` - if an error occurs during drawing the ship.

  - ### showRocketsPosition

    void showRocketsPosition(List<Player> players, int level)
    Shows the current positions of rockets for all players.
    Parameters:
      `players` - The list of players in the game.
      `level` - The current level of the game.

  - ### showCard

    void showCard(Card card)
    Displays a specific game card to the user.
    Parameters:
      `card` - The card to be displayed.

  - ### startFlightPhase

    void startFlightPhase(Ship ship, Map<Integer,Integer> positions) throws Exception
    Displays the flight phase information.
    Parameters:
      `ship` - The player's ship.
      `positions` - Updated positions of the player's rockets on the game board, received from the server.
    Throws:
      `Exception`

  - ### startCrewPlacingPhase

    void startCrewPlacingPhase(Ship ship, Map<Integer,Integer> positions)
    Displays the crew placing phase information.
    Parameters:
      `ship` - The ship for which crew is being placed.
      `positions` - A map indicating possible positions for placing crew members.

  - ### endAssemblingPhase

    void endAssemblingPhase()
    Ends the assembling phase in the UI.

  - ### startAssemblingPhase

    void startAssemblingPhase()
    Starts and displays the assembling phase in the UI.

  - ### showFinalRanking

    void showFinalRanking(Map<Player,Integer> ranking)
    Displays the final ranking of players at the end of the game.
    Parameters:
      `ranking` - A map where keys are players and values are their final scores.

  - ### notifyDefeat

    void notifyDefeat(int loseType)
    Notifies the user of a defeat, specifying the type of loss.
    Parameters:
      `loseType` - An integer representing the type of defeat.

  - ### customCardPrintMyTurn

    void customCardPrintMyTurn(int turnType)
    Prints a custom message related to a card when it's the current player's turn.
    Parameters:
      `turnType` - An integer representing the type of turn or card action.

  - ### customCardPrintNotMyTurn

    void customCardPrintNotMyTurn(String currentPlayer)
    Prints a custom message related to a card when it's not the current player's turn.
    Parameters:
      `currentPlayer` - The nickname of the player whose turn it currently is.

  - ### reportException

    void reportException(Exception e)
    Reports an exception to the user interface.
    Parameters:
      `e` - The exception to be reported.

  - ### handleConnectionResponse

    void handleConnectionResponse(ConnectionResponse response)
    Handles and displays the response received after a connection attempt.
    Parameters:
      `response` - The connection response to be handled.

  - ### showPlayersList

    void showPlayersList(List<String> players)
    Displays the list of players currently in the game.
    Parameters:
      `players` - A list of player nicknames.

  - ### newPlayerJoined

    void newPlayerJoined(String nickname)
    Notifies the UI that a new player has joined the game.
    Parameters:
      `nickname` - The nickname of the player who joined.

  - ### showDiceResult

    void showDiceResult(int diceResult)
    Displays the result of a dice roll to the user.
    Parameters:
      `diceResult` - The integer result of the dice roll.

  - ### roundResult

    void roundResult(boolean roundWon)
    Displays the result of a game round, indicating whether it was won or lost.
    Parameters:
      `roundWon` - A boolean indicating if the round was won (true) or lost (false).

  - ### newLeader

    void newLeader(boolean isNewLeader)
    Notifies the UI if the current player has become the new leader.
    Parameters:
      `isNewLeader` - A boolean indicating if the current player is the new leader.

  - ### onInfo

    void onInfo(String message)
    Displays a general informational message to the user.
    Parameters:
      `message` - The informational message to display.

  - ### onError

    void onError(String message) throws InterruptedException
    Displays an error message to the user.
    Parameters:
      `message` - The error message to display.
    Throws:
      `InterruptedException` - if the thread is interrupted while waiting for an error display.

  - ### setNickname

    void setNickname()
    Prompts the user to set their nickname.

  - ### showSecondsLeftForGui

    void showSecondsLeftForGui(int count, int secondsLeft)
    Shows a countdown of seconds left, specifically for GUI updates.
    Parameters:
      `count` - The current hourglass number.
      `secondsLeft` - The total seconds left.

  - ### showSubDeck

    void showSubDeck(List<Card> subDeck)
    Displays a sub-deck of cards to the user.
    Parameters:
      `subDeck` - A list of cards representing the sub-deck.

  - ### handleUpdateMessage

    void handleUpdateMessage(UpdateMessage msg)
    Handles and processes an update message received from the server.
    Parameters:
      `msg` - The update message to be handled.

  - ### printPromptSymbol

    void printPromptSymbol() throws InterruptedException
    Prints the prompt symbol in the UI, indicating readiness for user input.
    Throws:
      `InterruptedException` - if the thread is interrupted while printing the prompt symbol.

  - ### setUUID

    void setUUID(UUID clientId) throws InterruptedException
    Sets the ID for the client in the UI.
    Parameters:
      `clientId` - The UUID to be set.
    Throws:
      `InterruptedException` - if the thread is interrupted while setting the UUID.

  - ### effectResolution

    void effectResolution()
    Displays effect resolution information.

  - ### showSecondsLeft

    void showSecondsLeft(int count, int secondsLeft)
    Shows a countdown of seconds left.
    Parameters:
      `count` - The current hourglass number.
      `secondsLeft` - The total seconds left.

  - ### showGameList

    void showGameList(List<Integer> gameList)
    Displays a list of available games that the user can join.
    Parameters:
      `gameList` - A list of game IDs.