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 BoardUtils
boardUtils
protected CLI
cli
The UI which created the printerprotected Console
console
protected PrintableObject
mainLogo
protected java.util.Properties
properties
static int
SCENE_HEIGHT
static int
SCENE_WIDTH
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description abstract void
askIp()
Asks the user to insert the server addressabstract void
askLobbyName()
Asks the user to choose a name for the lobby to be createdabstract void
askLobbySize()
Asks the user to choose the lobby sizeabstract void
askToReloadSettings()
Asks the user if it wants to reload a previously saved address/username comboabstract void
askUsername()
Asks the user to insert its usernameabstract void
buildAction(java.util.List<Cell> gameBoard, java.util.List<Cell> buildableCells)
Asks the user to select a cell to build onabstract void
chooseAction(java.util.List<PossibleActions> possibleActions)
Asks the user which action to performabstract void
chooseBlockToBuild(java.util.List<Block> buildableBlocks)
Asks the user which block to build on a cellabstract void
chooseGameGods(java.util.List<GodData> allGods, int size)
Asks the user to choose the gods for the gameabstract void
chooseLobbyToJoin(java.util.Map<java.lang.String,java.util.List<java.lang.String>> lobbiesAvailable)
Asks the user which lobby to joinabstract void
chooseStartingPlayer(java.util.List<java.lang.String> players)
Asks the user which player will play firstabstract void
chooseToReloadMatch()
Asks the user if it wants to reload an existing saved matchabstract void
chooseUserGod(java.util.List<GodData> possibleGods)
Asks the user to choose its personal god for the gameabstract void
chooseWorker(java.util.List<Cell> cells)
Asks the user to pick a workerConsole
getConsole()
console getterprotected void
highlightWorkers(java.util.List<Cell> cells)
Highlights the user's workersabstract void
lobbyOptions(java.util.List<java.lang.String> options)
Asks the user to choose whether to join or create a lobbyabstract void
moveAction(java.util.List<Cell> gameBoard, java.util.List<Cell> walkableCells)
Asks the user to select a cell to move its current worker toabstract void
placeWorker()
Asks the user to place its worker on the boardabstract void
printError(java.lang.String errorMsg)
Shows an error messageabstract void
printMessage(java.lang.String msg)
Shows a success messageabstract void
printStartingScreen()
Shows the logoprotected abstract BoardUtils
setBoardUtils()
Creates a BoardUtils object, based on the printer calling itvoid
showGameBoard(java.util.List<Cell> gameBoard)
Prints the game board on the screenvoid
showGameBoard(java.util.List<Cell> gameBoard, java.util.List<Cell> toHighlight)
Prints the game board on the screenabstract void
showSavedSettings(java.util.List<java.lang.String> options)
Shows the user the saved address/username combosabstract void
updateGameData(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)
-