java.lang.Object
it.polimi.ingsw.view.inputManagers.InputManager
- Direct Known Subclasses:
AddWorkersInputManager
,ChooseStartingPlayerInputManager
,GodChoiceInputManager
,LobbyInputManager
,LoginManager
,ReloadGameInputManager
,SelectActionCellInputManager
,SelectActionInputManager
,SelectBlockInputManager
,SelectWorkerInputManager
public abstract class InputManager
extends java.lang.Object
InputManager abstraction
An InputManager is an object responsible for the console input acquisition and redirection
-
Field Summary
Fields Modifier and Type Field Description protected Client
client
The client to manage the input forprotected static java.util.concurrent.ScheduledFuture<?>
inputCountdown
The scheduled task that manage the timeout on user inputprotected boolean
isWaitingForInput
Determines if an eventual input has to be discarded or notprotected ViewInterface
view
The view to call methods on -
Constructor Summary
Constructors Constructor Description InputManager(Client client)
Default constructor -
Method Summary
Modifier and Type Method Description protected java.lang.String
cleanInput(java.lang.String input)
Sanitizes an input stringabstract void
manageInput(java.lang.String input)
Determines how to handle the received input based on the internal statevoid
setWaitingForInput(boolean waitingForInput)
void
startTimer(int availableTime)
Starts the timer which will terminate the client if no input is received for a certain amount of timevoid
stopTimer()
This method cancels the task and reset the second passed
-
Field Details
-
inputCountdown
protected static java.util.concurrent.ScheduledFuture<?> inputCountdownThe scheduled task that manage the timeout on user input -
client
The client to manage the input for -
view
The view to call methods on -
isWaitingForInput
protected boolean isWaitingForInputDetermines if an eventual input has to be discarded or not
-
-
Constructor Details
-
InputManager
Default constructor- Parameters:
client
- the client to manage the inputs for
-
-
Method Details
-
manageInput
public abstract void manageInput(java.lang.String input)Determines how to handle the received input based on the internal stateThis method expects an already trimmed input
- Parameters:
input
- the user input
-
cleanInput
protected java.lang.String cleanInput(java.lang.String input)Sanitizes an input string- Parameters:
input
- the user input- Returns:
- a sanitized version of the input string
-
setWaitingForInput
public void setWaitingForInput(boolean waitingForInput) -
startTimer
public void startTimer(int availableTime)Starts the timer which will terminate the client if no input is received for a certain amount of time- Parameters:
availableTime
- the maximum time the user has to input something
-
stopTimer
public void stopTimer()This method cancels the task and reset the second passed
-