java.lang.Object
it.polimi.ingsw.view.cli.CLI
- All Implemented Interfaces:
ViewInterface
public class CLI extends java.lang.Object implements ViewInterface
Command Line Interface manager
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.concurrent.locks.Lock
lock
-
Constructor Summary
Constructors Constructor Description CLI(boolean enableRawMode)
Default constructor -
Method Summary
Modifier and Type Method Description void
askIP()
Asks the user the server address to connect tovoid
askLobbyName()
Asks the user the name for the lobby to be createdvoid
askLobbySize()
Asks the user the number of players for its lobbyvoid
askToReloadLastSettings(java.util.List<java.lang.String> savedUsers)
Asks the user if it wants to reload a previously saved address/username combovoid
askUsername()
Asks the user the username it wants to usevoid
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 it wants to joinvoid
chooseMatchReload()
Asks the user if it wants to reload an existing saved matchvoid
chooseStartingPlayer(java.util.List<java.lang.String> players)
Asks the user which player will play firstvoid
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 workerboolean
enableRawMode()
Determines if the terminal running the application allows non-canonical modevoid
evaluateInput(java.lang.String input)
Passes a string to the inputManagervoid
gameBoardUpdate(java.util.List<Cell> gameBoard, java.util.List<PlayerData> players)
Refreshes the game screenvoid
gameStartScreen(java.util.List<Cell> gameBoard, java.util.List<PlayerData> playerData)
Updates information about the players and the gamevoid
lobbyOptions(java.util.List<java.lang.String> options)
Asks the user if it wants 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
printLogo()
Prints the start screenvoid
printUserServerCombos(java.util.List<java.lang.String> options)
Shows the user the address/username combosvoid
setInputManager(InputManager inputManager)
Sets the InputManager to parse the inputsvoid
showErrorMessage(java.lang.String error)
Shows an error messagevoid
showGameBoard(java.util.List<Cell> gameBoard)
Prints the game board on the screenvoid
showSuccessMessage(java.lang.String message)
Shows a success message
-
Field Details
-
lock
protected static java.util.concurrent.locks.Lock lock
-
-
Constructor Details
-
CLI
public CLI(boolean enableRawMode) throws java.io.IOExceptionDefault constructor- Parameters:
enableRawMode
- determines if the terminal in which the program is running allows non-canonical mode- Throws:
java.io.IOException
-
-
Method Details
-
enableRawMode
public boolean enableRawMode()Determines if the terminal running the application allows non-canonical mode- Returns:
- true if the terminal allows non-canonical mode, false otherwise
-
setInputManager
Sets the InputManager to parse the inputs- Specified by:
setInputManager
in interfaceViewInterface
- Parameters:
inputManager
- te inputManager to use
-
evaluateInput
public void evaluateInput(java.lang.String input)Passes a string to the inputManager- Parameters:
input
- the inputString
-
showErrorMessage
public void showErrorMessage(java.lang.String error)Shows an error message- Specified by:
showErrorMessage
in interfaceViewInterface
- Parameters:
error
- the error message
-
showSuccessMessage
public void showSuccessMessage(java.lang.String message)Shows a success message- Specified by:
showSuccessMessage
in interfaceViewInterface
- Parameters:
message
- the message
-
printLogo
public void printLogo()Prints the start screen- Specified by:
printLogo
in interfaceViewInterface
-
askToReloadLastSettings
public void askToReloadLastSettings(java.util.List<java.lang.String> savedUsers)Asks the user if it wants to reload a previously saved address/username combo- Specified by:
askToReloadLastSettings
in interfaceViewInterface
- Parameters:
savedUsers
- the address/username combos
-
printUserServerCombos
public void printUserServerCombos(java.util.List<java.lang.String> options)Shows the user the address/username combos- Specified by:
printUserServerCombos
in interfaceViewInterface
- Parameters:
options
- the address/username combos
-
askIP
public void askIP()Asks the user the server address to connect to- Specified by:
askIP
in interfaceViewInterface
-
askUsername
public void askUsername()Asks the user the username it wants to use- Specified by:
askUsername
in interfaceViewInterface
-
lobbyOptions
public void lobbyOptions(java.util.List<java.lang.String> options)Asks the user if it wants to join or create a lobby- Specified by:
lobbyOptions
in interfaceViewInterface
- Parameters:
options
- the possible options
-
askLobbyName
public void askLobbyName()Asks the user the name for the lobby to be created- Specified by:
askLobbyName
in interfaceViewInterface
-
askLobbySize
public void askLobbySize()Asks the user the number of players for its lobby- Specified by:
askLobbySize
in interfaceViewInterface
-
chooseLobbyToJoin
public void chooseLobbyToJoin(java.util.Map<java.lang.String,java.util.List<java.lang.String>> lobbiesAvailable)Asks the user which lobby it wants to join- Specified by:
chooseLobbyToJoin
in interfaceViewInterface
- Parameters:
lobbiesAvailable
- a map containing lobbies and their info- See Also:
Lobby.lobbyInfo()
-
chooseMatchReload
public void chooseMatchReload()Asks the user if it wants to reload an existing saved match- Specified by:
chooseMatchReload
in interfaceViewInterface
-
chooseGameGods
Asks the user to choose the gods for the game- Specified by:
chooseGameGods
in interfaceViewInterface
- 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 interfaceViewInterface
- 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 interfaceViewInterface
- Parameters:
players
- the list of players
-
gameStartScreen
Updates information about the players and the game- Specified by:
gameStartScreen
in interfaceViewInterface
- Parameters:
gameBoard
- the starting game boardplayerData
- the players data
-
showGameBoard
Prints the game board on the screen- Specified by:
showGameBoard
in interfaceViewInterface
- Parameters:
gameBoard
- the board to print
-
gameBoardUpdate
Refreshes the game screen- Specified by:
gameBoardUpdate
in interfaceViewInterface
- Parameters:
gameBoard
- the board to start withplayers
- information about the players
-
placeWorker
public void placeWorker()Asks the user to place its worker on the board- Specified by:
placeWorker
in interfaceViewInterface
-
chooseWorker
Asks the user to choose a worker- Specified by:
chooseWorker
in interfaceViewInterface
- Parameters:
cells
- the cells containing the user's workers
-
chooseAction
Asks the user which action to perform- Specified by:
chooseAction
in interfaceViewInterface
- Parameters:
possibleActions
- a list of possible actions
-
moveAction
Asks the user to select a cell to move its current worker on- Specified by:
moveAction
in interfaceViewInterface
- 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 interfaceViewInterface
- 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 interfaceViewInterface
- Parameters:
buildableBlocks
- the possible blocks (always more than one)
-