Module AM37

Class Printer

java.lang.Object
it.polimi.ingsw.view.cli.console.printers.Printer
Direct Known Subclasses:
BasicPrinter, FancyPrinter

public abstract class Printer
extends java.lang.Object
Console Printing Utilities
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected BoardUtils boardUtils  
    protected CLI cli
    The UI which created the printer
    protected Console console  
    protected PrintableObject mainLogo  
    protected java.util.Properties properties  
    static int SCENE_HEIGHT  
    static int SCENE_WIDTH  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected Printer​(CLI cli, Console console)
    Default constructor
  • Method Summary

    Modifier and Type Method Description
    abstract void askIp()
    Asks the user to insert the server address
    abstract void askLobbyName()
    Asks the user to choose a name for the lobby to be created
    abstract void askLobbySize()
    Asks the user to choose the lobby size
    abstract void askToReloadSettings()
    Asks the user if it wants to reload a previously saved address/username combo
    abstract void askUsername()
    Asks the user to insert its username
    abstract void buildAction​(java.util.List<Cell> gameBoard, java.util.List<Cell> buildableCells)
    Asks the user to select a cell to build on
    abstract void chooseAction​(java.util.List<PossibleActions> possibleActions)
    Asks the user which action to perform
    abstract void chooseBlockToBuild​(java.util.List<Block> buildableBlocks)
    Asks the user which block to build on a cell
    abstract void chooseGameGods​(java.util.List<GodData> allGods, int size)
    Asks the user to choose the gods for the game
    abstract void chooseLobbyToJoin​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> lobbiesAvailable)
    Asks the user which lobby to join
    abstract void chooseStartingPlayer​(java.util.List<java.lang.String> players)
    Asks the user which player will play first
    abstract void chooseToReloadMatch()
    Asks the user if it wants to reload an existing saved match
    abstract void chooseUserGod​(java.util.List<GodData> possibleGods)
    Asks the user to choose its personal god for the game
    abstract void chooseWorker​(java.util.List<Cell> cells)
    Asks the user to pick a worker
    Console getConsole()
    console getter
    protected void highlightWorkers​(java.util.List<Cell> cells)
    Highlights the user's workers
    abstract void lobbyOptions​(java.util.List<java.lang.String> options)
    Asks the user to choose whether to join or create a lobby
    abstract void moveAction​(java.util.List<Cell> gameBoard, java.util.List<Cell> walkableCells)
    Asks the user to select a cell to move its current worker to
    abstract void placeWorker()
    Asks the user to place its worker on the board
    abstract void printError​(java.lang.String errorMsg)
    Shows an error message
    abstract void printMessage​(java.lang.String msg)
    Shows a success message
    abstract void printStartingScreen()
    Shows the logo
    protected abstract BoardUtils setBoardUtils()
    Creates a BoardUtils object, based on the printer calling it
    void showGameBoard​(java.util.List<Cell> gameBoard)
    Prints the game board on the screen
    void showGameBoard​(java.util.List<Cell> gameBoard, java.util.List<Cell> toHighlight)
    Prints the game board on the screen
    abstract void showSavedSettings​(java.util.List<java.lang.String> options)
    Shows the user the saved address/username combos
    abstract void updateGameData​(java.util.List<Cell> board, java.util.List<PlayerData> players)
    Updates information about the game and the players

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • Printer

      protected Printer​(CLI cli, Console console) throws java.io.IOException
      Default constructor
      Parameters:
      cli - the view which created the printer
      console - the Console object containing this
      Throws:
      java.io.IOException
  • Method Details

    • getConsole

      public Console getConsole()
      console getter
      Returns:
      the console which spawned this
    • printError

      public abstract void printError​(java.lang.String errorMsg)
      Shows an error message
      Parameters:
      errorMsg - the error message
    • printMessage

      public abstract void printMessage​(java.lang.String msg)
      Shows a success message
      Parameters:
      msg - the message
    • printStartingScreen

      public abstract void printStartingScreen()
      Shows the logo
    • askToReloadSettings

      public abstract void askToReloadSettings()
      Asks the user if it wants to reload a previously saved address/username combo
    • showSavedSettings

      public abstract void showSavedSettings​(java.util.List<java.lang.String> options)
      Shows the user the saved address/username combos
      Parameters:
      options - the address/username combos
    • askIp

      public abstract void askIp()
      Asks the user to insert the server address
    • askUsername

      public abstract void askUsername()
      Asks the user to insert its username
    • lobbyOptions

      public abstract void lobbyOptions​(java.util.List<java.lang.String> options)
      Asks the user to choose whether to join or create a lobby
      Parameters:
      options - a list of possible options
    • askLobbyName

      public abstract void askLobbyName()
      Asks the user to choose a name for the lobby to be created
    • askLobbySize

      public abstract void askLobbySize()
      Asks the user to choose the lobby size
    • chooseLobbyToJoin

      public abstract void chooseLobbyToJoin​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> lobbiesAvailable)
      Asks the user which lobby to join
      Parameters:
      lobbiesAvailable - a map containing the lobbies available and their relative information
    • chooseToReloadMatch

      public abstract void chooseToReloadMatch()
      Asks the user if it wants to reload an existing saved match
    • chooseGameGods

      public abstract void chooseGameGods​(java.util.List<GodData> allGods, int size)
      Asks the user to choose the gods for the game
      Parameters:
      allGods - the list of available gods
      size - the number of players
    • chooseUserGod

      public abstract void chooseUserGod​(java.util.List<GodData> possibleGods)
      Asks the user to choose its personal god for the game
      Parameters:
      possibleGods - a list containing the available gods
    • chooseStartingPlayer

      public abstract void chooseStartingPlayer​(java.util.List<java.lang.String> players)
      Asks the user which player will play first
      Parameters:
      players - the players in game
    • showGameBoard

      public void showGameBoard​(java.util.List<Cell> gameBoard)
      Prints the game board on the screen
      Parameters:
      gameBoard - the board to print
    • setBoardUtils

      protected abstract BoardUtils setBoardUtils()
      Creates a BoardUtils object, based on the printer calling it
      Returns:
      a boardUtils object
    • updateGameData

      public abstract void updateGameData​(java.util.List<Cell> board, java.util.List<PlayerData> players)
      Updates information about the game and the players
      Parameters:
      board - the game board
      players - information about the players
    • showGameBoard

      public void showGameBoard​(java.util.List<Cell> gameBoard, java.util.List<Cell> toHighlight)
      Prints the game board on the screen
      Parameters:
      gameBoard - the board to print
    • placeWorker

      public abstract void placeWorker()
      Asks the user to place its worker on the board
    • chooseWorker

      public abstract void chooseWorker​(java.util.List<Cell> cells)
      Asks the user to pick a worker
      Parameters:
      cells - the cells containing the player's workers
    • highlightWorkers

      protected void highlightWorkers​(java.util.List<Cell> cells)
      Highlights the user's workers
      Parameters:
      cells - the cells containing the user's workers
    • chooseAction

      public abstract void chooseAction​(java.util.List<PossibleActions> possibleActions)
      Asks the user which action to perform
      Parameters:
      possibleActions - a list of possible actions
    • moveAction

      public abstract void moveAction​(java.util.List<Cell> gameBoard, java.util.List<Cell> walkableCells)
      Asks the user to select a cell to move its current worker to
      Parameters:
      gameBoard - the current game board
      walkableCells - the cells on which the worker can be moved to
    • buildAction

      public abstract void buildAction​(java.util.List<Cell> gameBoard, java.util.List<Cell> buildableCells)
      Asks the user to select a cell to build on
      Parameters:
      gameBoard - the current game board
      buildableCells - the cells on which the worker can build
    • chooseBlockToBuild

      public abstract void chooseBlockToBuild​(java.util.List<Block> buildableBlocks)
      Asks the user which block to build on a cell
      Parameters:
      buildableBlocks - the possible blocks (always more than one)