merge development into test #26
@@ -114,7 +114,7 @@ private void initializeSerializables() {
|
||||
Serializer.registerClass(EndOfTurnMessage.class);
|
||||
Serializer.registerClass(LobbyAcceptMessage.class);
|
||||
Serializer.registerClass(LobbyDenyMessage.class);
|
||||
Serializer.registerClass(LobbyPlayerJoinMessage.class);
|
||||
Serializer.registerClass(LobbyPlayerJoinedMessage.class);
|
||||
Serializer.registerClass(LobbyPlayerLeaveMessage.class);
|
||||
Serializer.registerClass(MoveMessage.class);
|
||||
Serializer.registerClass(NoTurnMessage.class);
|
||||
|
||||
@@ -125,7 +125,7 @@ public void received(LobbyDenyMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg) {
|
||||
public void received(LobbyPlayerJoinedMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public void received(LobbyDenyMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg) {
|
||||
public void received(LobbyPlayerJoinedMessage msg) {
|
||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import pp.mdga.client.dialogState.NetworkDialogState;
|
||||
import pp.mdga.client.dialogState.StartDialogState;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
public class DialogsState extends ClientState {
|
||||
@@ -112,7 +111,7 @@ public void selectHost(String name){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg){
|
||||
public void received(LobbyPlayerJoinedMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.LobbyPlayerJoinMessage;
|
||||
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
|
||||
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
||||
import pp.mdga.message.server.ServerStartGameMessage;
|
||||
import pp.mdga.message.server.UpdateReadyMessage;
|
||||
@@ -74,8 +74,8 @@ public void received(ServerStartGameMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg){
|
||||
logic.getGame().getPlayers().put(msg.getId(), new Player(msg.getName()));
|
||||
public void received(LobbyPlayerJoinedMessage msg){
|
||||
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,16 +21,16 @@ protected void handlePowerCard(PlayCardMessage msg){
|
||||
if (msg.getCard().equals(BonusCard.TURBO)){
|
||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||
} else if (msg.getCard().equals(BonusCard.SHIELD)){
|
||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier())) % 10 != 0) {
|
||||
logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid()));
|
||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
|
||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||
} else {
|
||||
logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid()));
|
||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||
}
|
||||
} else {
|
||||
Piece ownPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier());
|
||||
Piece enemyPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifierEnemy());
|
||||
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
||||
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
|
||||
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
|
||||
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
|
||||
|
||||
@@ -60,7 +60,7 @@ public void received(ActivePlayerMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier());
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||
if (msg.isHomeMove()){
|
||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
||||
|
||||
@@ -66,7 +66,7 @@ public void received(ActivePlayerMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier());
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||
if (msg.isHomeMove()){
|
||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
||||
|
||||
@@ -35,7 +35,7 @@ public void exit() {
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg) {
|
||||
parent.setState(parent.getSelectPiece());
|
||||
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new));
|
||||
parent.getSelectPiece().setPossiblePieces(pieces);
|
||||
logic.addNotification(new SelectableMoveNotification(pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new)), msg.getTargetIndex(), msg.getIsHomeMove()));
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public void received(WaitPieceMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
Piece piece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier());
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
||||
//TODO: logic.addNotification(null);
|
||||
parent.setState(parent.getStartPiece());
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ public void setPossiblePieces(ArrayList<Piece> possiblePieces){
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if(possiblePieces.contains(piece)){
|
||||
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
|
||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
Piece piece = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier());
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||
if(msg.isHomeMove()){
|
||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
|
||||
@@ -31,7 +31,7 @@ public void exit() {
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if(moveablePiece.equals(piece)){
|
||||
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
|
||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public void exit() {
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if(moveablePiece.equals(piece)){
|
||||
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
|
||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,11 +102,11 @@ public void received(DiceNowMessage msg){
|
||||
@Override
|
||||
public void received(PossiblePieceMessage msg){
|
||||
if (msg.getEnemyPossiblePieces().isEmpty()){
|
||||
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.setState(parent.getShield());
|
||||
} else {
|
||||
parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.setState(parent.getSwap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
||||
|
||||
public void selectPiece(Piece piece) {
|
||||
if (possiblePieces.contains(piece)) {
|
||||
logic.send(RequestPlayCardMessage.requestPlayShield(piece.getIdentifier()));
|
||||
logic.send(RequestPlayCardMessage.requestPlayShield(piece.getUuid()));
|
||||
} else {
|
||||
LOGGER.log(Level.DEBUG, "Invalid piece selected");
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public void selectPiece(Piece piece){
|
||||
selectedEnemyPiece = piece;
|
||||
}
|
||||
if (selectedOwnPiece != null && selectedEnemyPiece != null){
|
||||
logic.send(RequestPlayCardMessage.requestPlaySwap(selectedOwnPiece.getIdentifier(), selectedEnemyPiece.getIdentifier()));
|
||||
logic.send(RequestPlayCardMessage.requestPlaySwap(selectedOwnPiece.getUuid(), selectedEnemyPiece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,16 +134,6 @@ public int getNumberOfActivePlayers() {
|
||||
return activePlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return a piece based on the identifier.
|
||||
*
|
||||
* @return the piece specified by the identifier
|
||||
*/
|
||||
public Piece getPieceThroughIdentifier(String identifier){
|
||||
String[] parts = identifier.split("-");
|
||||
return board.getPlayerData().get(Color.valueOf(parts[0])).getPieces()[Integer.parseInt(parts[1])];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return a piece based on the UUID.
|
||||
*
|
||||
|
||||
@@ -9,7 +9,6 @@ public class Piece {
|
||||
private ShieldState shield;
|
||||
private PieceState state;
|
||||
private final Color color;
|
||||
private final int id;
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
|
||||
/**
|
||||
@@ -22,7 +21,6 @@ public Piece(Color color, PieceState state, int id) {
|
||||
this.color = color;
|
||||
this.state = state;
|
||||
shield = ShieldState.NONE;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,15 +86,6 @@ public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
*
|
||||
* @return the color of the piece
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return color.toString() + "-" + id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
*
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by a client to request a move for a piece.
|
||||
*/
|
||||
@@ -10,14 +12,14 @@ public class RequestMoveMessage extends ClientMessage {
|
||||
/**
|
||||
* The identifier for the piece.
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
private final UUID pieceIdentifier;
|
||||
|
||||
/**
|
||||
* Constructor for RequestMove
|
||||
*
|
||||
* @param pieceIdentifier the piece identifier
|
||||
*/
|
||||
public RequestMoveMessage(String pieceIdentifier) {
|
||||
public RequestMoveMessage(UUID pieceIdentifier) {
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
}
|
||||
|
||||
@@ -33,7 +35,7 @@ private RequestMoveMessage() {
|
||||
*
|
||||
* @return the piece identifier
|
||||
*/
|
||||
public String getPieceIdentifier() {
|
||||
public UUID getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.BonusCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by a client to request playing a bonus card.
|
||||
*/
|
||||
@@ -16,9 +18,9 @@ public class RequestPlayCardMessage extends ClientMessage {
|
||||
/**
|
||||
* The identifier of the piece.
|
||||
*/
|
||||
private final String ownPieceIdentifier;
|
||||
private final UUID ownPieceIdentifier;
|
||||
|
||||
private final String enemyPieceIdentifier;
|
||||
private final UUID enemyPieceIdentifier;
|
||||
|
||||
/**
|
||||
* Constructs a new RequestPlayCard instance.
|
||||
@@ -26,7 +28,7 @@ public class RequestPlayCardMessage extends ClientMessage {
|
||||
* @param card the bonus card to be played
|
||||
* @param ownPieceIdentifier the identifier of the piece
|
||||
*/
|
||||
public RequestPlayCardMessage(BonusCard card, String ownPieceIdentifier, String enemyPieceIdentifier) {
|
||||
public RequestPlayCardMessage(BonusCard card, UUID ownPieceIdentifier, UUID enemyPieceIdentifier) {
|
||||
this.ownPieceIdentifier = ownPieceIdentifier;
|
||||
this.card = card;
|
||||
this.enemyPieceIdentifier = enemyPieceIdentifier;
|
||||
@@ -48,11 +50,17 @@ private RequestPlayCardMessage() {
|
||||
* @param enemyPieceIdentifier the identifier of the enemy piece
|
||||
* @return a new RequestPlayCard instance
|
||||
*/
|
||||
public static RequestPlayCardMessage requestPlaySwap(String ownPieceIdentifier, String enemyPieceIdentifier){
|
||||
public static RequestPlayCardMessage requestPlaySwap(UUID ownPieceIdentifier, UUID enemyPieceIdentifier){
|
||||
return new RequestPlayCardMessage(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier);
|
||||
}
|
||||
|
||||
public static RequestPlayCardMessage requestPlayShield(String ownPieceIdentifier){
|
||||
/**
|
||||
* Creates a new RequestPlayCard instance for a shield bonus card.
|
||||
*
|
||||
* @param ownPieceIdentifier the identifier of the piece
|
||||
* @return a new RequestPlayCard instance
|
||||
*/
|
||||
public static RequestPlayCardMessage requestPlayShield(UUID ownPieceIdentifier){
|
||||
return new RequestPlayCardMessage(BonusCard.SHIELD, ownPieceIdentifier, null);
|
||||
}
|
||||
|
||||
@@ -70,7 +78,7 @@ public BonusCard getCard() {
|
||||
*
|
||||
* @return the piece identifier
|
||||
*/
|
||||
public String getOwnPieceIdentifier() {
|
||||
public UUID getOwnPieceIdentifier() {
|
||||
return ownPieceIdentifier;
|
||||
}
|
||||
|
||||
@@ -79,7 +87,7 @@ public String getOwnPieceIdentifier() {
|
||||
*
|
||||
* @return the enemy piece identifier
|
||||
*/
|
||||
public String getEnemyPieceIdentifier() {
|
||||
public UUID getEnemyPieceIdentifier() {
|
||||
return enemyPieceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by a client to indicate that a piece has been selected for a bonus cards.
|
||||
*/
|
||||
@@ -10,14 +12,14 @@ public class SelectedPiecesMessage extends ClientMessage {
|
||||
/**
|
||||
* The piece identifier.
|
||||
*/
|
||||
private String pieceIdentifier;
|
||||
private final UUID pieceIdentifier;
|
||||
|
||||
/**
|
||||
* Constructor for SelectedPieces
|
||||
*
|
||||
* @param pieceIdentifier the piece identifier
|
||||
*/
|
||||
public SelectedPiecesMessage(String pieceIdentifier) {
|
||||
public SelectedPiecesMessage(UUID pieceIdentifier) {
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
}
|
||||
|
||||
@@ -33,7 +35,7 @@ private SelectedPiecesMessage() {
|
||||
*
|
||||
* @return the piece identifier
|
||||
*/
|
||||
public String getPieceIdentifier() {
|
||||
public UUID getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -13,7 +14,7 @@ public class AnyPieceMessage extends ServerMessage {
|
||||
/**
|
||||
* The list of pieces
|
||||
*/
|
||||
private final ArrayList<String> piece;
|
||||
private final ArrayList<UUID> piece;
|
||||
|
||||
/**
|
||||
* Constructor for AnyPiece
|
||||
@@ -28,7 +29,7 @@ public AnyPieceMessage() {
|
||||
*
|
||||
* @param piece the piece to add
|
||||
*/
|
||||
public void addPiece(String piece) {
|
||||
public void addPiece(UUID piece) {
|
||||
this.piece.add(piece);
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ public void addPiece(String piece) {
|
||||
*
|
||||
* @return the list of pieces
|
||||
*/
|
||||
public List<String> getPiece() {
|
||||
public List<UUID> getPiece() {
|
||||
return piece;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package pp.mdga.message.server;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.Player;
|
||||
|
||||
/**
|
||||
* A message sent from the server to the client indicating that a player has joined the lobby.
|
||||
*/
|
||||
@Serializable
|
||||
public class LobbyPlayerJoinMessage extends ServerMessage {
|
||||
public class LobbyPlayerJoinedMessage extends ServerMessage {
|
||||
|
||||
/**
|
||||
* The name of the player joining the lobby.
|
||||
* The player joining the lobby.
|
||||
*/
|
||||
private final String name;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* The ID of the new Player
|
||||
@@ -21,29 +22,30 @@ public class LobbyPlayerJoinMessage extends ServerMessage {
|
||||
/**
|
||||
* Constructs a new LobbyPlayerJoin instance with the specified player name.
|
||||
*
|
||||
* @param name the name of the player joining the lobby
|
||||
* @param player the player joining the lobby
|
||||
* @param id the id of the player
|
||||
*/
|
||||
public LobbyPlayerJoinMessage(int id, String name) {
|
||||
public LobbyPlayerJoinedMessage(int id, Player player) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.player = player;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private LobbyPlayerJoinMessage() {
|
||||
name = null;
|
||||
private LobbyPlayerJoinedMessage() {
|
||||
player = null;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the player joining the lobby.
|
||||
* Returns the player joining the lobby.
|
||||
*
|
||||
* @return the name of the player joining the lobby
|
||||
* @return the player joining the lobby
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3,6 +3,8 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.BonusCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player to play a card.
|
||||
*/
|
||||
@@ -16,9 +18,9 @@ public class PlayCardMessage extends ServerMessage {
|
||||
/**
|
||||
* The identifier of the piece that should be moved.
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
private final UUID ownPieceID;
|
||||
|
||||
private final String pieceIdentifierEnemy;
|
||||
private final UUID enemyPieceID;
|
||||
|
||||
private final int diceModifier;
|
||||
|
||||
@@ -26,13 +28,15 @@ public class PlayCardMessage extends ServerMessage {
|
||||
* Constructs a new PlayCard message.
|
||||
*
|
||||
* @param card the card that should be played
|
||||
* @param pieceIdentifier the identifier of the piece that should be moved
|
||||
* @param ownPieceID the identifier of the piece that should be moved
|
||||
* @param enemyPieceID the identifier of the enemy piece that should be moved
|
||||
* @param diceModifier the new modifier of the dice
|
||||
*/
|
||||
public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy, int diceModifier) {
|
||||
public PlayCardMessage(BonusCard card, UUID ownPieceID, UUID enemyPieceID, int diceModifier) {
|
||||
super();
|
||||
this.card = card;
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
this.pieceIdentifierEnemy = pieceIdentifierEnemy;
|
||||
this.ownPieceID = ownPieceID;
|
||||
this.enemyPieceID = enemyPieceID;
|
||||
this.diceModifier = diceModifier;
|
||||
}
|
||||
|
||||
@@ -40,31 +44,31 @@ public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdent
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private PlayCardMessage() {
|
||||
this.pieceIdentifierEnemy = null;
|
||||
ownPieceID = null;
|
||||
card = null;
|
||||
pieceIdentifier = null;
|
||||
enemyPieceID = null;
|
||||
diceModifier = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param ownPieceID the identifier of the piece of the player that should be affected
|
||||
* @param enemyPieceID the identifier of the enemy piece that should be affected
|
||||
* @return a new PlayCard message
|
||||
*/
|
||||
public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifierEnemy) {
|
||||
return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy, 1);
|
||||
public static PlayCardMessage swap(UUID ownPieceID, UUID enemyPieceID) {
|
||||
return new PlayCardMessage(BonusCard.SWAP, ownPieceID, enemyPieceID, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ownPieceID the identifier of the piece of the player that should be affected
|
||||
* @return a new PlayCard message
|
||||
*/
|
||||
public static PlayCardMessage shield(String pieceIdentifier) {
|
||||
return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null, 1);
|
||||
public static PlayCardMessage shield(UUID ownPieceID) {
|
||||
return new PlayCardMessage(BonusCard.SHIELD, ownPieceID, null, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,8 +95,8 @@ public BonusCard getCard() {
|
||||
*
|
||||
* @return the identifier of the piece that should be moved
|
||||
*/
|
||||
public String getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
public UUID getPieceIdentifier() {
|
||||
return ownPieceID;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,8 +104,8 @@ public String getPieceIdentifier() {
|
||||
*
|
||||
* @return the identifier of the enemy piece that should be moved
|
||||
*/
|
||||
public String getPieceIdentifierEnemy() {
|
||||
return pieceIdentifierEnemy;
|
||||
public UUID getPieceIdentifierEnemy() {
|
||||
return enemyPieceID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player to give all possible pieces to choose from.
|
||||
@@ -13,12 +14,12 @@ public class PossiblePieceMessage extends ServerMessage {
|
||||
/**
|
||||
* The list of possible own pieces
|
||||
*/
|
||||
private final List<String> possibleOwnPieces;
|
||||
private final List<UUID> possibleOwnPieces;
|
||||
|
||||
/**
|
||||
* The list of possible enemy pieces
|
||||
*/
|
||||
private final List<String> possibleEnemyPieces;
|
||||
private final List<UUID> possibleEnemyPieces;
|
||||
|
||||
/**
|
||||
* Constructor for PossiblePiece
|
||||
@@ -36,7 +37,7 @@ public PossiblePieceMessage() {
|
||||
* @param possibleEnemyPieces the list of possible enemy pieces
|
||||
* @return the swapped possible pieces
|
||||
*/
|
||||
public static PossiblePieceMessage swapPossiblePieces(ArrayList<String> possibleOwnPieces, ArrayList<String> possibleEnemyPieces) {
|
||||
public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOwnPieces, ArrayList<UUID> possibleEnemyPieces) {
|
||||
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
|
||||
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
|
||||
possiblePieceMessage.possibleEnemyPieces.addAll(possibleEnemyPieces);
|
||||
@@ -49,7 +50,7 @@ public static PossiblePieceMessage swapPossiblePieces(ArrayList<String> possible
|
||||
* @param possibleOwnPieces the list of possible own pieces
|
||||
* @return the possible pieces for the shield
|
||||
*/
|
||||
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<String> possibleOwnPieces){
|
||||
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces){
|
||||
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
|
||||
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
|
||||
return possiblePieceMessage;
|
||||
@@ -60,7 +61,7 @@ public static PossiblePieceMessage shieldPossiblePieces(ArrayList<String> possib
|
||||
*
|
||||
* @param piece the piece to add
|
||||
*/
|
||||
public void addOwnPossiblePiece(String piece) {
|
||||
public void addOwnPossiblePiece(UUID piece) {
|
||||
this.possibleOwnPieces.add(piece);
|
||||
}
|
||||
|
||||
@@ -69,21 +70,21 @@ public void addOwnPossiblePiece(String piece) {
|
||||
*
|
||||
* @param piece the piece to add
|
||||
*/
|
||||
public void addEnemyPossiblePiece(String piece) {
|
||||
public void addEnemyPossiblePiece(UUID piece) {
|
||||
this.possibleEnemyPieces.add(piece);
|
||||
}
|
||||
|
||||
/** Getter for the list of possible pieces
|
||||
* @return the list of possible pieces
|
||||
*/
|
||||
public List<String> getOwnPossiblePieces() {
|
||||
public List<UUID> getOwnPossiblePieces() {
|
||||
return possibleOwnPieces;
|
||||
}
|
||||
|
||||
/** Getter for the list of possible enemy pieces
|
||||
* @return the list of possible enemy pieces
|
||||
*/
|
||||
public List<String> getEnemyPossiblePieces() {
|
||||
public List<UUID> getEnemyPossiblePieces() {
|
||||
return possibleEnemyPieces;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Serializable
|
||||
public class SelectPieceMessage extends ServerMessage{
|
||||
|
||||
private final List<String> pieces;
|
||||
private final List<UUID> pieces;
|
||||
private final List<Boolean> isHomeMove;
|
||||
private final List<Integer> targetIndex;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class SelectPieceMessage extends ServerMessage{
|
||||
* @param isHomeMove the List of booleans of isHomeMove of the pieces
|
||||
* @param targetIndex the List of indexes of target nodes of the pieces
|
||||
*/
|
||||
public SelectPieceMessage(List<String> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex){
|
||||
public SelectPieceMessage(List<UUID> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex){
|
||||
this.pieces = pieces;
|
||||
this.isHomeMove = isHomeMove;
|
||||
this.targetIndex = targetIndex;
|
||||
@@ -38,7 +39,7 @@ public SelectPieceMessage(){
|
||||
*
|
||||
* @return the pieces
|
||||
*/
|
||||
public List<String> getPieces(){
|
||||
public List<UUID> getPieces(){
|
||||
return pieces;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public interface ServerInterpreter {
|
||||
*
|
||||
* @param msg the LobbyPlayerJoin message received
|
||||
*/
|
||||
void received(LobbyPlayerJoinMessage msg);
|
||||
void received(LobbyPlayerJoinedMessage msg);
|
||||
|
||||
/**
|
||||
* Handles a LobbyPlayerLeave message received from the server.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player that he has to move a start piece.
|
||||
*/
|
||||
@@ -10,7 +12,7 @@ public class StartPieceMessage extends ServerMessage {
|
||||
/**
|
||||
* The identifier for the piece.
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
private final UUID pieceIdentifier;
|
||||
|
||||
/**
|
||||
* The target index of the move;
|
||||
@@ -23,7 +25,7 @@ public class StartPieceMessage extends ServerMessage {
|
||||
* @param pieceIdentifier the identifier for the piece
|
||||
* @param targetIndex the index of the targetNode
|
||||
*/
|
||||
public StartPieceMessage(String pieceIdentifier, int targetIndex) {
|
||||
public StartPieceMessage(UUID pieceIdentifier, int targetIndex) {
|
||||
super();
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
this.targetIndex = targetIndex;
|
||||
@@ -34,7 +36,7 @@ public StartPieceMessage(String pieceIdentifier, int targetIndex) {
|
||||
*/
|
||||
private StartPieceMessage() {
|
||||
super();
|
||||
this.pieceIdentifier = "";
|
||||
this.pieceIdentifier = null;
|
||||
this.targetIndex = 0;
|
||||
}
|
||||
|
||||
@@ -43,7 +45,7 @@ private StartPieceMessage() {
|
||||
*
|
||||
* @return the piece identifier
|
||||
*/
|
||||
public String getPieceIdentifier() {
|
||||
public UUID getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user