# Interface VirtualView

All Superinterfaces:
  `Remote`

All Known Implementing Classes:
  `RmiClient`, `SocketClient`, `SocketClientHandler`

public interface VirtualView extends Remote
This interface defines the methods for client-side display and input operations that can be remotely invoked by the server. It represents a generic view accessible by the server, allowing different underlying communication technologies (RMI, Socket) to implement it.

Methods declared in this interface are expected to throw `Exception` to signal any issues that prevent the successful completion of the operation. These exceptions can arise from low-level network communication failures or from application-level logical errors encountered during the display or processing of the information on the client.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `connectionResponse(ConnectionResponse connectionResponse)`
  Handles a connection response from the server, indicating the outcome of a connection attempt or a change in connection status.
  `void`
  `connectionTest()`
  Performs a connection test.
  `void`
  `crewPlacingPhase(Ship ship, Map<Integer,Integer> positions)`
  Starts the crew placing phase for the client, providing the client's updated ship and current rocket positions.
  `void`
  `diceResult(int diceResult)`
  Displays the result of a dice roll to the client.
  `void`
  `effectResolution()`
  Starts the effect resolution phase on the client's side.
  `void`
  `finishFinalHourglass()`
  Notifies the client that the final hourglass timer has finished.
  `void`
  `lockClient()`
  Locks the client's UI, preventing user input.
  `void`
  `newLeader(boolean isNewLeader)`
  Notifies the client if they have become the new leader of the game.
  `void`
  `notifyDefeat(int loseType)`
  Notifies the client of a defeat in the game, along with the reason.
  `void`
  `playerJoined(String newPlayer, List<String> players)`
  Notifies the client that a new player has joined the game and provides the updated list of all current players.
  `void`
  `roundResult(boolean roundWon)`
  Notifies the client whether the current round was won or lost.
  `void`
  `setGameLevel(int level)`
  Sets the current game level on the client's view.
  `void`
  `setNickname()`
  Prompts the client to set their nickname.
  `void`
  `setUUID(UUID clientId)`
  Sets the unique identifier (UUID) for the client.
  `void`
  `showCard(Card card)`
  Displays a drawn card to the client.
  `void`
  `showComponent(Component component)`
  Displays a drawn component to the client.
  `void`
  `showFaceUpComponentList(List<Component> components)`
  Displays the current list of face-up components available on the gameboard to the client.
  `void`
  `showFinalRanking(Map<Player,Integer> ranking)`
  Displays the final ranking of players at the end of the game.
  `void`
  `showGameList(List<Integer> gameList)`
  Displays the list of available games that the client can join or observe.
  `void`
  `showSecondsLeft(int count, int secondsLeft)`
  Displays a countdown of seconds left.
  `void`
  `showSecondsLeftForGui(int counter, int secondsLeft)`
  Displays a countdown of seconds left specifically for GUI updates.
  `void`
  `showShip(Ship ship)`
  Displays a ship to the client.
  `void`
  `showSubDeck(List<Card> subDeck)`
  Displays a sub-deck of cards to the client.
  `void`
  `showUpdate(UpdateMessage msg)`
  Displays an update message received from the server to the client's UI.
  `void`
  `startAssemblingPhase(List<Player> players, int level)`
  Initiates the assembling phase for the client, providing the initial list of players and the game level.
  `void`
  `startFlightPhase(Ship ship, Map<Integer,Integer> positions)`
  Starts the flight phase for the client, providing the client's updated ship and the current rocket positions.
  `void`
  `startGame()`
  Notifies the client that the game has started.
  `void`
  `turnChange(boolean isMyTurn, int turnType, int currentPlayer)`
  Notifies the client about a turn change, indicating if it's their turn, the type of turn, and the index of the current player.
  `void`
  `updatePositions(Map<Integer,Integer> positions)`
  Updates the positions of players' rockets on the client's game board display.

- ## Method Details

  - ### showUpdate

    void showUpdate(UpdateMessage msg) throws Exception
    Displays an update message received from the server to the client's UI.
    Parameters:
      `msg` - The `UpdateMessage` to display.
    Throws:
      `Exception`

  - ### showCard

    void showCard(Card card) throws Exception
    Displays a drawn card to the client. This occurs when a player draws a card from a deck.
    Parameters:
      `card` - The `Card` to display.
    Throws:
      `Exception`

  - ### showComponent

    void showComponent(Component component) throws Exception
    Displays a drawn component to the client.
    Parameters:
      `component` - The `Component` object to display.
    Throws:
      `Exception`

  - ### startGame

    void startGame() throws Exception
    Notifies the client that the game has started.
    Throws:
      `Exception`

  - ### lockClient

    void lockClient() throws Exception
    Locks the client's UI, preventing user input.
    Throws:
      `Exception`

  - ### setNickname

    void setNickname() throws Exception
    Prompts the client to set their nickname.
    Throws:
      `Exception`

  - ### startAssemblingPhase

    void startAssemblingPhase(List<Player> players, int level) throws Exception
    Initiates the assembling phase for the client, providing the initial list of players and the game level.
    Parameters:
      `players` - The list of `Player` objects currently in the game.
      `level` - The current game level.
    Throws:
      `Exception`

  - ### showShip

    void showShip(Ship ship) throws Exception
    Displays a ship to the client. This can be the client's own ship or an opponent's ship.
    Parameters:
      `ship` - The `Ship` object to display.
    Throws:
      `Exception`

  - ### showFaceUpComponentList

    void showFaceUpComponentList(List<Component> components) throws Exception
    Displays the current list of face-up components available on the gameboard to the client.
    Parameters:
      `components` - The list of components that are currently face-up.
    Throws:
      `Exception`

  - ### updatePositions

    void updatePositions(Map<Integer,Integer> positions) throws Exception
    Updates the positions of players' rockets on the client's game board display.
    Parameters:
      `positions` - A map where keys are player IDs and values are their updated rocket positions.
    Throws:
      `Exception`

  - ### effectResolution

    void effectResolution() throws Exception
    Starts the effect resolution phase on the client's side.
    Throws:
      `Exception`

  - ### startFlightPhase

    void startFlightPhase(Ship ship, Map<Integer,Integer> positions) throws Exception
    Starts the flight phase for the client, providing the client's updated ship and the current rocket positions.
    Parameters:
      `ship` - The client's `Ship`.
      `positions` - A map of player IDs to their rocket positions.
    Throws:
      `Exception`

  - ### showSubDeck

    void showSubDeck(List<Card> subDeck) throws Exception
    Displays a sub-deck of cards to the client.
    Parameters:
      `subDeck` - The list of `Card` objects in the sub-deck.
    Throws:
      `Exception`

  - ### connectionTest

    void connectionTest() throws Exception
    Performs a connection test.
    Throws:
      `Exception`

  - ### crewPlacingPhase

    void crewPlacingPhase(Ship ship, Map<Integer,Integer> positions) throws Exception
    Starts the crew placing phase for the client, providing the client's updated ship and current rocket positions.
    Parameters:
      `ship` - The client's `Ship` object.
      `positions` - A map of player IDs to their rocket positions.
    Throws:
      `Exception`

  - ### showSecondsLeft

    void showSecondsLeft(int count, int secondsLeft) throws Exception
    Displays a countdown of seconds left.
    Parameters:
      `count` - The current hourglass number.
      `secondsLeft` - The total number of seconds remaining.
    Throws:
      `Exception`

  - ### finishFinalHourglass

    void finishFinalHourglass() throws Exception
    Notifies the client that the final hourglass timer has finished.
    Throws:
      `Exception`

  - ### showSecondsLeftForGui

    void showSecondsLeftForGui(int counter, int secondsLeft) throws Exception
    Displays a countdown of seconds left specifically for GUI updates.
    Parameters:
      `counter` - The current hourglass number.
      `secondsLeft` - The total seconds remaining.
    Throws:
      `Exception`

  - ### showFinalRanking

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

  - ### notifyDefeat

    void notifyDefeat(int loseType) throws Exception
    Notifies the client of a defeat in the game, along with the reason.
    Parameters:
      `loseType` - An integer indicating the type of defeat.
    Throws:
      `Exception`

  - ### setGameLevel

    void setGameLevel(int level) throws Exception
    Sets the current game level on the client's view.
    Parameters:
      `level` - The game level to set.
    Throws:
      `Exception`

  - ### setUUID

    void setUUID(UUID clientId) throws Exception
    Sets the unique identifier (UUID) for the client.
    Parameters:
      `clientId` - The `UUID` to set for the client.
    Throws:
      `Exception`

  - ### connectionResponse

    void connectionResponse(ConnectionResponse connectionResponse) throws Exception
    Handles a connection response from the server, indicating the outcome of a connection attempt or a change in connection status.
    Parameters:
      `connectionResponse` - The `ConnectionResponse` enum received from the server.
    Throws:
      `Exception`

  - ### playerJoined

    void playerJoined(String newPlayer, List<String> players) throws Exception
    Notifies the client that a new player has joined the game and provides the updated list of all current players.
    Parameters:
      `newPlayer` - The nickname of the new player who joined.
      `players` - The updated list of all player nicknames in the game.
    Throws:
      `Exception`

  - ### newLeader

    void newLeader(boolean isNewLeader) throws Exception
    Notifies the client if they have become the new leader of the game.
    Parameters:
      `isNewLeader` - True if the client is the new leader, false otherwise.
    Throws:
      `Exception`

  - ### diceResult

    void diceResult(int diceResult) throws Exception
    Displays the result of a dice roll to the client.
    Parameters:
      `diceResult` - The integer result of the dice roll.
    Throws:
      `Exception`

  - ### roundResult

    void roundResult(boolean roundWon) throws Exception
    Notifies the client whether the current round was won or lost.
    Parameters:
      `roundWon` - True if the round was won, false if lost.
    Throws:
      `Exception`

  - ### turnChange

    void turnChange(boolean isMyTurn, int turnType, int currentPlayer) throws Exception
    Notifies the client about a turn change, indicating if it's their turn, the type of turn, and the index of the current player.
    Parameters:
      `isMyTurn` - True if it's the client's turn, false otherwise.
      `turnType` - An integer representing the specific type or phase of the turn.
      `currentPlayer` - The index of the current player in the game's player list.
    Throws:
      `Exception`

  - ### showGameList

    void showGameList(List<Integer> gameList) throws Exception
    Displays the list of available games that the client can join or observe.
    Parameters:
      `gameList` - A list of integers representing the IDs of available games.
    Throws:
      `Exception`