Module app

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 Details

    • game

      G extends Game<M,P> game
    • isConnected

      boolean[] isConnected
    • connectedPlayers

      int connectedPlayers
    • spectators

      List<Spectator<M extends Move<P>,P extends Piece>> spectators
  • Constructor Details

    • InteractiveGame

      public InteractiveGame(G game)
  • Method Details

    • connectPlayer

      public void connectPlayer(int playerId, Player<M,P> player)
      Connects the player and handles the controls
      Specified by:
      connectPlayer in interface GameSocket<M extends Move<P>,P extends Piece>
      Parameters:
      playerId - id of connected player
      player - player to be connected
    • connectSpectator

      public void connectSpectator(Spectator<M,P> spectator)
      Connects spectator that listens to the events
      Specified by:
      connectSpectator in interface GameSocket<M extends Move<P>,P extends Piece>
      Parameters:
      spectator - spectator to be connected
    • getPieces

      public List<P> getPieces(int player)
      Description copied from interface: GameView
      Returns all pieces that belong to the player
      Specified by:
      getPieces in interface GameView<M extends Move<P>,P extends Piece>
    • getAllPieces

      public List<P> getAllPieces()
      Description copied from interface: GameView
      Returns all pieces in the game
      Specified by:
      getAllPieces in interface GameView<M extends Move<P>,P extends Piece>
    • getLegalMoves

      public List<M> getLegalMoves(int player)
      Description copied from interface: GameView
      Returns list of moves available for the player
      Specified by:
      getLegalMoves in interface GameView<M extends Move<P>,P extends Piece>
    • getLegalMoves

      public List<M> getLegalMoves(int player, P piece)
      Description copied from interface: GameView
      Returns list of moves with given piece available for the player
      Specified by:
      getLegalMoves in interface GameView<M extends Move<P>,P extends Piece>
    • makeMove

      public List<P> makeMove(int player, M move)
      Description copied from interface: Game
      Makes the move as the player
      Specified by:
      makeMove in interface Game<M extends Move<P>,P extends Piece>
    • getPlayerCount

      public int getPlayerCount()
      Description copied from interface: GameView
      Returns number of player this game requires
      Specified by:
      getPlayerCount in interface GameView<M extends Move<P>,P extends Piece>