added dice, started adding notification implementation, added hover, highlight and select functionality for pieces
This commit is contained in:
@@ -2,37 +2,76 @@
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification that a piece has been moved.
|
||||
*/
|
||||
public class MovePieceNotification extends Notification {
|
||||
|
||||
private Color color;
|
||||
private int nodeIndex;
|
||||
/**
|
||||
* The unique identifier of the piece being moved.
|
||||
*/
|
||||
private final UUID piece;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param color the color of the piece that has been moved.
|
||||
* @param nodeIndex the index of the node the piece has been moved to.
|
||||
* The index of the node from which the piece started moving.
|
||||
* Ignored if {@code moveStart} is {@code true}.
|
||||
*/
|
||||
MovePieceNotification(Color color, int nodeIndex) {
|
||||
this.color = color;
|
||||
this.nodeIndex = nodeIndex;
|
||||
private final int startIndex;
|
||||
|
||||
/**
|
||||
* The index of the node to which the piece is moving.
|
||||
* If {@code moveStart} is {@code true}, this index represents the start node.
|
||||
*/
|
||||
private final int moveIndex;
|
||||
|
||||
/**
|
||||
* Flag indicating that the piece ({@code uuid}) is moving from waiting area to the startNode.
|
||||
*/
|
||||
private final boolean moveStart;
|
||||
|
||||
/**
|
||||
* Constructs a notification for a piece start movement.
|
||||
*
|
||||
* @param piece the unique identifier of the piece
|
||||
* @param moveIndex the destination node index
|
||||
* @param moveStart whether to ignore {@code startIndex} and use {@code moveIndex} as the start node
|
||||
*/
|
||||
public MovePieceNotification(UUID piece, int moveIndex, boolean moveStart) {
|
||||
this.piece = piece;
|
||||
this.startIndex = 0;
|
||||
this.moveIndex = moveIndex;
|
||||
this.moveStart = moveStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color of the piece that has been moved.
|
||||
* @return the color of the piece that has been moved.
|
||||
* Constructs a notification for a piece infield move with {@code moveStart} set to {@code false}.
|
||||
*
|
||||
* @param piece the unique identifier of the piece
|
||||
* @param startIndex the starting node index
|
||||
* @param moveIndex the destination node index
|
||||
*/
|
||||
public Color getColor() {
|
||||
return color;
|
||||
public MovePieceNotification(UUID piece, int startIndex, int moveIndex) {
|
||||
this.piece = piece;
|
||||
this.startIndex = startIndex;
|
||||
this.moveIndex = moveIndex;
|
||||
this.moveStart = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of the node the piece has been moved to.
|
||||
* @return the index of the node the piece has been moved to.
|
||||
*/
|
||||
public int getNodeIndex() {
|
||||
return nodeIndex;
|
||||
public int getMoveIndex() {
|
||||
return moveIndex;
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public UUID getPiece() {
|
||||
return piece;
|
||||
}
|
||||
|
||||
public boolean isMoveStart() {
|
||||
return moveStart;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification for selecting pieces and their possible moves.
|
||||
*/
|
||||
public class SelectableMoveNotification extends Notification{
|
||||
|
||||
/**
|
||||
* List of UUIDs representing the pieces that can be moved based on the dice roll.
|
||||
*/
|
||||
private final List<UUID> pieces;
|
||||
|
||||
/**
|
||||
* List of integers representing the target nodes the pieces can move to.
|
||||
*/
|
||||
private final List<Integer> moveIndexe;
|
||||
|
||||
/**
|
||||
* List of booleans indicating whether the corresponding target nodes are in the home area.
|
||||
* {@code true} if the target node is in the home area, {@code false} if in the infield.
|
||||
*/
|
||||
private final List<Boolean> homeMoves;
|
||||
|
||||
/**
|
||||
* Constructs a notification for selectable piece moves.
|
||||
*
|
||||
* @param pieces the list of pieces that can be moved
|
||||
* @param moveIndexe the list of target nodes for the moves
|
||||
* @param homeMoves the list indicating if the target nodes are in the home area
|
||||
*/
|
||||
public SelectableMoveNotification(List<UUID> pieces, List<Integer> moveIndexe, List<Boolean> homeMoves) {
|
||||
this.pieces = pieces;
|
||||
this.moveIndexe = moveIndexe;
|
||||
this.homeMoves = homeMoves;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of pieces that can be moved.
|
||||
*
|
||||
* @return a list of UUIDs representing the movable pieces
|
||||
*/
|
||||
public List<UUID> getPieces() {
|
||||
return pieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of target nodes for the moves.
|
||||
*
|
||||
* @return a list of integers representing the target nodes
|
||||
*/
|
||||
public List<Integer> getMoveIndexe() {
|
||||
return moveIndexe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list indicating whether the target nodes are in the home area.
|
||||
*
|
||||
* @return a list of booleans, {@code true} if the target node is in the home area, {@code false} otherwise
|
||||
*/
|
||||
public List<Boolean> getHomeMoves() {
|
||||
return homeMoves;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification to inform the client about the selectable pieces.
|
||||
*/
|
||||
public class SelectablePiecesNotification extends Notification{
|
||||
|
||||
private List<UUID> selectablePieces;
|
||||
|
||||
/**
|
||||
* @param selectablePieces
|
||||
*/
|
||||
SelectablePiecesNotification(List<UUID> selectablePieces){
|
||||
this.selectablePieces = selectablePieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List<UUID>
|
||||
*/
|
||||
public List<UUID> getSelectablePieces(){
|
||||
return selectablePieces;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification for selecting pieces for swapcard.
|
||||
*/
|
||||
public class SelectableSwapNotification extends Notification{
|
||||
|
||||
/**
|
||||
* List of UUIDs representing the player's own pieces available for selection.
|
||||
*/
|
||||
private final List<UUID> ownPieces;
|
||||
|
||||
/**
|
||||
* List of UUIDs representing the opponent's pieces available for selection.
|
||||
*/
|
||||
private final List<UUID> enemyPieces;
|
||||
|
||||
/**
|
||||
* Constructs a notification for selecting pieces for swapcard.
|
||||
*
|
||||
* @param ownPieces the list of the player's own pieces
|
||||
* @param enemyPieces the list of the opponent's pieces
|
||||
*/
|
||||
public SelectableSwapNotification(List<UUID> ownPieces, List<UUID> enemyPieces) {
|
||||
this.ownPieces = ownPieces;
|
||||
this.enemyPieces = enemyPieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of the player's own pieces available for selection.
|
||||
*
|
||||
* @return a list of UUIDs representing the player's own pieces
|
||||
*/
|
||||
public List<UUID> getOwnPieces() {
|
||||
return ownPieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of the opponent's pieces available for selection.
|
||||
*
|
||||
* @return a list of UUIDs representing the opponent's pieces
|
||||
*/
|
||||
public List<UUID> getEnemyPieces() {
|
||||
return enemyPieces;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class SwapPieceNotification extends Notification {
|
||||
* @param firstPiece the UUID of the first piece that has been swapped.
|
||||
* @param secondPiece the UUID of the second piece that has been swapped.
|
||||
*/
|
||||
SwapPieceNotification(UUID firstPiece, UUID secondPiece) {
|
||||
public SwapPieceNotification(UUID firstPiece, UUID secondPiece) {
|
||||
assert(!firstPiece.equals(secondPiece));
|
||||
this.firstPiece = firstPiece;
|
||||
this.secondPiece = secondPiece;
|
||||
|
||||
Reference in New Issue
Block a user