Class ClientView

java.lang.Object
it.polimi.ingsw.Client.CLI.ClientView

public class ClientView extends Object
This class contains the status of Client inside the Server and is responsible for printing UI elements in to the CLI
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Used to contain lobby's admin's nickname
    private boolean
    Used to verify whether the Game has ended
    private boolean
    Used to verify whether the Game has started
    private boolean
    Used to verify whether the client is connected to the Server
    private boolean
    Used to verify whether the client has entered a lobby
    private boolean
    Used to verify whether the client is logged to the Server
    private Model
    Used to contain the game
    private String
    Used to contain client's nickname
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Method to disconnect the view from lobby (when the game ends or is closed for any reason)
    void
     
    Get lobby's admin's nickname
    boolean
    Get whether the game has started or not
    Get current game
    get Client's nickname
    boolean
    Get whether the client has connected to the Server or not
    boolean
    Get whether the game has ended or not
    boolean
    Get whether the client has connected to a lobby or not
    boolean
    Get whether the client has logged to the Server or not
    private void
    Support method responsible for printing the 3 characterCards
    private void
    Support method responsible for printing all players' PlayerBoards
    private void
    Support method responsible for printing all field's components (islands and clouds)
    void
    Prints all gameBoard's element that the user is allowed to see (Islands, clouds, playerBoards and characterCards)
    void
    Set Game's admin's nickname
    void
    setConnected(boolean connected)
    Set Client's connection status(connected or not)
    void
    setGame(Model game)
    Set game's model
    void
    setGameEnded(boolean gameEnded)
    Set Game's status (ended or not)
    void
    setGameStarted(boolean started)
    Set Game's status (started or not)
    void
    setIsInLobby(boolean inLobby)
    Set Client's status inside a lobby (connected to a lobby or not)
    void
    setLogged(boolean logged)
    Set Client's logged status inside the server (logged or not)
    void
    setNickname(String nickname)
    Set Client's nickname

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • model

      private Model model
      Used to contain the game
    • isConnected

      private boolean isConnected
      Used to verify whether the client is connected to the Server
    • isLogged

      private boolean isLogged
      Used to verify whether the client is logged to the Server
    • isInLobby

      private boolean isInLobby
      Used to verify whether the client has entered a lobby
    • gameStarted

      private boolean gameStarted
      Used to verify whether the Game has started
    • gameEnded

      private boolean gameEnded
      Used to verify whether the Game has ended
    • admin

      private String admin
      Used to contain lobby's admin's nickname
    • Nickname

      private String Nickname
      Used to contain client's nickname
  • Constructor Details

    • ClientView

      public ClientView()
  • Method Details

    • getAdmin

      public String getAdmin()
      Get lobby's admin's nickname
      Returns:
      admin's nickname
    • setAdmin

      public void setAdmin(String admin)
      Set Game's admin's nickname
      Parameters:
      admin - String containing admin's nickname
    • getModel

      public Model getModel()
      Get current game
      Returns:
      gameBoard representing the game
    • getGameStarted

      public boolean getGameStarted()
      Get whether the game has started or not
      Returns:
      true if the game has started, false otherwise
    • setGameStarted

      public void setGameStarted(boolean started)
      Set Game's status (started or not)
      Parameters:
      started - boolean representing whether the game has started or not
    • isGameEnded

      public boolean isGameEnded()
      Get whether the game has ended or not
      Returns:
      true if the game has ended, false otherwise
    • setGameEnded

      public void setGameEnded(boolean gameEnded)
      Set Game's status (ended or not)
      Parameters:
      gameEnded - boolean representing whether the game has ended or not
    • isInLobby

      public boolean isInLobby()
      Get whether the client has connected to a lobby or not
      Returns:
      true if the client has connected to a lobby, false otherwise
    • isConnected

      public boolean isConnected()
      Get whether the client has connected to the Server or not
      Returns:
      true if the client has connected to the Server, false otherwise
    • setConnected

      public void setConnected(boolean connected)
      Set Client's connection status(connected or not)
      Parameters:
      connected - boolean representing whether the client has connected or not to the server
    • isLogged

      public boolean isLogged()
      Get whether the client has logged to the Server or not
      Returns:
      true if the client has logged to the Server, false otherwise
    • setLogged

      public void setLogged(boolean logged)
      Set Client's logged status inside the server (logged or not)
      Parameters:
      logged - boolean representing whether the client is logged or not
    • printView

      public void printView()
      Prints all gameBoard's element that the user is allowed to see (Islands, clouds, playerBoards and characterCards)
    • printIslandField

      private void printIslandField()
      Support method responsible for printing all field's components (islands and clouds)
    • printGameBoards

      private void printGameBoards()
      Support method responsible for printing all players' PlayerBoards
    • printCharacterCard

      private void printCharacterCard()
      Support method responsible for printing the 3 characterCards
    • getNickname

      public String getNickname()
      get Client's nickname
      Returns:
      String containing the nickname
    • setNickname

      public void setNickname(String nickname)
      Set Client's nickname
      Parameters:
      nickname - String containing Client's nickname
    • disconnectViewFromServer

      public void disconnectViewFromServer()
    • disconnectView

      public void disconnectView()
      Method to disconnect the view from lobby (when the game ends or is closed for any reason)
    • setIsInLobby

      public void setIsInLobby(boolean inLobby)
      Set Client's status inside a lobby (connected to a lobby or not)
      Parameters:
      inLobby - boolean representing whether the client is in lobby or not
    • setGame

      public void setGame(Model game)
      Set game's model
      Parameters:
      game - GameBoard containing game's model