Module AM37

Class BasicPrinter

java.lang.Object
it.polimi.ingsw.view.cli.console.printers.Printer
it.polimi.ingsw.view.cli.console.printers.basicPrinter.BasicPrinter

public class BasicPrinter
extends Printer
  • Field Summary

    Fields inherited from class it.polimi.ingsw.view.cli.console.printers.Printer

    boardUtils, cli, console, mainLogo, properties, SCENE_HEIGHT, SCENE_WIDTH
  • Constructor Summary

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

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

    Methods inherited from class it.polimi.ingsw.view.cli.console.printers.Printer

    getConsole, highlightWorkers, showGameBoard, showGameBoard

    Methods inherited from class java.lang.Object

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

    • BasicPrinter

      public BasicPrinter​(Console console, CLI cli) throws java.io.IOException
      Default constructor
      Parameters:
      cli - the view which created the printer
      Throws:
      java.io.IOException
  • Method Details

    • printError

      public void printError​(java.lang.String errorMsg)
      Shows an error message
      Specified by:
      printError in class Printer
      Parameters:
      errorMsg - the error message
    • printMessage

      public void printMessage​(java.lang.String msg)
      Shows a success message
      Specified by:
      printMessage in class Printer
      Parameters:
      msg - the message
    • printStartingScreen

      public void printStartingScreen()
      Shows the logo
      Specified by:
      printStartingScreen in class Printer
    • askToReloadSettings

      public void askToReloadSettings()
      Asks the user if it wants to reload a previously saved address/username combo
      Specified by:
      askToReloadSettings in class Printer
    • showSavedSettings

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

      public void askIp()
      Asks the user to insert the server address
      Specified by:
      askIp in class Printer
    • askUsername

      public void askUsername()
      Asks the user to insert its username
      Specified by:
      askUsername in class Printer
    • lobbyOptions

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

      public void askLobbyName()
      Asks the user to choose a name for the lobby to be created
      Specified by:
      askLobbyName in class Printer
    • askLobbySize

      public void askLobbySize()
      Asks the user to choose the lobby size
      Specified by:
      askLobbySize in class Printer
    • chooseLobbyToJoin

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

      public void chooseToReloadMatch()
      Asks the user if it wants to reload an existing saved match
      Specified by:
      chooseToReloadMatch in class Printer
    • chooseGameGods

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

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

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

      protected BoardUtils setBoardUtils()
      Creates a BoardUtils object, based on the printer calling it
      Specified by:
      setBoardUtils in class Printer
      Returns:
      a boardUtils object
    • updateGameData

      public void updateGameData​(java.util.List<Cell> board, java.util.List<PlayerData> players)
      Updates information about the game and the players
      Specified by:
      updateGameData in class Printer
      Parameters:
      board - the game board
      players - information about the players
    • chooseAction

      public void chooseAction​(java.util.List<PossibleActions> possibleActions)
      Asks the user which action to perform
      Specified by:
      chooseAction in class Printer
      Parameters:
      possibleActions - a list of possible actions
    • placeWorker

      public void placeWorker()
      Asks the user to place its worker on the board
      Specified by:
      placeWorker in class Printer
    • chooseWorker

      public void chooseWorker​(java.util.List<Cell> cells)
      Asks the user to choose a worker
      Specified by:
      chooseWorker in class Printer
      Parameters:
      cells - the cells containing the user's workers
    • moveAction

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

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

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

      protected void printOptions​(java.util.List<java.lang.String> list)
      Print a list of options, preceded by a number that the user will have to type to choose that option
      Parameters:
      list - the options