added all Notifications for the model view communication

added all required notifications with their content and getter methods.
This commit is contained in:
Hanno Fleischer
2024-11-16 18:58:33 +01:00
parent 6b2d775534
commit 44b623f9fd
23 changed files with 556 additions and 13 deletions

View File

@@ -0,0 +1,27 @@
package pp.mdga.notification;
import java.util.UUID;
/**
* Notification that is sent when a card is acquired.
*/
public class AcquireCardNotification extends Notification{
private UUID cardId;
/**
* Constructor.
* @param cardId The id of the card that was acquired.
*/
public AcquireCardNotification(UUID cardId) {
this.cardId = cardId;
}
/**
* Get the id of the card that was acquired.
* @return The id of the card that was acquired.
*/
public UUID getCardId() {
return cardId;
}
}

View File

@@ -2,8 +2,23 @@
import pp.mdga.game.Color;
/**
* Notification that the active player has changed
*/
public class ActivePlayerNotification extends Notification {
ActivePlayerNotification(Color color) {
/**
* The color of the active player
*/
private Color color;
ActivePlayerNotification(Color color) {
this.color = color;
}
/**
* @return the color of the active player
*/
public Color getColor() {
return color;
}
}

View File

@@ -0,0 +1,12 @@
package pp.mdga.notification;
/**
* Class CeremonyNotification
*/
public class CeremonyNotification extends Notification{
/**
* Constructor
*/
CeremonyNotification() {
}
}

View File

@@ -0,0 +1,13 @@
package pp.mdga.notification;
/**
* Notification that the dice is now.
*/
public class DiceNowNotification extends Notification {
/**
* Constructor.
*/
DiceNowNotification() {
}
}

View File

@@ -0,0 +1,27 @@
package pp.mdga.notification;
import pp.mdga.game.Color;
/**
* Notification that is sent when a player has diced.
*/
public class DicingNotification extends Notification{
private Color color;
/**
* Constructor.
* @param color The color of the player that diced.
*/
DicingNotification(Color color) {
this.color = color;
}
/**
* Get the color of the player that diced.
* @return The color of the player that diced.
*/
public Color getColor() {
return color;
}
}

View File

@@ -2,9 +2,34 @@
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
/**
* Notification that a card has been drawn
*/
public class DrawCardNotification extends Notification {
DrawCardNotification(Color color, BonusCard card) {
private Color color;
private BonusCard card;
/**
* @param color the color of the player who drew the card
* @param card the card that was drawn
*/
DrawCardNotification(Color color, BonusCard card) {
this.color = color;
this.card = card;
}
/**
* @return the color of the player who drew the card
*/
public Color getColor() {
return color;
}
/**
* @return the card that was drawn
*/
public BonusCard getCard() {
return card;
}
}

View File

@@ -0,0 +1,12 @@
package pp.mdga.notification;
/**
* GameNotification class
*/
public class GameNotification extends Notification{
/**
* Constructor
*/
GameNotification() {
}
}

View File

@@ -0,0 +1,41 @@
package pp.mdga.notification;
import java.util.UUID;
/**
* Notification that a piece has moved to a home.
*/
public class HomeMoveNotification extends Notification {
private UUID pieceId;
private int homeIndex;
/**
* Constructor.
*
* @param pieceId the piece id
* @param homeIndex the home index
*/
HomeMoveNotification(UUID pieceId, int homeIndex) {
this.pieceId = pieceId;
this.homeIndex = homeIndex;
}
/**
* Get the piece id.
*
* @return the piece id
*/
public UUID getPieceId() {
return pieceId;
}
/**
* Get the home index.
*
* @return the home index
*/
public int getHomeIndex() {
return homeIndex;
}
}

View File

@@ -1,9 +1,23 @@
package pp.mdga.notification;
import pp.mdga.game.Color;
/**
* Notification that a card has been drawn
*/
public class InterruptNotification extends Notification {
InterruptNotification(Color color) {
private Color color;
/**
* @param color the color of the player who drew the card
*/
InterruptNotification(Color color) {
this.color = color;
}
/**
* @return the color of the player who drew the card
*/
public Color getColor() {
return color;
}
}

View File

@@ -0,0 +1,12 @@
package pp.mdga.notification;
/**
* Notification that a dialog has been started
*/
public class LobbyDialogNotification extends Notification{
/**
* Constructor
*/
LobbyDialogNotification() {
}
}

View File

@@ -2,8 +2,37 @@
import pp.mdga.game.Color;
/**
* Notification that a piece has been moved.
*/
public class MovePieceNotification extends Notification {
MovePieceNotification(Color color, int nodeIndex) {
private Color color;
private int nodeIndex;
/**
* 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.
*/
MovePieceNotification(Color color, int nodeIndex) {
this.color = color;
this.nodeIndex = nodeIndex;
}
/**
* Get the color of the piece that has been moved.
* @return the color of the piece that has been moved.
*/
public Color getColor() {
return color;
}
/**
* 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;
}
}

View File

@@ -4,8 +4,34 @@
import java.util.UUID;
/**
* Notification that a piece is in the game
*/
public class PieceInGameNotification extends Notification{
PieceInGameNotification(Color color, UUID id) {
private Color color;
private UUID id;
/**
* Constructor
* @param color the color of the piece
* @param id the id of the piece
*/
PieceInGameNotification(Color color, UUID id) {
this.color = color;
this.id = id;
}
/**
* @return the color of the piece
*/
public Color getColor() {
return null;
}
/**
* @return the id of the piece
*/
public UUID getId() {
return null;
}
}

View File

@@ -3,8 +3,37 @@
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
/**
* Notification that a card has been played.
*/
public class PlayCardNotification extends Notification {
PlayCardNotification(Color color, BonusCard card) {
private Color color;
private BonusCard card;
/**
* Constructor.
* @param color the color of the player that played the card.
* @param card the card that was played.
*/
PlayCardNotification(Color color, BonusCard card) {
this.color = color;
this.card = card;
}
/**
* Get the color of the player that played the card.
* @return the color of the player that played the card.
*/
public Color getColor() {
return color;
}
/**
* Get the card that was played.
* @return the card that was played.
*/
public BonusCard getCard() {
return card;
}
}

View File

@@ -2,8 +2,37 @@
import pp.mdga.game.Color;
/**
* Notification that a player is in the game.
*/
public class PlayerInGameNotification extends Notification {
PlayerInGameNotification(Color color, String name) {
private Color color;
private String name;
/**
* Constructor.
* @param color the color of the player that is in the game.
* @param name the name of the player that is in the game.
*/
PlayerInGameNotification(Color color, String name) {
this.color = color;
this.name = name;
}
/**
* Get the color of the player that is in the game.
* @return the color of the player that is in the game.
*/
public Color getColor() {
return color;
}
/**
* Get the name of the player that is in the game.
* @return the name of the player that is in the game.
*/
public String getName() {
return name;
}
}

View File

@@ -2,8 +2,26 @@
import pp.mdga.game.Color;
/**
* Notification that a player is in the game.
*/
public class ResumeNotification extends Notification {
ResumeNotification(Color color) {
private Color color;
/**
* Constructor.
* @param color the color of the player that is in the game.
*/
ResumeNotification(Color color) {
this.color = color;
}
/**
* Get the color of the player that is in the game.
* @return the color of the player that is in the game.
*/
public Color getColor() {
return color;
}
}

View File

@@ -2,8 +2,48 @@
import pp.mdga.game.Color;
/**
* Notification that a die has been rolled.
*/
public class RollDiceNotification extends Notification{
RollDiceNotification(Color color, int eyes, int moveNumber) {
private Color color;
private int eyes;
private int moveNumber;
/**
* Constructor.
* @param color the color of the player that rolled the die.
* @param eyes the number of eyes that were rolled.
* @param moveNumber the number of the move that was made.
*/
RollDiceNotification(Color color, int eyes, int moveNumber) {
this.color = color;
this.eyes = eyes;
this.moveNumber = moveNumber;
}
/**
* Get the color of the player that rolled the die.
* @return the color of the player that rolled the die.
*/
public Color getColor() {
return color;
}
/**
* Get the number of eyes that were rolled.
* @return the number of eyes that were rolled.
*/
public int getEyes() {
return eyes;
}
/**
* Get the number of the move that was made.
* @return the number of the move that was made.
*/
public int getMoveNumber() {
return moveNumber;
}
}

View File

@@ -0,0 +1,28 @@
package pp.mdga.notification;
import pp.mdga.game.BonusCard;
import java.util.List;
/**
* Notification that contains a list of cards that the player can choose from.
*/
public class SelectableCardsNotification extends Notification {
private List<BonusCard> cards;
/**
* Constructor.
* @param cards The list of cards that the player can choose from.
*/
SelectableCardsNotification(List<BonusCard> cards) {
this.cards = cards;
}
/**
* Get the list of cards that the player can choose from.
* @return The list of cards that the player can choose from.
*/
public List<BonusCard> getCards() {
return cards;
}
}

View File

@@ -0,0 +1,26 @@
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;
}
}

View File

@@ -0,0 +1,12 @@
package pp.mdga.notification;
/**
* Notification that a dialog has been started
*/
public class StartDialogNotification extends Notification{
/**
* Constructor
*/
StartDialogNotification() {
}
}

View File

@@ -2,8 +2,38 @@
import java.util.UUID;
/**
* Notification that two pieces have been swapped.
*/
public class SwapPieceNotification extends Notification {
SwapPieceNotification(UUID a, UUID b) {
assert(!a.equals(b));
private UUID firstPiece;
private UUID secondPiece;
/**
* Constructor.
* @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) {
assert(!firstPiece.equals(secondPiece));
this.firstPiece = firstPiece;
this.secondPiece = secondPiece;
}
/**
* Get the UUID of the first piece that has been swapped.
* @return the UUID of the first piece that has been swapped.
*/
public UUID getFirstPiece() {
return firstPiece;
}
/**
* Get the UUID of the second piece that has been swapped.
* @return the UUID of the second piece that has been swapped.
*/
public UUID getSecondPiece() {
return secondPiece;
}
}

View File

@@ -0,0 +1,27 @@
package pp.mdga.notification;
import pp.mdga.game.Color;
/**
* Class TskSelectNotification
*/
public class TskSelectNotification extends Notification{
private Color color;
/**
* Constructor.
* @param color the color of the player that is in the game.
*/
TskSelectNotification(Color color) {
this.color = color;
}
/**
* Get the color of the player that is in the game.
* @return the color of the player that is in the game.
*/
public Color getColor() {
return color;
}
}

View File

@@ -0,0 +1,24 @@
package pp.mdga.notification;
import pp.mdga.game.Color;
public class TskUnselectNotification extends Notification{
private Color color;
/**
* Constructor
* @param color
*/
TskUnselectNotification(Color color){
this.color = color;
}
/**
* Get the color
* @return color
*/
public Color getColor() {
return color;
}
}

View File

@@ -0,0 +1,27 @@
package pp.mdga.notification;
import java.util.UUID;
/**
* Notification to inform the player that he has to wait for the other player to move.
*/
public class WaitMoveNotification extends Notification{
private UUID pieceId;
/**
* Constructor.
* @param pieceId the id of the piece that has to move.
*/
public WaitMoveNotification(UUID pieceId) {
this.pieceId = pieceId;
}
/**
* Get the id of the piece that has to move.
* @return the id of the piece that has to move.
*/
public UUID getPieceId() {
return pieceId;
}
}