Module app

Class PieceSocket<M extends Move<P>,P extends Piece>

java.lang.Object
app.utils.pieceplayer.PieceSocket<M,P>
Type Parameters:
M -
P -
All Implemented Interfaces:
Spectator<M,P>
Direct Known Subclasses:
HotSeatPlayer, PieceSpectator, StandalonePiecePlayer

public abstract class PieceSocket<M extends Move<P>,P extends Piece> extends Object implements Spectator<M,P>
Socket for interacting with game using individual pieces.
  • Field Details

  • Constructor Details

    • PieceSocket

      public PieceSocket()
  • Method Details

    • update

      public final void update(int player, M move, List<P> changedPieces)
      Updates all interactive pieces connected to the changed pieces
      Specified by:
      update in interface Spectator<M extends Move<P>,P extends Piece>
      Parameters:
      player - player that made a move
      move - move that caused the change
      changedPieces - altered pieces
    • connectPieces

      public void connectPieces(Function<P,? extends InteractivePiece<M,P>> newPiece)
      Connects underlying game pieces to supplied interactors.

      Implementation should call this method and add newly created piece to the map

      Parameters:
      newPiece - constructor of InteractivePiece that takes P as argument
    • connectPiece

      protected abstract void connectPiece(P piece)
      Connect a single piece and add it to the map