modified messages to work with piece uuid instead of an identifier.
This commit is contained in:
		@@ -3,9 +3,7 @@
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.GameState;
 | 
			
		||||
import pp.mdga.message.server.CeremonyMessage;
 | 
			
		||||
import pp.mdga.message.server.DiceNowMessage;
 | 
			
		||||
import pp.mdga.message.server.EndOfTurnMessage;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
 | 
			
		||||
public class WaitingState extends GameStates {
 | 
			
		||||
 | 
			
		||||
@@ -37,7 +35,22 @@ public void received(DiceNowMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(EndOfTurnMessage msg){
 | 
			
		||||
        parent.setState(parent.getWaiting());
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
        parent.setState(parent.getAnimation());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayCardMessage msg){
 | 
			
		||||
        parent.setState(parent.getAnimation());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ActivePlayerMessage msg){
 | 
			
		||||
        parent.setState(parent.getAnimation());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg){
 | 
			
		||||
        parent.setState(parent.getAnimation());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@
 | 
			
		||||
 */
 | 
			
		||||
public class Board {
 | 
			
		||||
    private Map<Color, PlayerData> playerData;
 | 
			
		||||
    private Node[] infield;
 | 
			
		||||
    private final Node[] infield;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor is used to create a new board
 | 
			
		||||
 
 | 
			
		||||
@@ -12,14 +12,26 @@ public class MoveMessage extends ServerMessage {
 | 
			
		||||
     */
 | 
			
		||||
    private final String pieceIdentifier;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The index of the target node;
 | 
			
		||||
     */
 | 
			
		||||
    private final int targetIndex;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * True if the pieces move into the home.
 | 
			
		||||
     */
 | 
			
		||||
    private final boolean isHomeMove;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new MoveMessage instance.
 | 
			
		||||
     *
 | 
			
		||||
     * @param identifier the identifier of the piece that should be moved
 | 
			
		||||
     */
 | 
			
		||||
    public MoveMessage(String identifier) {
 | 
			
		||||
    public MoveMessage(String identifier, boolean isHomeMove, int targetIndex) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.pieceIdentifier = identifier;
 | 
			
		||||
        this.isHomeMove = isHomeMove;
 | 
			
		||||
        this.targetIndex = targetIndex;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -27,6 +39,8 @@ public MoveMessage(String identifier) {
 | 
			
		||||
     */
 | 
			
		||||
    private MoveMessage() {
 | 
			
		||||
        pieceIdentifier = null;
 | 
			
		||||
        targetIndex = 0;
 | 
			
		||||
        isHomeMove = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -38,6 +52,24 @@ public String getIdentifier() {
 | 
			
		||||
        return pieceIdentifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the index of the target Node.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the target index
 | 
			
		||||
     */
 | 
			
		||||
    public int getTargetIndex(){
 | 
			
		||||
        return targetIndex;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns a boolean based on if it is a home move or not.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the boolean isHomeMove.
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isHomeMove(){
 | 
			
		||||
        return isHomeMove;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Accepts a visitor to process this message.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -8,14 +8,20 @@
 | 
			
		||||
public class SelectPieceMessage extends ServerMessage{
 | 
			
		||||
 | 
			
		||||
    private final List<String> pieces;
 | 
			
		||||
    private final List<Boolean> isHomeMove;
 | 
			
		||||
    private final List<Integer> targetIndex;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new SelectPiece instance.
 | 
			
		||||
     *
 | 
			
		||||
     * @param pieces the pieces to be selected
 | 
			
		||||
     * @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){
 | 
			
		||||
    public SelectPieceMessage(List<String> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex){
 | 
			
		||||
        this.pieces = pieces;
 | 
			
		||||
        this.isHomeMove = isHomeMove;
 | 
			
		||||
        this.targetIndex = targetIndex;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -23,6 +29,8 @@ public SelectPieceMessage(List<String> pieces){
 | 
			
		||||
     */
 | 
			
		||||
    public SelectPieceMessage(){
 | 
			
		||||
        pieces = null;
 | 
			
		||||
        isHomeMove = null;
 | 
			
		||||
        targetIndex = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -12,14 +12,21 @@ public class StartPieceMessage extends ServerMessage {
 | 
			
		||||
     */
 | 
			
		||||
    private final String pieceIdentifier;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The target index of the move;
 | 
			
		||||
     */
 | 
			
		||||
    private final int targetIndex;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new StartPiece instance with the specified piece identifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @param pieceIdentifier the identifier for the piece
 | 
			
		||||
     * @param targetIndex the index of the targetNode
 | 
			
		||||
     */
 | 
			
		||||
    public StartPieceMessage(String pieceIdentifier) {
 | 
			
		||||
    public StartPieceMessage(String pieceIdentifier, int targetIndex) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.pieceIdentifier = pieceIdentifier;
 | 
			
		||||
        this.targetIndex = targetIndex;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -28,6 +35,7 @@ public StartPieceMessage(String pieceIdentifier) {
 | 
			
		||||
    private StartPieceMessage() {
 | 
			
		||||
        super();
 | 
			
		||||
        this.pieceIdentifier = "";
 | 
			
		||||
        this.targetIndex = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -39,6 +47,15 @@ public String getPieceIdentifier() {
 | 
			
		||||
        return pieceIdentifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the index of the target node
 | 
			
		||||
     *
 | 
			
		||||
     * @return the index of the target node as int.
 | 
			
		||||
     */
 | 
			
		||||
    public int getTargetIndex(){
 | 
			
		||||
        return targetIndex;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Accepts a visitor to process this message.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user