reverted server messages

This commit is contained in:
Daniel Grigencha
2024-11-25 16:14:15 +01:00
parent 52d9fff493
commit 9759b6871b
29 changed files with 1994 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Color;
/**
* A message sent by the server to inform the clients about the active player.
*/
@Serializable
public class ActivePlayer extends ServerMessage {
/**
* The color of the active player.
*/
private final Color color;
/**
* Constructor for ActivePlayer
*
* @param color the color of the active player
*/
public ActivePlayer(Color color) {
super();
this.color = color;
}
/**
* Default constructor for serialization purposes.
*/
private ActivePlayer() {
color = null;
}
/**
* Getter for the color of the active player
*
* @return the color of the active player
*/
public Color getColor() {
return color;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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 "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

@@ -0,0 +1,73 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* A message sent by the server to the active player containing a list of pieces that the player can move any piece of the list on the board.
*/
@Serializable
public class AnyPiece extends ServerMessage {
/**
* The list of pieces
*/
private final ArrayList<String> piece;
/**
* Constructor for AnyPiece
*/
public AnyPiece() {
super();
piece = new ArrayList<>();
}
/**
* Add a piece to the list of pieces
*
* @param piece the piece to add
*/
public void addPiece(String piece) {
this.piece.add(piece);
}
/**
* Getter for the list of pieces
*
* @return the list of pieces
*/
public List<String> getPiece() {
return piece;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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 "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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to the reconnected player to provide a briefing about the current game state.
*/
@Serializable
public class Briefing extends ServerMessage {
/**
* Constructs a new Briefing instance.
*/
public Briefing() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to indicate the beginning of the ceremony.
*/
@Serializable
public class CeremonyMessage extends ServerMessage {
/**
* Constructs a new Ceremony instance.
*/
public CeremonyMessage() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,110 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import java.util.List;
/**
* A message sent by the server to the client to inform about the dice roll.
*/
@Serializable
public class Dice extends ServerMessage {
/**
* The eye of the dice
*/
private final int diceEye;
/**
* The pieces that can be moved
*/
private final List<String> moveablePieces;
/**
* Constructor for Dice
*
* @param diceEye the eye of the dice
* @param moveablePieces the pieces that can be moved
*/
public Dice(int diceEye, List<String> moveablePieces) {
super();
this.diceEye = diceEye;
this.moveablePieces = moveablePieces;
}
/**
* Default constructor for serialization purposes.
*/
private Dice() {
diceEye = 0;
moveablePieces = null;
}
/**
* Constructor for inactivePlayer
*
* @param diceEye the eye of the dice
* @return a new Dice object
*/
public static Dice inactivePlayer(int diceEye) {
return new Dice(diceEye, null);
}
/**
* Constructor for activePlayer
*
* @param diceEye the eye of the dice
* @param moveablePieces the pieces that can be moved
* @return a new Dice object
*/
public static Dice activePlayer(int diceEye, List<String> moveablePieces) {
return new Dice(diceEye, moveablePieces);
}
/**
* Getter for the eye of the dice
*
* @return the eye of the dice
*/
public int getDiceEye() {
return diceEye;
}
/**
* Getter for the pieces that can be moved
*
* @return the pieces that can be moved
*/
public List<String> getMoveablePieces() {
return moveablePieces;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to the active player to indicate that they can roll the dice again.
*/
@Serializable
public class DiceAgain extends ServerMessage {
/**
* Constructs a new DiceAgain instance.
*/
public DiceAgain() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to the active player to enable the dice now button.
*/
@Serializable
public class DiceNow extends ServerMessage {
/**
* Constructs a new DiceNow instance.
*/
public DiceNow() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to indicate the end of the turn of the active player.
*/
@Serializable
public class EndOfTurn extends ServerMessage {
/**
* Constructs a new EndOfTurn instance.
*/
public EndOfTurn() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to indicate that the client has been accepted into the lobby.
*/
@Serializable
public class LobbyAccept extends ServerMessage {
/**
* Constructs a new LobbyAccept instance.
*/
public LobbyAccept() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to deny a client's request to join the lobby.
*/
@Serializable
public class LobbyDeny extends ServerMessage {
/**
* Constructs a new LobbyDeny instance.
*/
public LobbyDeny() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,71 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent from the server to the client indicating that a player has joined the lobby.
*/
@Serializable
public class LobbyPlayerJoin extends ServerMessage {
/**
* The name of the player joining the lobby.
*/
private final String name;
/**
* Constructs a new LobbyPlayerJoin instance with the specified player name.
*
* @param name the name of the player joining the lobby
*/
public LobbyPlayerJoin(String name) {
super();
this.name = name;
}
/**
* Default constructor for serialization purposes.
*/
private LobbyPlayerJoin() {
name = null;
}
/**
* Returns the name of the player joining the lobby.
*
* @return the name of the player joining the lobby
*/
public String getName() {
return name;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,88 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Color;
/**
* A message sent by the server to indicate that a player has left the lobby.
*/
@Serializable
public class LobbyPlayerLeave extends ServerMessage {
/**
* The name of the player leaving the lobby.
*/
private final String name;
/**
* The color associated with the player leaving the lobby.
*/
private final Color color;
/**
* Constructs a new LobbyPlayerLeave instance with the specified player name and color.
*
* @param name the name of the player leaving the lobby
* @param color the color associated with the player leaving the lobby
*/
public LobbyPlayerLeave(String name, Color color) {
super();
this.name = name;
this.color = color;
}
/**
* Default constructor for serialization purposes.
*/
private LobbyPlayerLeave() {
name = null;
color = null;
}
/**
* Returns the name of the player leaving the lobby.
*
* @return the name of the player leaving the lobby
*/
public String getName() {
return name;
}
/**
* Returns the color associated with the player leaving the lobby.
*
* @return the color associated with the player leaving the lobby
*/
public Color getColor() {
return color;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,70 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to the client to move a piece on the board.
*/
@Serializable
public class MoveMessage extends ServerMessage {
/**
* The identifier of the piece that should be moved.
*/
private final String pieceIdentifier;
/**
* Constructs a new MoveMessage instance.
*
* @param identifier the identifier of the piece that should be moved
*/
public MoveMessage(String identifier) {
super();
this.pieceIdentifier = identifier;
}
/**
* Default constructor for serialization purposes.
*/
private MoveMessage() {
pieceIdentifier = null;
}
/**
* Returns the identifier of the piece that should be moved.
*
* @return the identifier of the piece that should be moved
*/
public String getIdentifier() {
return pieceIdentifier;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to the active player to indicate that he has no valid moves.
*/
@Serializable
public class NoTurn extends ServerMessage {
/**
* Constructs a new NoTurn instance.
*/
public NoTurn() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to indicate that the game is paused.
*/
@Serializable
public class PauseGame extends ServerMessage {
/**
* Constructs a new PauseGame instance.
*/
public PauseGame() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,131 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard;
/**
* A message sent by the server to the active player to play a card.
*/
@Serializable
public class PlayCard extends ServerMessage {
/**
* The card that should be played.
*/
private final BonusCard card;
/**
* The identifier of the piece that should be moved.
*/
private final String pieceIdentifier;
private final String pieceIdentifierEnemy;
/**
* Constructs a new PlayCard message.
*
* @param card the card that should be played
* @param pieceIdentifier the identifier of the piece that should be moved
*/
public PlayCard(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) {
super();
this.card = card;
this.pieceIdentifier = pieceIdentifier;
this.pieceIdentifierEnemy = pieceIdentifierEnemy;
}
/**
* Default constructor for serialization purposes.
*/
private PlayCard() {
this.pieceIdentifierEnemy = null;
card = null;
pieceIdentifier = null;
}
/**
* Creates a new PlayCard message for the given card and piece identifier.
*
* @param pieceIdentifier the identifier of the piece of the player that should be affected
* @param pieceIdentifierEnemy the identifier of the enemy piece that should be affected
* @return a new PlayCard message
*/
public static PlayCard swap(String pieceIdentifier, String pieceIdentifierEnemy) {
return new PlayCard(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy);
}
/**
* Creates a new PlayCard message for the given card and piece identifier.
*
* @return a new PlayCard message
*/
public static PlayCard turbo() {
return new PlayCard(BonusCard.TURBO, null, null);
}
/**
* Creates a new PlayCard message for the given card and piece identifier.
*
* @param pieceIdentifier the identifier of the piece of the player that should be affected
* @return a new PlayCard message
*/
public static PlayCard shield(String pieceIdentifier) {
return new PlayCard(BonusCard.SHIELD, pieceIdentifier, null);
}
/**
* Returns the card that should be played.
*
* @return the card that should be played
*/
public BonusCard getCard() {
return card;
}
/**
* Returns the identifier of the piece that should be moved.
*
* @return the identifier of the piece that should be moved
*/
public String getPieceIdentifier() {
return pieceIdentifier;
}
/**
* Returns the identifier of the enemy piece that should be moved.
*
* @return the identifier of the enemy piece that should be moved
*/
public String getPieceIdentifierEnemy() {
return pieceIdentifierEnemy;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,74 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard;
import java.util.ArrayList;
import java.util.List;
/**
* A message sent by the server to the client to indicate the possible cards that can be chosen.
*/
@Serializable
public class PossibleCard extends ServerMessage {
/**
* The list of possible cards.
*/
private final List<BonusCard> possibleCards;
/**
* Constructor for a PossibleCard instance.
*/
public PossibleCard() {
super();
possibleCards = new ArrayList<>();
}
/**
* Add a possible card to the list of possible cards
*
* @param card the possible card to add
*/
public void addPossibleCard(BonusCard card) {
this.possibleCards.add(card);
}
/**
* Getter for the list of possible cards
*
* @return the list of possible cards
*/
public List<BonusCard> getPossibleCards() {
return possibleCards;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,119 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* A message sent by the server to the active player to give all possible pieces to choose from.
*/
@Serializable
public class PossiblePiece extends ServerMessage {
/**
* The list of possible own pieces
*/
private final List<String> possibleOwnPieces;
/**
* The list of possible enemy pieces
*/
private final List<String> possibleEnemyPieces;
/**
* Constructor for PossiblePiece
*/
public PossiblePiece() {
super();
possibleOwnPieces = new ArrayList<>();
possibleEnemyPieces = new ArrayList<>();
}
/**
* Swap the possible pieces
*
* @param possibleOwnPieces the list of possible own pieces
* @param possibleEnemyPieces the list of possible enemy pieces
* @return the swapped possible pieces
*/
public static PossiblePiece swapPossiblePieces(ArrayList<String> possibleOwnPieces, ArrayList<String> possibleEnemyPieces) {
PossiblePiece possiblePiece = new PossiblePiece();
possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces);
possiblePiece.possibleEnemyPieces.addAll(possibleEnemyPieces);
return possiblePiece;
}
/**
* Get the possible pieces for the shield
*
* @param possibleOwnPieces the list of possible own pieces
* @return the possible pieces for the shield
*/
public static PossiblePiece shieldPossiblePieces(ArrayList<String> possibleOwnPieces){
PossiblePiece possiblePiece = new PossiblePiece();
possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces);
return possiblePiece;
}
/**
* Add a piece to the list of possible pieces
*
* @param piece the piece to add
*/
public void addOwnPossiblePiece(String piece) {
this.possibleOwnPieces.add(piece);
}
/**
* Add a piece to the list of possible enemy pieces
*
* @param piece the piece to add
*/
public void addEnemyPossiblePiece(String piece) {
this.possibleEnemyPieces.add(piece);
}
/** Getter for the list of possible pieces
* @return the list of possible pieces
*/
public List<String> getOwnPossiblePieces() {
return possibleOwnPieces;
}
/** Getter for the list of possible enemy pieces
* @return the list of possible enemy pieces
*/
public List<String> getEnemyPossiblePieces() {
return possibleEnemyPieces;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to all client to inform them about the current ranking. (only in DetermineStartPlayer)
*/
@Serializable
public class RankingResponse extends ServerMessage {
/**
* Constructs a new RankingResponse instance.
*/
public RankingResponse() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to the clients to indicate that the ranking shall be rolled again. (only in DetermineStartPlayer)
*/
@Serializable
public class RankingRollAgain extends ServerMessage {
/**
* Constructs a new RankingRollAgain instance.
*/
public RankingRollAgain() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,69 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Game;
/**
* A message sent by the server to a client that has reconnected to the game. (give the last saved model)
*/
@Serializable
public class ReconnectBriefing extends ServerMessage {
/**
* The game.
*/
private final Game game;
/**
* Constructs a new ReconnectBriefing message.
*/
public ReconnectBriefing(Game game) {
super();
this.game = game;
}
/**
* Default constructor for serialization purposes.
*/
private ReconnectBriefing() {
this(null);
}
/**
* Returns the game.
*
* @return the game
*/
public Game getGame() {
return game;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to resume the game.
*/
@Serializable
public class ResumeGame extends ServerMessage {
/**
* Constructs a new ResumeGame instance.
*/
public ResumeGame() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,196 @@
package pp.mdga.message.server;
/**
* An interface for processing server messages.
* Implementations of this interface can be used to handle different types of server messages.
*/
public interface ServerInterpreter {
/**
* Handles an ActivePlayer message received from the server.
*
* @param msg the ActivePlayer message received
*/
void received(ActivePlayer msg);
/**
* Handles an AnyPiece message received from the server.
*
* @param msg the AnyPiece message received
*/
void received(AnyPiece msg);
/**
* Handles a Briefing message received from the server.
*
* @param msg the Briefing message received
*/
void received(Briefing msg);
/**
* Handles a Ceremony message received from the server.
*
* @param msg the Ceremony message received
*/
void received(CeremonyMessage msg);
/**
* Handles a Dice message received from the server.
*
* @param msg the Dice message received
*/
void received(Dice msg);
/**
* Handles a DiceAgain message received from the server.
*
* @param msg the DiceAgain message received
*/
void received(DiceAgain msg);
/**
* Handles a DiceNow message received from the server.
*
* @param msg the DiceNow message received
*/
void received(DiceNow msg);
/**
* Handles an EndOfGame message received from the server.
*
* @param msg the EndOfGame message received
*/
void received(EndOfTurn msg);
/**
* Handles a GameOver message received from the server.
*
* @param msg the GameOver message received
*/
void received(LobbyAccept msg);
/**
* Handles a LobbyDeny message received from the server.
*
* @param msg the LobbyDeny message received
*/
void received(LobbyDeny msg);
/**
* Handles a LobbyPlayerJoin message received from the server.
*
* @param msg the LobbyPlayerJoin message received
*/
void received(LobbyPlayerJoin msg);
/**
* Handles a LobbyPlayerLeave message received from the server.
*
* @param msg the LobbyPlayerLeave message received
*/
void received(LobbyPlayerLeave msg);
/**
* Handles a MoveMessage message received from the server.
*
* @param msg the MoveMessage message received
*/
void received(MoveMessage msg);
/**
* Handles a NoTurn message received from the server.
*
* @param msg the NoTurn message received
*/
void received(NoTurn msg);
/**
* Handles a PauseGame message received from the server.
*
* @param msg the PauseGame message received
*/
void received(PauseGame msg);
/**
* Handles a PlayCard message received from the server.
*
* @param msg the PlayCard message received
*/
void received(PlayCard msg);
/**
* Handles a PossibleCard message received from the server.
*
* @param msg the PossibleCard message received
*/
void received(PossibleCard msg);
/**
* Handles a PossiblePiece message received from the server.
*
* @param msg the PossiblePiece message received
*/
void received(PossiblePiece msg);
/**
* Handles a RankingResponce message received from the server.
*
* @param msg the RankingResponce message received
*/
void received(RankingResponse msg);
/**
* Handles a RankingRollAgain message received from the server.
*
* @param msg the RankingRollAgain message received
*/
void received(RankingRollAgain msg);
/**
* Handles a ReconnectBriefing message received from the server.
*
* @param msg the ReconnectBriefing message received
*/
void received(ReconnectBriefing msg);
/**
* Handles a ResumeGame message received from the server.
*
* @param msg the ResumeGame message received
*/
void received(ResumeGame msg);
/**
* Handles a ServerStartGame message received from the server.
*
* @param msg the ServerStartGame message received
*/
void received(ServerStartGame msg);
/**
* Handles a StartPiece message received from the server.
*
* @param msg the StartPiece message received
*/
void received(StartPiece msg);
/**
* Handles a UpdateReady message received from the server.
*
* @param msg the UpdateReady message received
*/
void received(UpdateReady msg);
/**
* Handles a UpdateTSK message received from the server.
*
* @param msg the UpdateTSK message received
*/
void received(UpdateTSK msg);
/**
* Handles a WaitPiece message received from the server.
*
* @param msg the WaitPiece message received
*/
void received(WaitPiece msg);
}

View File

@@ -0,0 +1,31 @@
package pp.mdga.message.server;
import com.jme3.network.AbstractMessage;
/**
* An abstract base class for server messages used in network transfer.
* It extends the AbstractMessage class provided by the jme3-network library.
*/
public abstract class ServerMessage extends AbstractMessage {
/**
* Constructs a new ServerMessage instance.
*/
protected ServerMessage() {
super(true);
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
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.
*
* @return the bundle key of the informational text
*/
public abstract String getInfoTextKey();
}

View File

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message indicating that the game shall start.
*/
@Serializable
public class ServerStartGame extends ServerMessage {
/**
* Constructs a new ServerStartGame instance.
*/
public ServerStartGame() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,71 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to the active player that he has to move a start piece.
*/
@Serializable
public class StartPiece extends ServerMessage {
/**
* The identifier for the piece.
*/
private final String pieceIdentifier;
/**
* Constructs a new StartPiece instance with the specified piece identifier.
*
* @param pieceIdentifier the identifier for the piece
*/
public StartPiece(String pieceIdentifier) {
super();
this.pieceIdentifier = pieceIdentifier;
}
/**
* Default constructor for serialization purposes.
*/
private StartPiece() {
super();
this.pieceIdentifier = "";
}
/**
* Gets the identifier for the piece.
*
* @return the piece identifier
*/
public String getPieceIdentifier() {
return pieceIdentifier;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,89 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Color;
/**
* A message sent by the server to every client to update the readiness status of a player.
*/
@Serializable
public class UpdateReady extends ServerMessage {
/**
* The color associated with the update.
*/
private final Color color;
/**
* Indicates whether the player is ready.
*/
private final boolean ready;
/**
* Constructs a new UpdateReady instance with the specified color and readiness status.
*
* @param color the color associated with the update
* @param ready the readiness status
*/
public UpdateReady(Color color, boolean ready) {
super();
this.color = color;
this.ready = ready;
}
/**
* Default constructor for serialization purposes.
*/
private UpdateReady() {
super();
this.color = null;
this.ready = false;
}
/**
* Gets the color associated with the update.
*
* @return the color
*/
public Color getColor() {
return color;
}
/**
* Checks if the player is ready.
*
* @return true if the player is ready, false otherwise
*/
public boolean isReady() {
return ready;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,87 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Color;
/**
* A message sent by the server to every client to update the TSK.
*/
@Serializable
public class UpdateTSK extends ServerMessage {
/**
* The name associated with the update.
*/
private final String name;
/**
* The color associated with the update.
*/
private final Color color;
/**
* Constructs a new UpdateTSK instance with the specified name and color.
*
* @param name the name associated with the update
* @param color the color associated with the update
*/
public UpdateTSK(String name, Color color) {
super();
this.name = name;
this.color = color;
}
/**
* Default constructor for serialization purposes.
*/
private UpdateTSK() {
this("", null);
}
/**
* Gets the name associated with the update.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets the color associated with the update.
*
* @return the color
*/
public Color getColor() {
return color;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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

@@ -0,0 +1,46 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to the active player to choose a piece from the waiting area.
*/
@Serializable
public class WaitPiece extends ServerMessage {
/**
* Constructs a new WaitPiece instance.
*/
public WaitPiece() {
super();
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
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 "";
}
}