Module AM37

Class FancyPrinter

java.lang.Object
it.polimi.ingsw.view.cli.console.printers.Printer
it.polimi.ingsw.view.cli.console.printers.fancyPrinter.FancyPrinter

public class FancyPrinter
extends Printer
Fancy printer for systems supporting non canonical terminal mode
  • 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
    FancyPrinter​(Console console, CLI cli)
    Default constructor
  • Method Summary

    Modifier and Type Method Description
    void askIp()
    Asks the user both the server address and the username
    At this point, the username is surely not set yet
    void askLobbyName()
    Shows a TextInputDialog asking for both the lobby name and size
    void askLobbySize()
    Does nothing, the lobby size is asked in askLobbyName() for this printer
    void askToReloadSettings()
    Asks the user if it wants to reload an already used address/username combo
    void askUsername()
    Asks the user its username only
    This will generate an InputDialog only if the current state is "LOBBY", a.k.a.
    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)
    Shows the user a MultipleChoiceListDialog, containing the gods and their descriptions
    void chooseLobbyToJoin​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> lobbiesAvailable)
    Asks the user to choose which lobby to join, showing a list of available lobbies and their details
    void chooseStartingPlayer​(java.util.List<java.lang.String> players)
    Asks the user which player will play first
    void chooseToReloadMatch()
    Shows the user a dialog with two buttons (Yes/No), asking the user if it wants to reload a previously saved game status
    void chooseUserGod​(java.util.List<GodData> possibleGods)
    Shows the user a DetailedSingleChoiceListDialog, containing the available gods and descriptions
    void chooseWorker​(java.util.List<Cell> cells)
    Asks the user to choose a worker
    void lobbyOptions​(java.util.List<java.lang.String> options)
    Shows a dialog with one or two buttons, based on the possible lobby options (Create/Join)
    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 a popup error message
    void printMessage​(java.lang.String msg)
    Shows a popup general message
    void printStartingScreen()
    Shows the "Santorini" logo
    protected BoardUtils setBoardUtils()
    Creates a FancyPrinterBoardUtils
    void showSavedSettings​(java.util.List<java.lang.String> options)
    Shows a dialog with Yes/No buttons to decide to reload a previously saved address/username combo
    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

    • FancyPrinter

      public FancyPrinter​(Console console, CLI cli) throws java.io.IOException
      Default constructor
      Parameters:
      console - the console in which the output will be printed
      cli - the UI object
      Throws:
      java.io.IOException
  • Method Details

    • printError

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

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

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

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

      public void showSavedSettings​(java.util.List<java.lang.String> options)
      Shows a dialog with Yes/No buttons to decide to reload a previously saved address/username combo
      Specified by:
      showSavedSettings in class Printer
      Parameters:
      options - the address/username combos
    • askIp

      public void askIp()
      Asks the user both the server address and the username
      At this point, the username is surely not set yet
      Specified by:
      askIp in class Printer
    • askUsername

      public void askUsername()
      Asks the user its username only
      This will generate an InputDialog only if the current state is "LOBBY", a.k.a. the user tried to join a lobby using an already taken username for that lobby
      Specified by:
      askUsername in class Printer
    • lobbyOptions

      public void lobbyOptions​(java.util.List<java.lang.String> options)
      Shows a dialog with one or two buttons, based on the possible lobby options (Create/Join)
      Specified by:
      lobbyOptions in class Printer
      Parameters:
      options - a list of possible options
    • askLobbyName

      public void askLobbyName()
      Shows a TextInputDialog asking for both the lobby name and size
      Specified by:
      askLobbyName in class Printer
    • askLobbySize

      public void askLobbySize()
      Does nothing, the lobby size is asked in askLobbyName() for this printer
      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 to choose which lobby to join, showing a list of available lobbies and their details
      Specified by:
      chooseLobbyToJoin in class Printer
      Parameters:
      lobbiesAvailable - a map containing the lobbies available and their relative information
      See Also:
      Lobby.lobbyInfo()
    • chooseToReloadMatch

      public void chooseToReloadMatch()
      Shows the user a dialog with two buttons (Yes/No), asking the user if it wants to reload a previously saved game status
      Specified by:
      chooseToReloadMatch in class Printer
    • chooseGameGods

      public void chooseGameGods​(java.util.List<GodData> allGods, int size)
      Shows the user a MultipleChoiceListDialog, containing the gods and their descriptions
      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)
      Shows the user a DetailedSingleChoiceListDialog, containing the available gods and descriptions
      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 FancyPrinterBoardUtils
      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 player'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)