removed from every Message the getInfoTest method and only overrode the toString method in messages with content, in every other message it is handled through the parent class

This commit is contained in:
Hanno Fleischer
2024-12-04 11:07:55 +01:00
parent 29711d6210
commit de899cef35
47 changed files with 61 additions and 533 deletions

View File

@@ -66,4 +66,9 @@ public Node[] getInfield() {
public void setPieceOnBoard(int index, Piece piece) {
infield[index].setOccupant(piece);
}
@Override
public String toString(){
return "Default Board";
}
}

View File

@@ -254,4 +254,9 @@ public void setActive(boolean active) {
public void setPieceInHome(int index, Piece piece) {
this.homeNodes[index].setOccupant(piece);
}
@Override
public String toString(){
return "Player: " + name + " Color: " + color;
}
}

View File

@@ -14,16 +14,6 @@ public AnimationEndMessage() {
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.
*

View File

@@ -21,4 +21,8 @@ protected ClientMessage() {
* @param from the connection ID of the sender
*/
public abstract void accept(ClientInterpreter interpreter, int from);
public String toString() {
return getClass().getSimpleName() + "{}";
}
}

View File

@@ -24,14 +24,4 @@ public ClientStartGameMessage() {
public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from);
}
/**
* This method will be used to return all necessary information of StartGameMessage in a more readable way.
*
* @return information as a String.
*/
@Override
public String toString() {
return "ClientStartGameMessage{}";
}
}

View File

@@ -11,16 +11,6 @@ public DisconnectedMessage() {
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.
*

View File

@@ -14,16 +14,6 @@ public ForceContinueGameMessage() {
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.
*

View File

@@ -42,7 +42,7 @@ public String getName(){
*/
@Override
public String toString() {
return "JoinServer{}";
return "JoinServer {" + "name=" + name + '}';
}
/**

View File

@@ -14,16 +14,6 @@ public LeaveGameMessage() {
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.
*

View File

@@ -14,16 +14,6 @@ public LobbyNotReadyMessage() {
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.
*

View File

@@ -14,16 +14,6 @@ public LobbyReadyMessage() {
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.
*

View File

@@ -14,16 +14,6 @@ public NoPowerCardMessage() {
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.
*

View File

@@ -14,16 +14,6 @@ public RequestBriefingMessage() {
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.
*

View File

@@ -14,16 +14,6 @@ public RequestDieMessage() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "RequestDie{}";
}
/**
* Accepts a visitor to process this message.
*

View File

@@ -98,7 +98,8 @@ public UUID getEnemyPieceIdentifier() {
*/
@Override
public String toString() {
return "RequestPlayCard={card=" + card.toString() + '}';
assert card != null;
return "RequestPlayCard={card=" + card + '}';
}
/**

View File

@@ -58,14 +58,4 @@ public void accept(ServerInterpreter interpreter) {
public String toString() {
return "ActivePlayer{color=" + color + '}';
}
/**
* Returns the key for the informational text associated with this message.
*
* @return the key for the informational text
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -61,14 +61,4 @@ public void accept(ServerInterpreter interpreter) {
public String toString() {
return "AnyPiece{piece=" + piece + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -23,24 +23,4 @@ public BriefingMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -23,24 +23,4 @@ public CeremonyMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -23,24 +23,4 @@ public DiceAgainMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -23,24 +23,4 @@ public DiceNowMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -57,16 +57,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "DieMessage{" + "diceEye=" + diceEye + '}';
}
}

View File

@@ -23,24 +23,4 @@ public EndOfTurnMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -34,18 +34,6 @@ public IncorrectRequestMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Gets the bundle key of the informational text to be shown at the client.
* This key is used to retrieve the appropriate localized text for display.
*
* @return the bundle key of the informational text
*/
@Override
public String getInfoTextKey() {
return "";
}
/**
* This method will be used to return necessary class information in a more readable format.
*

View File

@@ -39,7 +39,6 @@ public int getHost() {
return this.host;
}
/**
* Accepts a visitor to process this message.
*
@@ -51,22 +50,12 @@ public void accept(ServerInterpreter interpreter) {
}
/**
* Returns a string representation of this message.
* This method will be used to return necessary class information in a more readable format.
*
* @return a string representation of this message
* @return information as a String.
*/
@Override
public String toString() {
return "Lobby Accept";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "LobbyAcceptMessage with host: %d".formatted(this.host);
}
}

View File

@@ -23,24 +23,4 @@ public LobbyDenyMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LobbyDeny";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -79,23 +79,8 @@ public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "LobbyPlayerJoinedMessage{" + "player=" + player + ", id=" + id + ", host=" + host + '}';
}
}

View File

@@ -56,16 +56,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "LobbyPlayerLeaveMessage{" + "id=" + id + '}';
}
}

View File

@@ -89,16 +89,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "MoveMessage{" + "pieceUUID=" + pieceUUID + ", targetIndex=" + targetIndex + ", isHomeMove=" + isHomeMove + '}';
}
}

View File

@@ -23,24 +23,4 @@ public NoTurnMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -54,16 +54,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "PauseGameMessage{" + "playerId=" + playerId + '}';
}
}

View File

@@ -135,16 +135,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "PlayCardMessage{" + "card=" + card + ", ownPieceID=" + ownPieceID + ", enemyPieceID=" + enemyPieceID + ", diceModifier=" + diceModifier + '}';
}
}

View File

@@ -59,16 +59,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "PossibleCardMessage{" + "possibleCards=" + possibleCards + '}';
}
}

View File

@@ -50,7 +50,7 @@ public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOw
* @param possibleOwnPieces the list of possible own pieces
* @return the possible pieces for the shield
*/
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces){
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces) {
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
return possiblePieceMessage;
@@ -74,14 +74,18 @@ public void addEnemyPossiblePiece(UUID piece) {
this.possibleEnemyPieces.add(piece);
}
/** Getter for the list of possible pieces
/**
* Getter for the list of possible pieces
*
* @return the list of possible pieces
*/
public List<UUID> getOwnPossiblePieces() {
return possibleOwnPieces;
}
/** Getter for the list of possible enemy pieces
/**
* Getter for the list of possible enemy pieces
*
* @return the list of possible enemy pieces
*/
public List<UUID> getEnemyPossiblePieces() {
@@ -105,16 +109,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "PossiblePieceMessage{" + "possibleOwnPieces=" + possibleOwnPieces + ", possibleEnemyPieces=" + possibleEnemyPieces + '}';
}
}

View File

@@ -52,16 +52,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "RankingResponseMessage{" + "startingPlayerId=" + startingPlayerId + '}';
}
}

View File

@@ -23,24 +23,4 @@ public RankingRollAgainMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -54,16 +54,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "ReconnectBriefingMessage{" + "game=" + game + '}';
}
}

View File

@@ -23,24 +23,4 @@ public ResumeGameMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -77,7 +77,7 @@ public void accept(ServerInterpreter interpreter) {
* @return a string representation of this message
*/
@Override
public String getInfoTextKey() {
return "";
public String toString() {
return "SelectPieceMessage{" + "pieces=" + pieces + ", isHomeMove=" + isHomeMove + ", targetIndex=" + targetIndex + '}';
}
}

View File

@@ -22,10 +22,12 @@ protected ServerMessage() {
public abstract void accept(ServerInterpreter interpreter);
/**
* Gets the bundle key of the informational text to be shown at the client.
* This key is used to retrieve the appropriate localized text for display.
* Returns a string representation of this message.
*
* @return the bundle key of the informational text
* @return a string representation of this message
*/
public abstract String getInfoTextKey();
@Override
public String toString() {
return getClass().getSimpleName() + "{}";
}
}

View File

@@ -74,16 +74,7 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
return "ServerStartGameMessage{" + "players=" + players + ", board=" + board + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -16,15 +16,4 @@ public class ShutdownMessage extends ServerMessage {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
* Gets the bundle key of the informational text to be shown at the client.
* This key is used to retrieve the appropriate localized text for display.
*
* @return the bundle key of the informational text
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -5,7 +5,7 @@
*/
public class SpectatorMessage extends ServerMessage {
/**
* Construc
* Constructor
*/
public SpectatorMessage() {
super();
@@ -19,14 +19,4 @@ public SpectatorMessage() {
public void accept(ServerInterpreter interpreter) {
interpreter.received(this);
}
/**
*
* @return
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -75,16 +75,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "StartPieceMessage{" + "pieceIdentifier=" + pieceIdentifier + ", targetIndex=" + targetIndex + '}';
}
}

View File

@@ -73,16 +73,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "UpdateReadyMessage{" + "playerId=" + playerId + ", ready=" + ready + '}';
}
}

View File

@@ -58,6 +58,15 @@ public Color getColor() {
return color;
}
/**
* Checks if the TSK is taken.
*
* @return true if the TSK is taken, false otherwise
*/
public boolean isTaken() {
return isTaken;
}
/**
* Accepts a visitor to process this message.
*
@@ -75,20 +84,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
public boolean isTaken() {
return isTaken;
return "UpdateTSKMessage{" + "id=" + id + ", color=" + color + '}';
}
}

View File

@@ -54,16 +54,6 @@ public void accept(ServerInterpreter interpreter) {
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
return "WaitPieceMessage{" + "pieceID=" + pieceID + '}';
}
}