Class TwoPhaseMoveGame<T>
- Type Parameters:
T
- represents the moves that can be applied to the states
Conducts a two-player game of the two-phase move-type on the console.
-
Field Summary
Fields inherited from class game.console.AbstractGame
console, parser, state
-
Constructor Summary
ConstructorsConstructorDescriptionTwoPhaseMoveGame
(TwoPhaseMoveState<T> state, Function<String, T> parser) Creates aTwoPhaseMoveGame
instance to conduct a two-player game of the two-phase move-type on the console. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
makeMoveIfPossible
(T move) Applies the move specified to the state of the game if the move is a legal one.protected void
Prints a prompt on the console to read the next move to be made.Methods inherited from class game.console.AbstractGame
printState, printStatus, readMove, start
-
Constructor Details
-
TwoPhaseMoveGame
Creates aTwoPhaseMoveGame
instance to conduct a two-player game of the two-phase move-type on the console.- Parameters:
state
- the state from which the game is startedparser
- a function that converts a line read from the console to a move- Throws:
AssertionError
- if the console is not available
-
-
Method Details
-
makeMoveIfPossible
Description copied from class:AbstractGame
Applies the move specified to the state of the game if the move is a legal one. In case of a legal move, it should also print the updated state on the console with theAbstractGame.printState()
method.- Specified by:
makeMoveIfPossible
in classAbstractGame<TwoPhaseMoveState<T>, T>
- Parameters:
move
- the move to be made
-
printPrompt
protected void printPrompt()Description copied from class:AbstractGame
Prints a prompt on the console to read the next move to be made.- Overrides:
printPrompt
in classAbstractGame<TwoPhaseMoveState<T>, T>
-