Files
Gruppe-01-fin/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java
Fleischer Hanno 806f0d7d9d 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.
2024-11-23 12:26:20 +01:00

97 lines
2.1 KiB
Java

package pp.mdga.game;
/**
* This class will be used to hold all Piece relevant data.
*/
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
*
* @param color the color of the piece
* @param state the state of the piece
*/
public Piece(Color color, PieceState state, int id) {
this.color = color;
this.state = state;
shield = ShieldState.NONE;
this.id = id;
}
/**
* This method is used to get the color of the piece
*
* @return the color of the piece
*/
public void setShield(ShieldState shield) {
this.shield = shield;
}
/**
* This method is used to get the color of the piece
*
* @return the color of the piece
*/
public ShieldState getShield() {
return shield;
}
/**
* This method is used to get the color of the piece
*
* @param state the state of the piece
*/
public void setState(PieceState state) {
this.state = state;
}
/**
* This method is used to get the color of the piece
*
* @return the color of the piece
*/
public PieceState getState() {
return state;
}
/**
* This method is used to get the color of the piece
*
* @return the color of the piece
*/
public boolean isShielded() {
return shield == ShieldState.ACTIVE;
}
/**
* This method is used to get the color of the piece
*
* @return the color of the piece
*/
public boolean isSuppressed() {
return shield == ShieldState.SUPPRESSED;
}
/**
* This method is used to get the color of the piece
*
* @return the color of the piece
*/
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;
}
}