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 addressvoid
askLobbyName()
Asks the user to choose a name for the lobby to be createdvoid
askLobbySize()
Asks the user to choose the lobby sizevoid
askToReloadSettings()
Asks the user if it wants to reload a previously saved address/username combovoid
askUsername()
Asks the user to insert its usernamevoid
buildAction(java.util.List<Cell> gameBoard, java.util.List<Cell> buildableCells)
Asks the user to select a cell to build onvoid
chooseAction(java.util.List<PossibleActions> possibleActions)
Asks the user which action to performvoid
chooseBlockToBuild(java.util.List<Block> buildableBlocks)
Asks the user which block to build on a cellvoid
chooseGameGods(java.util.List<GodData> allGods, int size)
Asks the user to choose the gods for the gamevoid
chooseLobbyToJoin(java.util.Map<java.lang.String,java.util.List<java.lang.String>> lobbiesAvailable)
Asks the user which lobby to joinvoid
chooseStartingPlayer(java.util.List<java.lang.String> players)
Asks the user which player will play firstvoid
chooseToReloadMatch()
Asks the user if it wants to reload an existing saved matchvoid
chooseUserGod(java.util.List<GodData> possibleGods)
Asks the user to choose its personal god for the gamevoid
chooseWorker(java.util.List<Cell> cells)
Asks the user to choose a workervoid
lobbyOptions(java.util.List<java.lang.String> options)
Asks the user to choose whether to join or create a lobbyvoid
moveAction(java.util.List<Cell> gameBoard, java.util.List<Cell> walkableCells)
Asks the user to select a cell to move its current worker onvoid
placeWorker()
Asks the user to place its worker on the boardvoid
printError(java.lang.String errorMsg)
Shows an error messagevoid
printMessage(java.lang.String msg)
Shows a success messageprotected 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 optionvoid
printStartingScreen()
Shows the logoprotected BoardUtils
setBoardUtils()
Creates a BoardUtils object, based on the printer calling itvoid
showSavedSettings(java.util.List<java.lang.String> options)
Shows the user the saved address/username combosvoid
updateGameData(java.util.List<Cell> board, java.util.List<PlayerData> players)
Updates information about the game and the playersMethods inherited from class it.polimi.ingsw.view.cli.console.printers.Printer
getConsole, highlightWorkers, showGameBoard, showGameBoard
-
Constructor Details
-
BasicPrinter
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 classPrinter
- Parameters:
errorMsg
- the error message
-
printMessage
public void printMessage(java.lang.String msg)Shows a success message- Specified by:
printMessage
in classPrinter
- Parameters:
msg
- the message
-
printStartingScreen
public void printStartingScreen()Shows the logo- Specified by:
printStartingScreen
in classPrinter
-
askToReloadSettings
public void askToReloadSettings()Asks the user if it wants to reload a previously saved address/username combo- Specified by:
askToReloadSettings
in classPrinter
-
showSavedSettings
public void showSavedSettings(java.util.List<java.lang.String> options)Shows the user the saved address/username combos- Specified by:
showSavedSettings
in classPrinter
- Parameters:
options
- the address/username combos
-
askIp
public void askIp()Asks the user to insert the server address -
askUsername
public void askUsername()Asks the user to insert its username- Specified by:
askUsername
in classPrinter
-
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 classPrinter
- 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 classPrinter
-
askLobbySize
public void askLobbySize()Asks the user to choose the lobby size- Specified by:
askLobbySize
in classPrinter
-
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 classPrinter
- 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 classPrinter
-
chooseGameGods
Asks the user to choose the gods for the game- Specified by:
chooseGameGods
in classPrinter
- Parameters:
allGods
- the list of available godssize
- the number of players
-
chooseUserGod
Asks the user to choose its personal god for the game- Specified by:
chooseUserGod
in classPrinter
- 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 classPrinter
- Parameters:
players
- the players in game
-
setBoardUtils
Creates a BoardUtils object, based on the printer calling it- Specified by:
setBoardUtils
in classPrinter
- Returns:
- a boardUtils object
-
updateGameData
Updates information about the game and the players- Specified by:
updateGameData
in classPrinter
- Parameters:
board
- the game boardplayers
- information about the players
-
chooseAction
Asks the user which action to perform- Specified by:
chooseAction
in classPrinter
- 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 classPrinter
-
chooseWorker
Asks the user to choose a worker- Specified by:
chooseWorker
in classPrinter
- Parameters:
cells
- the cells containing the user's workers
-
moveAction
Asks the user to select a cell to move its current worker on- Specified by:
moveAction
in classPrinter
- Parameters:
gameBoard
- the current game boardwalkableCells
- the cells on which the worker can be moved to
-
buildAction
Asks the user to select a cell to build on- Specified by:
buildAction
in classPrinter
- Parameters:
gameBoard
- the current game boardbuildableCells
- the cells on which the worker can build
-
chooseBlockToBuild
Asks the user which block to build on a cell- Specified by:
chooseBlockToBuild
in classPrinter
- 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
-