merge development into test #26
@@ -91,7 +91,7 @@ private void initializeSerializables() {
|
|||||||
Serializer.registerClass(DeselectTSKMessage.class);
|
Serializer.registerClass(DeselectTSKMessage.class);
|
||||||
Serializer.registerClass(ForceContinueGameMessage.class);
|
Serializer.registerClass(ForceContinueGameMessage.class);
|
||||||
Serializer.registerClass(StartGameMessage.class);
|
Serializer.registerClass(StartGameMessage.class);
|
||||||
Serializer.registerClass(JoinServerMessage.class);
|
Serializer.registerClass(JoinedLobbyMessage.class);
|
||||||
Serializer.registerClass(LeaveGameMessage.class);
|
Serializer.registerClass(LeaveGameMessage.class);
|
||||||
Serializer.registerClass(LobbyNotReadyMessage.class);
|
Serializer.registerClass(LobbyNotReadyMessage.class);
|
||||||
Serializer.registerClass(LobbyReadyMessage.class);
|
Serializer.registerClass(LobbyReadyMessage.class);
|
||||||
@@ -139,7 +139,7 @@ private void registerListeners() {
|
|||||||
myServer.addMessageListener(this, DeselectTSKMessage.class);
|
myServer.addMessageListener(this, DeselectTSKMessage.class);
|
||||||
myServer.addMessageListener(this, ForceContinueGameMessage.class);
|
myServer.addMessageListener(this, ForceContinueGameMessage.class);
|
||||||
myServer.addMessageListener(this, StartGameMessage.class);
|
myServer.addMessageListener(this, StartGameMessage.class);
|
||||||
myServer.addMessageListener(this, JoinServerMessage.class);
|
myServer.addMessageListener(this, JoinedLobbyMessage.class);
|
||||||
myServer.addMessageListener(this, LeaveGameMessage.class);
|
myServer.addMessageListener(this, LeaveGameMessage.class);
|
||||||
myServer.addMessageListener(this, LobbyNotReadyMessage.class);
|
myServer.addMessageListener(this, LobbyNotReadyMessage.class);
|
||||||
myServer.addMessageListener(this, LobbyReadyMessage.class);
|
myServer.addMessageListener(this, LobbyReadyMessage.class);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public LobbyState(ClientState parent, ClientGameLogic logic) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
logic.send(new JoinedLobbyMessage(parent.getOwnPlayerName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
|
import pp.mdga.game.PieceState;
|
||||||
import pp.mdga.game.ShieldState;
|
import pp.mdga.game.ShieldState;
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
import pp.mdga.message.server.PlayCardMessage;
|
||||||
import pp.mdga.notification.ShieldActiveNotification;
|
import pp.mdga.notification.ShieldActiveNotification;
|
||||||
@@ -45,5 +46,6 @@ protected void throwPiece(Piece piece){
|
|||||||
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
||||||
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
||||||
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
||||||
|
piece.setState(PieceState.WAITING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,7 @@
|
|||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.GameState;
|
import pp.mdga.client.GameState;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.*;
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.game.Player;
|
|
||||||
import pp.mdga.game.ShieldState;
|
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.notification.*;
|
import pp.mdga.notification.*;
|
||||||
|
|
||||||
@@ -74,6 +71,13 @@ public void received(MoveMessage msg){
|
|||||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
||||||
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
||||||
|
for(int i = msg.getTargetIndex() + 1; i < 4; i++){
|
||||||
|
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
|
||||||
|
pieceToMove.setState(PieceState.HOME);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pieceToMove.setState(PieceState.HOMEFINISHED);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
||||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
|
import pp.mdga.game.PieceState;
|
||||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||||
import pp.mdga.message.server.MoveMessage;
|
import pp.mdga.message.server.MoveMessage;
|
||||||
|
|
||||||
@@ -35,6 +36,8 @@ public void selectPiece(Piece piece){
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg){
|
public void received(MoveMessage msg){
|
||||||
|
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||||
|
pieceToMove.setState(PieceState.ACTIVE);
|
||||||
parent.getParent().setState(parent.getParent().getMovePiece());
|
parent.getParent().setState(parent.getParent().getMovePiece());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public interface ClientInterpreter {
|
|||||||
* @param msg the JoinServer message to be processed
|
* @param msg the JoinServer message to be processed
|
||||||
* @param from the connection ID from which the message was received
|
* @param from the connection ID from which the message was received
|
||||||
*/
|
*/
|
||||||
void received(JoinServerMessage msg, int from);
|
void received(JoinedLobbyMessage msg, int from);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a received LeaveGame message.
|
* Processes a received LeaveGame message.
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
* A message sent by a client when joining the server.
|
* A message sent by a client when joining the server.
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class JoinServerMessage extends ClientMessage {
|
public class JoinedLobbyMessage extends ClientMessage {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new JoinServer instance.
|
* Constructs a new JoinServer instance.
|
||||||
*/
|
*/
|
||||||
public JoinServerMessage(String name) {
|
public JoinedLobbyMessage(String name) {
|
||||||
super();
|
super();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
@@ -21,11 +21,20 @@ public JoinServerMessage(String name) {
|
|||||||
/**
|
/**
|
||||||
* Constructs a new JoinServer instance.
|
* Constructs a new JoinServer instance.
|
||||||
*/
|
*/
|
||||||
public JoinServerMessage() {
|
public JoinedLobbyMessage() {
|
||||||
super();
|
super();
|
||||||
name = null;
|
name = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the player that is joining the server.
|
||||||
|
*
|
||||||
|
* @return the name of the player that is joining the server
|
||||||
|
*/
|
||||||
|
public String getName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of this message.
|
* Returns a string representation of this message.
|
||||||
*
|
*
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A message sent by the server to the client to move a piece on the board.
|
* A message sent by the server to the client to move a piece on the board.
|
||||||
*/
|
*/
|
||||||
@@ -10,7 +12,7 @@ public class MoveMessage extends ServerMessage {
|
|||||||
/**
|
/**
|
||||||
* The identifier of the piece that should be moved.
|
* The identifier of the piece that should be moved.
|
||||||
*/
|
*/
|
||||||
private final String pieceIdentifier;
|
private final UUID pieceUUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index of the target node;
|
* The index of the target node;
|
||||||
@@ -27,9 +29,9 @@ public class MoveMessage extends ServerMessage {
|
|||||||
*
|
*
|
||||||
* @param identifier the identifier of the piece that should be moved
|
* @param identifier the identifier of the piece that should be moved
|
||||||
*/
|
*/
|
||||||
public MoveMessage(String identifier, boolean isHomeMove, int targetIndex) {
|
public MoveMessage(UUID identifier, boolean isHomeMove, int targetIndex) {
|
||||||
super();
|
super();
|
||||||
this.pieceIdentifier = identifier;
|
this.pieceUUID = identifier;
|
||||||
this.isHomeMove = isHomeMove;
|
this.isHomeMove = isHomeMove;
|
||||||
this.targetIndex = targetIndex;
|
this.targetIndex = targetIndex;
|
||||||
}
|
}
|
||||||
@@ -38,7 +40,7 @@ public MoveMessage(String identifier, boolean isHomeMove, int targetIndex) {
|
|||||||
* Default constructor for serialization purposes.
|
* Default constructor for serialization purposes.
|
||||||
*/
|
*/
|
||||||
private MoveMessage() {
|
private MoveMessage() {
|
||||||
pieceIdentifier = null;
|
pieceUUID = null;
|
||||||
targetIndex = 0;
|
targetIndex = 0;
|
||||||
isHomeMove = false;
|
isHomeMove = false;
|
||||||
}
|
}
|
||||||
@@ -48,8 +50,8 @@ private MoveMessage() {
|
|||||||
*
|
*
|
||||||
* @return the identifier of the piece that should be moved
|
* @return the identifier of the piece that should be moved
|
||||||
*/
|
*/
|
||||||
public String getIdentifier() {
|
public UUID getIdentifier() {
|
||||||
return pieceIdentifier;
|
return pieceUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public void received(StartGameMessage msg, int from) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(JoinServerMessage msg, int from) {
|
public void received(JoinedLobbyMessage msg, int from) {
|
||||||
this.currentState.received(msg, from);
|
this.currentState.received(msg, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public void received(StartGameMessage msg, int from) {}
|
|||||||
* @param msg as the message which was sent by the player as a JoinServer object.
|
* @param msg as the message which was sent by the player as a JoinServer object.
|
||||||
* @param from as the client id of the player as an Integer.
|
* @param from as the client id of the player as an Integer.
|
||||||
*/
|
*/
|
||||||
public void received(JoinServerMessage msg, int from) {}
|
public void received(JoinedLobbyMessage msg, int from) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be called whenever the server received an LeaveGame message.
|
* This method will be called whenever the server received an LeaveGame message.
|
||||||
|
|||||||
Reference in New Issue
Block a user