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 BoardUtilsboardUtilsprotected CLIcliThe UI which created the printerprotected Consoleconsoleprotected PrintableObjectmainLogoprotected java.util.Propertiespropertiesstatic intSCENE_HEIGHTstatic intSCENE_WIDTH -
Constructor Summary
-
Method Summary
Modifier and Type Method Description abstract voidaskIp()Asks the user to insert the server addressabstract voidaskLobbyName()Asks the user to choose a name for the lobby to be createdabstract voidaskLobbySize()Asks the user to choose the lobby sizeabstract voidaskToReloadSettings()Asks the user if it wants to reload a previously saved address/username comboabstract voidaskUsername()Asks the user to insert its usernameabstract voidbuildAction(java.util.List<Cell> gameBoard, java.util.List<Cell> buildableCells)Asks the user to select a cell to build onabstract voidchooseAction(java.util.List<PossibleActions> possibleActions)Asks the user which action to performabstract voidchooseBlockToBuild(java.util.List<Block> buildableBlocks)Asks the user which block to build on a cellabstract voidchooseGameGods(java.util.List<GodData> allGods, int size)Asks the user to choose the gods for the gameabstract voidchooseLobbyToJoin(java.util.Map<java.lang.String,java.util.List<java.lang.String>> lobbiesAvailable)Asks the user which lobby to joinabstract voidchooseStartingPlayer(java.util.List<java.lang.String> players)Asks the user which player will play firstabstract voidchooseToReloadMatch()Asks the user if it wants to reload an existing saved matchabstract voidchooseUserGod(java.util.List<GodData> possibleGods)Asks the user to choose its personal god for the gameabstract voidchooseWorker(java.util.List<Cell> cells)Asks the user to pick a workerConsolegetConsole()console getterprotected voidhighlightWorkers(java.util.List<Cell> cells)Highlights the user's workersabstract voidlobbyOptions(java.util.List<java.lang.String> options)Asks the user to choose whether to join or create a lobbyabstract voidmoveAction(java.util.List<Cell> gameBoard, java.util.List<Cell> walkableCells)Asks the user to select a cell to move its current worker toabstract voidplaceWorker()Asks the user to place its worker on the boardabstract voidprintError(java.lang.String errorMsg)Shows an error messageabstract voidprintMessage(java.lang.String msg)Shows a success messageabstract voidprintStartingScreen()Shows the logoprotected abstract BoardUtilssetBoardUtils()Creates a BoardUtils object, based on the printer calling itvoidshowGameBoard(java.util.List<Cell> gameBoard)Prints the game board on the screenvoidshowGameBoard(java.util.List<Cell> gameBoard, java.util.List<Cell> toHighlight)Prints the game board on the screenabstract voidshowSavedSettings(java.util.List<java.lang.String> options)Shows the user the saved address/username combosabstract voidupdateGameData(java.util.List<Cell> board, java.util.List<PlayerData> players)Updates information about the game and the players
-
Field Details
-
SCENE_WIDTH
public static final int SCENE_WIDTH- See Also:
- Constant Field Values
-
SCENE_HEIGHT
public static final int SCENE_HEIGHT- See Also:
- Constant Field Values
-
cli
The UI which created the printer -
boardUtils
-
console
-
mainLogo
-
properties
protected final java.util.Properties properties
-
-
Constructor Details
-
Printer
Default constructor- Parameters:
cli- the view which created the printerconsole- the Console object containing this- Throws:
java.io.IOException
-
-
Method Details
-
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
Asks the user to choose the gods for the game- Parameters:
allGods- the list of available godssize- the number of players
-
chooseUserGod
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
Prints the game board on the screen- Parameters:
gameBoard- the board to print
-
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 boardplayers- information about the players
-
showGameBoard
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
Asks the user to pick a worker- Parameters:
cells- the cells containing the player's workers
-
highlightWorkers
Highlights the user's workers- Parameters:
cells- the cells containing the user's workers
-
chooseAction
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 boardwalkableCells- 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 boardbuildableCells- the cells on which the worker can build
-
chooseBlockToBuild
Asks the user which block to build on a cell- Parameters:
buildableBlocks- the possible blocks (always more than one)
-