added message contents to the messages

addedn the conentents for all messages regarding the BPMN diagramm and own interpretation.
also created an identifier for pieces to be used for network communication between server and client so that they talk about the same piece.
This commit is contained in:
Fleischer Hanno
2024-11-23 12:26:20 +01:00
parent 89232901a7
commit 806f0d7d9d
21 changed files with 398 additions and 4 deletions

View File

@@ -405,4 +405,17 @@ public void notifyObservers() {
observer.update();
}
}
/**
* This method returns the piece through its identifier.
*
* @param identifier the identifier of the piece
* @return the piece
*/
public Piece getPieceThroughIdentifier(String identifier) {
String[] parts = identifier.split("-");
Color color = Color.valueOf(parts[0]);
int index = Integer.parseInt(parts[1]);
return board.getPlayerData().get(color).getPieces()[index];
}
}

View File

@@ -7,6 +7,7 @@ public class Piece {
private ShieldState shield;
private PieceState state;
private final Color color;
private final int id;
/**
* This constructor is used to create a new Piece
@@ -14,10 +15,11 @@ public class Piece {
* @param color the color of the piece
* @param state the state of the piece
*/
public Piece(Color color, PieceState state) {
public Piece(Color color, PieceState state, int id) {
this.color = color;
this.state = state;
shield = ShieldState.NONE;
this.id = id;
}
/**
@@ -82,4 +84,13 @@ public boolean isSuppressed() {
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;
}
}

View File

@@ -19,7 +19,7 @@ public PlayerData(Color color) {
waitingArea = new Piece[4];
for (int i = 0; i < 4; i++) {
homeNodes[i] = new HomeNode();
pieces[i] = new Piece(color, PieceState.WAITING);
pieces[i] = new Piece(color, PieceState.WAITING, i);
waitingArea[i] = pieces[i];
}
}