Module app
Package app.core.interactor
Class InteractiveGame<M extends Move<P>,P extends Piece,G extends Game<M,P>>
java.lang.Object
app.core.interactor.InteractiveGame<M,P,G>
- All Implemented Interfaces:
Game<M,
,P> GameView<M,
,P> GameSocket<M,
P>
public final class InteractiveGame<M extends Move<P>,P extends Piece,G extends Game<M,P>>
extends Object
implements Game<M,P>, GameSocket<M,P>
Wraps game allowing players to interact with each other and notifies participants about events
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) G
(package private) boolean[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
connectPlayer
(int playerId, Player<M, P> player) Connects the player and handles the controlsvoid
connectSpectator
(Spectator<M, P> spectator) Connects spectator that listens to the eventsReturns all pieces in the gamegetLegalMoves
(int player) Returns list of moves available for the playergetLegalMoves
(int player, P piece) Returns list of moves with given piece available for the playergetPieces
(int player) Returns all pieces that belong to the playerint
Returns number of player this game requiresMakes the move as the player
-
Field Details
-
game
-
isConnected
boolean[] isConnected -
connectedPlayers
int connectedPlayers -
spectators
-
-
Constructor Details
-
InteractiveGame
-
-
Method Details
-
connectPlayer
Connects the player and handles the controls- Specified by:
connectPlayer
in interfaceGameSocket<M extends Move<P>,
P extends Piece> - Parameters:
playerId
- id of connected playerplayer
- player to be connected
-
connectSpectator
Connects spectator that listens to the events- Specified by:
connectSpectator
in interfaceGameSocket<M extends Move<P>,
P extends Piece> - Parameters:
spectator
- spectator to be connected
-
getPieces
Description copied from interface:GameView
Returns all pieces that belong to the player -
getAllPieces
Description copied from interface:GameView
Returns all pieces in the game -
getLegalMoves
Description copied from interface:GameView
Returns list of moves available for the player -
getLegalMoves
Description copied from interface:GameView
Returns list of moves with given piece available for the player -
makeMove
Description copied from interface:Game
Makes the move as the player -
getPlayerCount
public int getPlayerCount()Description copied from interface:GameView
Returns number of player this game requires
-