added javadocs to all client messages

This commit is contained in:
Daniel Grigencha
2024-11-24 19:56:51 +01:00
committed by Felix
parent 6938ce16b7
commit f6d16a81bf
19 changed files with 593 additions and 67 deletions

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message indicating an animation event is finished in the game.
*/
@Serializable
public class AnimationEnd extends ClientMessage { public class AnimationEnd extends ClientMessage {
@Override /**
public String toString() { * Constructs an AnimationEnd message.
return "null"; */
public AnimationEnd() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "AnimationEnd{}";
}
/**
* Accepts a visitor for processing this message.
*
* @param interpreter the visitor to be used for processing
* @param from the connection ID of the sender
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,37 +1,143 @@
package pp.mdga.message.client; package pp.mdga.message.client;
/**
* Visitor interface for processing all client messages.
*/
public interface ClientInterpreter { public interface ClientInterpreter {
void received(AnimationEnd animationEnd, int from); /**
* Processes a received AnimationEnd message.
*
* @param msg the AnimationEnd message to be processed
* @param from the connection ID from which the message was received
*/
void received(AnimationEnd msg, int from);
void received(DeselectTSK deselectTSK , int from); /**
* Processes a received DeselectTSK message.
*
* @param msg the DeselectTSK message to be processed
* @param from the connection ID from which the message was received
*/
void received(DeselectTSK msg, int from);
void received(ForceStartGame forceStartGame, int from);
void received(JoinServer joinServer , int from); /**
* Processes a received ForceStartGame message.
*
* @param msg the ForceStartGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(ForceStartGame msg, int from);
void received(LeaveGame leaveGame , int from); /**
* Processes a received JoinServer message.
*
* @param msg the JoinServer message to be processed
* @param from the connection ID from which the message was received
*/
void received(JoinServer msg, int from);
void received(LobbyNotReady lobbyNotReady , int from); /**
* Processes a received LeaveGame message.
*
* @param msg the LeaveGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(LeaveGame msg, int from);
void received(LobbyReady lobbyReady , int from); /**
* Processes a received LobbyNotReady message.
*
* @param msg the LobbyNotReady message to be processed
* @param from the connection ID from which the message was received
*/
void received(LobbyNotReady msg, int from);
void received(RequestBriefing requestBriefing , int from); /**
* Processes a received LobbyReady message.
*
* @param msg the LobbyReady message to be processed
* @param from the connection ID from which the message was received
*/
void received(LobbyReady msg, int from);
void received(RequestDice requestDice , int from); /**
* Processes a received RequestBriefing message.
*
* @param msg the RequestBriefing message to be processed
* @param from the connection ID from which the message was received
*/
void received(RequestBriefing msg, int from);
void received(RequestMove requestMove , int from); /**
* Processes a received RequestDice message.
*
* @param msg the RequestDice message to be processed
* @param from the connection ID from which the message was received
*/
void received(RequestDice msg, int from);
void received(RequestPlayCard requestPlayCard , int from); /**
* Processes a received RequestMove message.
*
* @param msg the RequestMove message to be processed
* @param from the connection ID from which the message was received
*/
void received(RequestMove msg, int from);
void received(SelectCard selectCard , int from); /**
* Processes a received RequestPlayCard message.
*
* @param msg the RequestPlayCard message to be processed
* @param from the connection ID from which the message was received
*/
void received(RequestPlayCard msg, int from);
void received(SelectTSK selectTSK , int from); /**
* Processes a received SelectCard message.
*
* @param msg the SelectCard message to be processed
* @param from the connection ID from which the message was received
*/
void received(SelectCard msg, int from);
void received(ForceContinueGame forceContinueGame, int from); /**
* Processes a received SelectTSK message.
*
* @param msg the SelectTSK message to be processed
* @param from the connection ID from which the message was received
*/
void received(SelectTSK msg, int from);
void received(ClientStartGame clientStartGame, int from); /**
* Processes a received ForceContinueGame message.
*
* @param msg the ForceContinueGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(ForceContinueGame msg, int from);
void received(NoPowerCard noPowerCard, int from); /**
* Processes a received ClientStartGame message.
*
* @param msg the ClientStartGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(ClientStartGame msg, int from);
void received(SelectedPieces selectedPieces, int from); /**
* Processes a received NoPowerCard message.
*
* @param msg the NoPowerCard message to be processed
* @param from the connection ID from which the message was received
*/
void received(NoPowerCard msg, int from);
/**
* Processes a received SelectedPieces message.
*
* @param msg the SelectedPieces message to be processed
* @param from the connection ID from which the message was received
*/
void received(SelectedPieces msg, int from);
} }

View File

@@ -2,10 +2,23 @@
import com.jme3.network.AbstractMessage; import com.jme3.network.AbstractMessage;
/**
* An abstract base class for client messages used in network transfer.
* It extends the AbstractMessage class provided by the jme3-network library.
*/
public abstract class ClientMessage extends AbstractMessage { public abstract class ClientMessage extends AbstractMessage {
/**
* Constructs a new ClientMessage instance.
*/
protected ClientMessage() { protected ClientMessage() {
super(true); super(true);
} }
/**
* Accepts a visitor for processing this message.
*
* @param interpreter the visitor to be used for processing
* @param from the connection ID of the sender
*/
public abstract void accept(ClientInterpreter interpreter, int from); public abstract void accept(ClientInterpreter interpreter, int from);
} }

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the host to start the game.
*/
@Serializable
public class ClientStartGame extends ClientMessage { public class ClientStartGame extends ClientMessage {
@Override /**
public String toString() { * Constructs a new ClientStartGame instance.
return "null"; */
public ClientStartGame() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ClientStartGame{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,23 +1,53 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Color; import pp.mdga.game.Color;
/**
* A message sent by a client to deselect a TSK.
*/
@Serializable
public class DeselectTSK extends ClientMessage { public class DeselectTSK extends ClientMessage {
/**
* The color associated with the TSK to be deselected.
*/
private final Color color; private final Color color;
/**
* Constructs a new DeselectTSK message with the specified color.
*
* @param color the color associated with the TSK to be deselected
*/
public DeselectTSK(Color color) { public DeselectTSK(Color color) {
super();
this.color = color; this.color = color;
} }
/**
* Returns the color associated with the TSK to be deselected.
*
* @return the color associated with the TSK to be deselected
*/
public Color getColor() { public Color getColor() {
return color; return color;
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override @Override
public String toString() { public String toString() {
return "null"; return "DeselectTSK{" + "color=" + color + '}';
} }
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the host to force the continuation of the game, when the game was interrupted.
*/
@Serializable
public class ForceContinueGame extends ClientMessage { public class ForceContinueGame extends ClientMessage {
@Override /**
public String toString() { * Constructs a new ForceContinueGame message.
return "null"; */
public ForceContinueGame() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ForceContinueGame{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,15 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
public class ForceStartGame extends ClientMessage { import com.jme3.network.serializing.Serializable;
public ForceStartGame() {
/**
* A message sent by the host to force start the game when not everyone is ready or not everyone has selected a TSK.
*/
@Serializable
public class ForceStartGame extends ClientMessage {
/**
* Constructs a new ForceStartGame message.
*/
public ForceStartGame() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override @Override
public String toString() { public String toString() {
return "null"; return "ForceStartGame{}";
} }
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by a client when joining the server.
*/
@Serializable
public class JoinServer extends ClientMessage { public class JoinServer extends ClientMessage {
@Override /**
public String toString() { * Constructs a new JoinServer instance.
return "null"; */
public JoinServer() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "JoinServer{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by a client to leave the game.
*/
@Serializable
public class LeaveGame extends ClientMessage { public class LeaveGame extends ClientMessage {
@Override /**
public String toString() { * Constructs a new LeaveGame instance.
return "null"; */
public LeaveGame() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LeaveGame{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by a client to unready in the lobby.
*/
@Serializable
public class LobbyNotReady extends ClientMessage { public class LobbyNotReady extends ClientMessage {
@Override /**
public String toString() { * Constructs a new LobbyNotReady instance.
return "null"; */
public LobbyNotReady() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LobbyNotReady{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the client to ready-up in the lobby.
*/
@Serializable
public class LobbyReady extends ClientMessage { public class LobbyReady extends ClientMessage {
@Override /**
public String toString() { * Constructs a new LobbyReady instance.
return "null"; */
public LobbyReady() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LobbyReady{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by a client to indicate that the player is not using a power card.
*/
@Serializable
public class NoPowerCard extends ClientMessage { public class NoPowerCard extends ClientMessage {
@Override /**
public String toString() { * Constructs a new NoPowerCard instance.
return "null"; */
public NoPowerCard() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "NoPowerCard{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by a client to request a briefing from the server. (after a reconnect)
*/
@Serializable
public class RequestBriefing extends ClientMessage { public class RequestBriefing extends ClientMessage {
@Override /**
public String toString() { * Constructs a new RequestBriefing instance.
return "null"; */
public RequestBriefing() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "RequestBriefing{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,11 +1,35 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by a client to request a die roll.
*/
@Serializable
public class RequestDice extends ClientMessage { public class RequestDice extends ClientMessage {
@Override /**
public String toString() { * Constructs a new RequestDice instance.
return "null"; */
public RequestDice() {
super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "RequestDice{}";
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,30 +1,49 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import pp.mdga.game.Color; import com.jme3.network.serializing.Serializable;
/**
* A message sent by a client to request a move for a piece.
*/
@Serializable
public class RequestMove extends ClientMessage { public class RequestMove extends ClientMessage {
/**
* The identifier for the piece.
*/
private final String pieceIdentifier; private final String pieceIdentifier;
/** Constructor for RequestMove /**
* Constructor for RequestMove
* @param pieceIdentifier the piece identifier * @param pieceIdentifier the piece identifier
*/ */
public RequestMove(String pieceIdentifier) { public RequestMove(String pieceIdentifier) {
this.pieceIdentifier = pieceIdentifier; this.pieceIdentifier = pieceIdentifier;
} }
/** Getter for the piece identifier /**
* Getter for the piece identifier
* @return the piece identifier * @return the piece identifier
*/ */
public String getPieceIdentifier() { public String getPieceIdentifier() {
return pieceIdentifier; return pieceIdentifier;
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override @Override
public String toString() { public String toString() {
return pieceIdentifier; return "RequestMove{pieceIdentifier = " + pieceIdentifier + '}';
} }
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,30 +1,68 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
/**
* A message sent by a client to request playing a bonus card.
*/
@Serializable
public class RequestPlayCard extends ClientMessage { public class RequestPlayCard extends ClientMessage {
/**
* The bonus card to be played.
*/
private final BonusCard card; private final BonusCard card;
/**
* The identifier of the piece.
*/
private final String pieceIdentifier; private final String pieceIdentifier;
/**
* Constructs a new RequestPlayCard instance.
*
* @param card the bonus card to be played
* @param pieceIdentifier the identifier of the piece
*/
public RequestPlayCard(BonusCard card, String pieceIdentifier) { public RequestPlayCard(BonusCard card, String pieceIdentifier) {
this.pieceIdentifier = pieceIdentifier; this.pieceIdentifier = pieceIdentifier;
this.card = card; this.card = card;
} }
/**
* Gets the bonus card associated with this request.
*
* @return the bonus card
*/
public BonusCard getCard() { public BonusCard getCard() {
return card; return card;
} }
/**
* Gets the piece identifier associated with this request.
*
* @return the piece identifier
*/
public String getPieceIdentifier() { public String getPieceIdentifier() {
return pieceIdentifier; return pieceIdentifier;
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override @Override
public String toString() { public String toString() {
return card.toString(); return "RequestPlayCard={card=" + card.toString() + '}';
} }
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,24 +1,52 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
/**
* A message sent from the client to the server to select a bonus card.
*/
@Serializable
public class SelectCard extends ClientMessage { public class SelectCard extends ClientMessage {
/**
* The bonus card to be selected.
*/
private final BonusCard card; private final BonusCard card;
/**
* Constructs a new SelectCard instance.
*
* @param card the bonus card to be selected
*/
public SelectCard(BonusCard card) { public SelectCard(BonusCard card) {
this.card = card; this.card = card;
} }
/**
* Gets the bonus card associated with this selection.
*
* @return the bonus card
*/
public BonusCard getCard() { public BonusCard getCard() {
return card; return card;
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override @Override
public String toString() { public String toString() {
return "null"; return "SelectCard{card=" + card + '}';
} }
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,7 +1,9 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Color; import pp.mdga.game.Color;
@Serializable
public class SelectTSK extends ClientMessage { public class SelectTSK extends ClientMessage {
private final Color color; private final Color color;
@@ -14,11 +16,22 @@ public Color getColor() {
return color; return color;
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override @Override
public String toString() { public String toString() {
return "null"; return "SelectTSK{color=" + color + '}';
} }
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);

View File

@@ -1,30 +1,49 @@
package pp.mdga.message.client; package pp.mdga.message.client;
import pp.mdga.game.Color; import com.jme3.network.serializing.Serializable;
/**
* A message sent by a client to indicate that a piece has been selected for a bonus cards.
*/
@Serializable
public class SelectedPieces extends ClientMessage { public class SelectedPieces extends ClientMessage {
/**
* The piece identifier.
*/
private String pieceIdentifier; private String pieceIdentifier;
/** Constructor for SelectedPieces /**
* Constructor for SelectedPieces
* @param pieceIdentifier the piece identifier * @param pieceIdentifier the piece identifier
*/ */
public SelectedPieces(String pieceIdentifier) { public SelectedPieces(String pieceIdentifier) {
this.pieceIdentifier = pieceIdentifier; this.pieceIdentifier = pieceIdentifier;
} }
/** Getter for the piece identifier /**
* Getter for the piece identifier
* @return the piece identifier * @return the piece identifier
*/ */
public String getPieceIdentifier() { public String getPieceIdentifier() {
return pieceIdentifier; return pieceIdentifier;
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override @Override
public String toString() { public String toString() {
return "null"; return "SelectedPieces{pieceIdentifier=" + pieceIdentifier + '}';
} }
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
* @param from the connection ID from which the message was received
*/
@Override @Override
public void accept(ClientInterpreter interpreter, int from) { public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from); interpreter.received(this, from);