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 voidaskIp()Asks the user to insert the server addressvoidaskLobbyName()Asks the user to choose a name for the lobby to be createdvoidaskLobbySize()Asks the user to choose the lobby sizevoidaskToReloadSettings()Asks the user if it wants to reload a previously saved address/username combovoidaskUsername()Asks the user to insert its usernamevoidbuildAction(java.util.List<Cell> gameBoard, java.util.List<Cell> buildableCells)Asks the user to select a cell to build onvoidchooseAction(java.util.List<PossibleActions> possibleActions)Asks the user which action to performvoidchooseBlockToBuild(java.util.List<Block> buildableBlocks)Asks the user which block to build on a cellvoidchooseGameGods(java.util.List<GodData> allGods, int size)Asks the user to choose the gods for the gamevoidchooseLobbyToJoin(java.util.Map<java.lang.String,java.util.List<java.lang.String>> lobbiesAvailable)Asks the user which lobby to joinvoidchooseStartingPlayer(java.util.List<java.lang.String> players)Asks the user which player will play firstvoidchooseToReloadMatch()Asks the user if it wants to reload an existing saved matchvoidchooseUserGod(java.util.List<GodData> possibleGods)Asks the user to choose its personal god for the gamevoidchooseWorker(java.util.List<Cell> cells)Asks the user to choose a workervoidlobbyOptions(java.util.List<java.lang.String> options)Asks the user to choose whether to join or create a lobbyvoidmoveAction(java.util.List<Cell> gameBoard, java.util.List<Cell> walkableCells)Asks the user to select a cell to move its current worker onvoidplaceWorker()Asks the user to place its worker on the boardvoidprintError(java.lang.String errorMsg)Shows an error messagevoidprintMessage(java.lang.String msg)Shows a success messageprotected voidprintOptions(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 optionvoidprintStartingScreen()Shows the logoprotected BoardUtilssetBoardUtils()Creates a BoardUtils object, based on the printer calling itvoidshowSavedSettings(java.util.List<java.lang.String> options)Shows the user the saved address/username combosvoidupdateGameData(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:
printErrorin classPrinter- Parameters:
errorMsg- the error message
-
printMessage
public void printMessage(java.lang.String msg)Shows a success message- Specified by:
printMessagein classPrinter- Parameters:
msg- the message
-
printStartingScreen
public void printStartingScreen()Shows the logo- Specified by:
printStartingScreenin classPrinter
-
askToReloadSettings
public void askToReloadSettings()Asks the user if it wants to reload a previously saved address/username combo- Specified by:
askToReloadSettingsin classPrinter
-
showSavedSettings
public void showSavedSettings(java.util.List<java.lang.String> options)Shows the user the saved address/username combos- Specified by:
showSavedSettingsin 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:
askUsernamein 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:
lobbyOptionsin 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:
askLobbyNamein classPrinter
-
askLobbySize
public void askLobbySize()Asks the user to choose the lobby size- Specified by:
askLobbySizein 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:
chooseLobbyToJoinin 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:
chooseToReloadMatchin classPrinter
-
chooseGameGods
Asks the user to choose the gods for the game- Specified by:
chooseGameGodsin 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:
chooseUserGodin 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:
chooseStartingPlayerin classPrinter- Parameters:
players- the players in game
-
setBoardUtils
Creates a BoardUtils object, based on the printer calling it- Specified by:
setBoardUtilsin classPrinter- Returns:
- a boardUtils object
-
updateGameData
Updates information about the game and the players- Specified by:
updateGameDatain classPrinter- Parameters:
board- the game boardplayers- information about the players
-
chooseAction
Asks the user which action to perform- Specified by:
chooseActionin classPrinter- Parameters:
possibleActions- a list of possible actions
-
placeWorker
public void placeWorker()Asks the user to place its worker on the board- Specified by:
placeWorkerin classPrinter
-
chooseWorker
Asks the user to choose a worker- Specified by:
chooseWorkerin 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:
moveActionin 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:
buildActionin 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:
chooseBlockToBuildin 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
-