Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
Fleischer Hanno
2024-12-01 21:49:30 +01:00
40 changed files with 481 additions and 111 deletions

View File

@@ -7,6 +7,7 @@
import com.jme3.texture.Texture2D; import com.jme3.texture.Texture2D;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.game.BonusCard;
import java.util.List; import java.util.List;
@@ -70,7 +71,7 @@ public void hideDice() {
cardLayerHandler.hideDice(); cardLayerHandler.hideDice();
} }
public void addCard(pp.mdga.game.BonusCard card) { public void addCard(BonusCard card) {
cardLayerHandler.addCard(card); cardLayerHandler.addCard(card);
} }
@@ -78,7 +79,7 @@ public void clearSelectableCards() {
cardLayerHandler.clearSelectableCards(); cardLayerHandler.clearSelectableCards();
} }
public void setSelectableCards(List<pp.mdga.game.BonusCard> select) { public void setSelectableCards(List<BonusCard> select) {
cardLayerHandler.setSelectableCards(select); cardLayerHandler.setSelectableCards(select);
} }

View File

@@ -8,12 +8,19 @@
* Notification that is sent when a card is acquired. * Notification that is sent when a card is acquired.
*/ */
public class AcquireCardNotification extends Notification { public class AcquireCardNotification extends Notification {
/**
* The id of the card that was acquired.
*/
private final UUID cardId;
private UUID cardId; /**
private BonusCard bonusCard; * The bonus card that was acquired.
*/
private final BonusCard bonusCard;
/** /**
* Constructor. * Constructor.
*
* @param cardId The id of the card that was acquired. * @param cardId The id of the card that was acquired.
*/ */
public AcquireCardNotification(BonusCard bonusCard, UUID cardId) { public AcquireCardNotification(BonusCard bonusCard, UUID cardId) {
@@ -23,6 +30,7 @@ public AcquireCardNotification(BonusCard bonusCard, UUID cardId) {
/** /**
* Get the id of the card that was acquired. * Get the id of the card that was acquired.
*
* @return The id of the card that was acquired. * @return The id of the card that was acquired.
*/ */
public UUID getCardId() { public UUID getCardId() {

View File

@@ -6,12 +6,16 @@
* Notification that the active player has changed * Notification that the active player has changed
*/ */
public class ActivePlayerNotification extends Notification { public class ActivePlayerNotification extends Notification {
/** /**
* The color of the active player * The color of the active player
*/ */
private Color color; private final Color color;
/**
* Constructor.
*
* @param color the color of the active player
*/
public ActivePlayerNotification(Color color) { public ActivePlayerNotification(Color color) {
this.color = color; this.color = color;
} }

View File

@@ -7,7 +7,7 @@
/** /**
* Class CeremonyNotification * Class CeremonyNotification
* Represents a notification for a ceremony in the game. * Represents a notification for a ceremony in the game.
* * <p>
* Index mapping: * Index mapping:
* index = 0 ==> winner * index = 0 ==> winner
* index = 1 ==> 2nd * index = 1 ==> 2nd
@@ -16,6 +16,9 @@
* index = 4 ==> total * index = 4 ==> total
*/ */
public class CeremonyNotification extends Notification { public class CeremonyNotification extends Notification {
/**
* Attributes.
*/
private ArrayList<Color> colors; private ArrayList<Color> colors;
private ArrayList<String> names; private ArrayList<String> names;
private ArrayList<Integer> piecesThrown; private ArrayList<Integer> piecesThrown;
@@ -40,8 +43,6 @@ public CeremonyNotification() {
this.bonusNodes = new ArrayList<>(); this.bonusNodes = new ArrayList<>();
} }
// Getters and Setters
/** /**
* @return the list of colors * @return the list of colors
*/ */

View File

@@ -4,7 +4,6 @@
* Notification that the dice is now. * Notification that the dice is now.
*/ */
public class DiceNowNotification extends Notification { public class DiceNowNotification extends Notification {
/** /**
* Constructor. * Constructor.
*/ */

View File

@@ -6,11 +6,14 @@
* Notification that is sent when a player has diced. * Notification that is sent when a player has diced.
*/ */
public class DicingNotification extends Notification { public class DicingNotification extends Notification {
/**
private Color color; * The color of the player that diced.
*/
private final Color color;
/** /**
* Constructor. * Constructor.
*
* @param color The color of the player that diced. * @param color The color of the player that diced.
*/ */
public DicingNotification(Color color) { public DicingNotification(Color color) {
@@ -19,6 +22,7 @@ public DicingNotification(Color color) {
/** /**
* Get the color of the player that diced. * Get the color of the player that diced.
*
* @return The color of the player that diced. * @return The color of the player that diced.
*/ */
public Color getColor() { public Color getColor() {

View File

@@ -7,9 +7,15 @@
* Notification that a card has been drawn * Notification that a card has been drawn
*/ */
public class DrawCardNotification extends Notification { public class DrawCardNotification extends Notification {
/**
* The color of the player who drew the card
*/
private final Color color;
private Color color; /**
private BonusCard card; * The card that was drawn
*/
private final BonusCard card;
/** /**
* @param color the color of the player who drew the card * @param color the color of the player who drew the card

View File

@@ -6,9 +6,15 @@
* Notification that a piece has moved to a home. * Notification that a piece has moved to a home.
*/ */
public class HomeMoveNotification extends Notification { public class HomeMoveNotification extends Notification {
/**
* The unique identifier of the piece.
*/
private final UUID pieceId;
private UUID pieceId; /**
private int homeIndex; * The index of the home position.
*/
private final int homeIndex;
/** /**
* Constructor. * Constructor.

View File

@@ -6,8 +6,10 @@
* Notification that a card has been drawn * Notification that a card has been drawn
*/ */
public class InterruptNotification extends Notification { public class InterruptNotification extends Notification {
/**
private Color color; * The color of the player who disconnected
*/
private final Color color;
/** /**
* @param color the color of the player who disconnected * @param color the color of the player who disconnected

View File

@@ -4,9 +4,4 @@
* Notification that a dialog has been started * Notification that a dialog has been started
*/ */
public class LobbyDialogNotification extends Notification { public class LobbyDialogNotification extends Notification {
/**
* Constructor
*/
public LobbyDialogNotification() {
}
} }

View File

@@ -1,14 +1,11 @@
package pp.mdga.notification; package pp.mdga.notification;
import pp.mdga.game.Color;
import java.util.UUID; import java.util.UUID;
/** /**
* Notification that a piece has been moved. * Notification that a piece has been moved.
*/ */
public class MovePieceNotification extends Notification { public class MovePieceNotification extends Notification {
/** /**
* The unique identifier of the piece being moved. * The unique identifier of the piece being moved.
*/ */

View File

@@ -6,8 +6,10 @@
* Notification that a piece has no shield. * Notification that a piece has no shield.
*/ */
public class NoShieldNotification extends Notification{ public class NoShieldNotification extends Notification{
/**
private UUID pieceId; * The id of the piece that has no shield.
*/
private final UUID pieceId;
/** /**
* Constructor. * Constructor.

View File

@@ -1,4 +1,7 @@
package pp.mdga.notification; package pp.mdga.notification;
/**
* Represents a notification that can be sent to a player.
*/
public abstract class Notification { public abstract class Notification {
} }

View File

@@ -7,12 +7,19 @@
* Notification that a card has been played. * Notification that a card has been played.
*/ */
public class PlayCardNotification extends Notification { public class PlayCardNotification extends Notification {
/**
* The color of the player that played the card.
*/
private final Color color;
private Color color; /**
private BonusCard card; * The card that was played.
*/
private final BonusCard card;
/** /**
* Constructor. * Constructor.
*
* @param color the color of the player that played the card. * @param color the color of the player that played the card.
* @param card the card that was played. * @param card the card that was played.
*/ */
@@ -23,6 +30,7 @@ public PlayCardNotification(Color color, BonusCard card) {
/** /**
* Get the color of the player that played the card. * Get the color of the player that played the card.
*
* @return the color of the player that played the card. * @return the color of the player that played the card.
*/ */
public Color getColor() { public Color getColor() {
@@ -31,6 +39,7 @@ public Color getColor() {
/** /**
* Get the card that was played. * Get the card that was played.
*
* @return the card that was played. * @return the card that was played.
*/ */
public BonusCard getCard() { public BonusCard getCard() {

View File

@@ -9,13 +9,24 @@
* Notification that a player is in the game. * Notification that a player is in the game.
*/ */
public class PlayerInGameNotification extends Notification { public class PlayerInGameNotification extends Notification {
/**
* The color of the player that is in the game.
*/
private final Color color;
private Color color; /**
private String name; * The name of the player that is in the game.
private List<UUID> piecesList; */
private final String name;
/**
* The list of piece IDs associated with the player.
*/
private final List<UUID> piecesList;
/** /**
* Constructor. * Constructor.
*
* @param color the color of the player that is in the game. * @param color the color of the player that is in the game.
* @param name the name of the player that is in the game. * @param name the name of the player that is in the game.
*/ */
@@ -27,6 +38,7 @@ public PlayerInGameNotification(Color color, List<UUID> piecesList, String name
/** /**
* Get the color of the player that is in the game. * Get the color of the player that is in the game.
*
* @return the color of the player that is in the game. * @return the color of the player that is in the game.
*/ */
public Color getColor() { public Color getColor() {
@@ -35,12 +47,18 @@ public Color getColor() {
/** /**
* Get the name of the player that is in the game. * Get the name of the player that is in the game.
*
* @return the name of the player that is in the game. * @return the name of the player that is in the game.
*/ */
public String getName() { public String getName() {
return name; return name;
} }
/**
* Get the list of piece IDs associated with the player.
*
* @return the list of piece IDs associated with the player.
*/
public List<UUID> getPiecesList() { public List<UUID> getPiecesList() {
return piecesList; return piecesList;
} }

View File

@@ -6,11 +6,14 @@
* Notification that a player is in the game. * Notification that a player is in the game.
*/ */
public class ResumeNotification extends Notification { public class ResumeNotification extends Notification {
/**
private Color color; * The color of the player that is in the game.
*/
private final Color color;
/** /**
* Constructor. * Constructor.
*
* @param color the color of the player that is in the game. * @param color the color of the player that is in the game.
*/ */
public ResumeNotification(Color color) { public ResumeNotification(Color color) {
@@ -19,6 +22,7 @@ public ResumeNotification(Color color) {
/** /**
* Get the color of the player that is in the game. * Get the color of the player that is in the game.
*
* @return the color of the player that is in the game. * @return the color of the player that is in the game.
*/ */
public Color getColor() { public Color getColor() {

View File

@@ -6,13 +6,24 @@
* Notification that a die has been rolled. * Notification that a die has been rolled.
*/ */
public class RollDiceNotification extends Notification { public class RollDiceNotification extends Notification {
/**
* The color of the player that rolled the die.
*/
private final Color color;
private Color color; /**
private int eyes; * The number of eyes that were rolled.
private int moveNumber; */
private final int eyes;
/**
* The number of the move that was made.
*/
private final int moveNumber;
/** /**
* Constructor. * Constructor.
*
* @param color the color of the player that rolled the die. * @param color the color of the player that rolled the die.
* @param eyes the number of eyes that were rolled. * @param eyes the number of eyes that were rolled.
* @param moveNumber the number of the move that was made. * @param moveNumber the number of the move that was made.
@@ -25,6 +36,7 @@ public RollDiceNotification(Color color, int eyes, int moveNumber) {
/** /**
* Get the color of the player that rolled the die. * Get the color of the player that rolled the die.
*
* @return the color of the player that rolled the die. * @return the color of the player that rolled the die.
*/ */
public Color getColor() { public Color getColor() {
@@ -33,6 +45,7 @@ public Color getColor() {
/** /**
* Get the number of eyes that were rolled. * Get the number of eyes that were rolled.
*
* @return the number of eyes that were rolled. * @return the number of eyes that were rolled.
*/ */
public int getEyes() { public int getEyes() {
@@ -41,6 +54,7 @@ public int getEyes() {
/** /**
* Get the number of the move that was made. * Get the number of the move that was made.
*
* @return the number of the move that was made. * @return the number of the move that was made.
*/ */
public int getMoveNumber() { public int getMoveNumber() {

View File

@@ -7,8 +7,10 @@
* Notification that contains a list of cards that the player can choose from. * Notification that contains a list of cards that the player can choose from.
*/ */
public class SelectableCardsNotification extends Notification { public class SelectableCardsNotification extends Notification {
/**
private List<BonusCard> cards; * The list of cards that the player can choose from.
*/
private final List<BonusCard> cards;
/** /**
* Constructor. * Constructor.

View File

@@ -7,7 +7,6 @@
* Notification for selecting pieces and their possible moves. * Notification for selecting pieces and their possible moves.
*/ */
public class SelectableMoveNotification extends Notification { public class SelectableMoveNotification extends Notification {
/** /**
* List of UUIDs representing the pieces that can be moved based on the dice roll. * List of UUIDs representing the pieces that can be moved based on the dice roll.
*/ */
@@ -16,7 +15,7 @@ public class SelectableMoveNotification extends Notification{
/** /**
* List of integers representing the target nodes the pieces can move to. * List of integers representing the target nodes the pieces can move to.
*/ */
private final List<Integer> moveIndexe; private final List<Integer> moveIndices;
/** /**
* List of booleans indicating whether the corresponding target nodes are in the home area. * List of booleans indicating whether the corresponding target nodes are in the home area.
@@ -28,12 +27,12 @@ public class SelectableMoveNotification extends Notification{
* Constructs a notification for selectable piece moves. * Constructs a notification for selectable piece moves.
* *
* @param pieces the list of pieces that can be moved * @param pieces the list of pieces that can be moved
* @param moveIndexe the list of target nodes for the moves * @param moveIndices the list of target nodes for the moves
* @param homeMoves the list indicating if the target nodes are in the home area * @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) { public SelectableMoveNotification(List<UUID> pieces, List<Integer> moveIndices, List<Boolean> homeMoves) {
this.pieces = pieces; this.pieces = pieces;
this.moveIndexe = moveIndexe; this.moveIndices = moveIndices;
this.homeMoves = homeMoves; this.homeMoves = homeMoves;
} }
@@ -51,8 +50,8 @@ public List<UUID> getPieces() {
* *
* @return a list of integers representing the target nodes * @return a list of integers representing the target nodes
*/ */
public List<Integer> getMoveIndexe() { public List<Integer> getMoveIndices() {
return moveIndexe; return moveIndices;
} }
/** /**

View File

@@ -7,7 +7,6 @@
* Notification for selecting pieces for swapcard. * Notification for selecting pieces for swapcard.
*/ */
public class SelectableSwapNotification extends Notification { public class SelectableSwapNotification extends Notification {
/** /**
* List of UUIDs representing the player's own pieces available for selection. * List of UUIDs representing the player's own pieces available for selection.
*/ */

View File

@@ -6,8 +6,10 @@
* This class will be used to hold all ShieldActiveNotification relevant data. * This class will be used to hold all ShieldActiveNotification relevant data.
*/ */
public class ShieldActiveNotification extends Notification { public class ShieldActiveNotification extends Notification {
/**
private UUID pieceId; * The pieceId
*/
private final UUID pieceId;
/** /**
* This constructor is used to create a new ShieldActiveNotification * This constructor is used to create a new ShieldActiveNotification

View File

@@ -6,8 +6,10 @@
* This class will be used to hold all ShieldSuppressedNotification relevant data. * This class will be used to hold all ShieldSuppressedNotification relevant data.
*/ */
public class ShieldSuppressedNotification extends Notification { public class ShieldSuppressedNotification extends Notification {
/**
private UUID pieceId; * The pieceId
*/
private final UUID pieceId;
/** /**
* This constructor is used to create a new ShieldSuppressedNotification * This constructor is used to create a new ShieldSuppressedNotification

View File

@@ -4,9 +4,4 @@
* Notification that a dialog has been started * Notification that a dialog has been started
*/ */
public class StartDialogNotification extends Notification { public class StartDialogNotification extends Notification {
/**
* Constructor
*/
public StartDialogNotification() {
}
} }

View File

@@ -6,12 +6,19 @@
* Notification that two pieces have been swapped. * Notification that two pieces have been swapped.
*/ */
public class SwapPieceNotification extends Notification { public class SwapPieceNotification extends Notification {
/**
* The UUID of the first piece that has been swapped.
*/
private final UUID firstPiece;
private UUID firstPiece; /**
private UUID secondPiece; * The UUID of the second piece that has been swapped.
*/
private final UUID secondPiece;
/** /**
* Constructor. * Constructor.
*
* @param firstPiece the UUID of the first piece that has been swapped. * @param firstPiece the UUID of the first piece that has been swapped.
* @param secondPiece the UUID of the second piece that has been swapped. * @param secondPiece the UUID of the second piece that has been swapped.
*/ */
@@ -23,6 +30,7 @@ public SwapPieceNotification(UUID firstPiece, UUID secondPiece) {
/** /**
* Get the UUID of the first piece that has been swapped. * Get the UUID of the first piece that has been swapped.
*
* @return the UUID of the first piece that has been swapped. * @return the UUID of the first piece that has been swapped.
*/ */
public UUID getFirstPiece() { public UUID getFirstPiece() {
@@ -31,6 +39,7 @@ public UUID getFirstPiece() {
/** /**
* Get the UUID of the second piece that has been swapped. * Get the UUID of the second piece that has been swapped.
*
* @return the UUID of the second piece that has been swapped. * @return the UUID of the second piece that has been swapped.
*/ */
public UUID getSecondPiece() { public UUID getSecondPiece() {

View File

@@ -1,12 +1,15 @@
package pp.mdga.notification; package pp.mdga.notification;
import pp.mdga.game.Color;
import java.util.UUID; import java.util.UUID;
/**
* Notification that is sent when a piece is thrown.
*/
public class ThrowPieceNotification extends Notification { public class ThrowPieceNotification extends Notification {
/**
private UUID pieceId; * The id of the piece that was thrown.
*/
private final UUID pieceId;
/** /**
* This constructor is used to create a new ThrowPieceNotification * This constructor is used to create a new ThrowPieceNotification
@@ -15,6 +18,11 @@ public ThrowPieceNotification(UUID pieceId) {
this.pieceId = pieceId; this.pieceId = pieceId;
} }
/**
* Get the id of the piece that was thrown.
*
* @return The id of the piece that was thrown.
*/
public UUID getPieceId() { public UUID getPieceId() {
return pieceId; return pieceId;
} }

View File

@@ -6,13 +6,24 @@
* Class TskSelectNotification * Class TskSelectNotification
*/ */
public class TskSelectNotification extends Notification { public class TskSelectNotification extends Notification {
/**
* The color of the player that is in the game.
*/
private final Color color; private final Color color;
/**
* The name of the player that is in the game.
*/
private final String name; private final String name;
/**
* Indicates if the select notification affects the own user.
*/
private final boolean isSelf; private final boolean isSelf;
/** /**
* Constructor. * Constructor.
*
* @param color the color of the player that is in the game. * @param color the color of the player that is in the game.
* @param name the name of the player that is in the game. * @param name the name of the player that is in the game.
*/ */
@@ -24,6 +35,7 @@ public TskSelectNotification(Color color, String name, boolean isSelf) {
/** /**
* Get the color of the player that is in the game. * Get the color of the player that is in the game.
*
* @return the color of the player that is in the game. * @return the color of the player that is in the game.
*/ */
public Color getColor() { public Color getColor() {
@@ -32,6 +44,7 @@ public Color getColor() {
/** /**
* Get the name of the player that is in the game. * Get the name of the player that is in the game.
*
* @return the name of the player that is in the game. * @return the name of the player that is in the game.
*/ */
public String getName() { public String getName() {

View File

@@ -2,13 +2,19 @@
import pp.mdga.game.Color; import pp.mdga.game.Color;
/**
* Notification for unselecting a player
*/
public class TskUnselectNotification extends Notification { public class TskUnselectNotification extends Notification {
/**
private Color color; * The color of the player
*/
private final Color color;
/** /**
* Constructor * Constructor
* @param color *
* @param color the color of the player
*/ */
public TskUnselectNotification(Color color) { public TskUnselectNotification(Color color) {
this.color = color; this.color = color;
@@ -16,6 +22,7 @@ public TskUnselectNotification(Color color){
/** /**
* Get the color * Get the color
*
* @return color * @return color
*/ */
public Color getColor() { public Color getColor() {

View File

@@ -6,11 +6,14 @@
* Notification to inform the player that he has to wait for the other player to move. * Notification to inform the player that he has to wait for the other player to move.
*/ */
public class WaitMoveNotification extends Notification { public class WaitMoveNotification extends Notification {
/**
private UUID pieceId; * The id of the piece that has to move.
*/
private final UUID pieceId;
/** /**
* Constructor. * Constructor.
*
* @param pieceId the id of the piece that has to move. * @param pieceId the id of the piece that has to move.
*/ */
public WaitMoveNotification(UUID pieceId) { public WaitMoveNotification(UUID pieceId) {
@@ -19,6 +22,7 @@ public WaitMoveNotification(UUID pieceId) {
/** /**
* Get the id of the piece that has to move. * Get the id of the piece that has to move.
*
* @return the id of the piece that has to move. * @return the id of the piece that has to move.
*/ */
public UUID getPieceId() { public UUID getPieceId() {

View File

@@ -25,10 +25,10 @@ public class ServerGameLogic implements ClientInterpreter {
* States * States
*/ */
private ServerState currentState; private ServerState currentState;
private final ServerState lobbyState; private final LobbyState lobbyState;
private final ServerState gameState; private final GameState gameState;
private final ServerState interruptState; private final InterruptState interruptState;
private final ServerState ceremonyState; private final CeremonyState ceremonyState;
/** /**
* Constructor. * Constructor.
@@ -167,36 +167,36 @@ public ServerState getCurrentState() {
/** /**
* This method will be used to return lobbyState attribute of ServerGameLogic class. * This method will be used to return lobbyState attribute of ServerGameLogic class.
* *
* @return lobbyState as a ServerState object. * @return lobbyState as a LobbyState object.
*/ */
public ServerState getLobbyState() { public LobbyState getLobbyState() {
return this.lobbyState; return this.lobbyState;
} }
/** /**
* This method will be used to return gameState attribute of ServerGameLogic class. * This method will be used to return gameState attribute of ServerGameLogic class.
* *
* @return gameState as a ServerState object. * @return gameState as a GameState object.
*/ */
public ServerState getGameState() { public GameState getGameState() {
return this.gameState; return this.gameState;
} }
/** /**
* This method will be used to return interruptState attribute of ServerGameLogic class. * This method will be used to return interruptState attribute of ServerGameLogic class.
* *
* @return interruptState as a ServerState object. * @return interruptState as a InterruptState object.
*/ */
public ServerState getInterruptState() { public InterruptState getInterruptState() {
return this.interruptState; return this.interruptState;
} }
/** /**
* This method will be used to return ceremonyState attribute of ServerGameLogic class. * This method will be used to return ceremonyState attribute of ServerGameLogic class.
* *
* @return ceremonyState as a ServerState object. * @return ceremonyState as a CeremonyState object.
*/ */
public ServerState getCeremonyState() { public CeremonyState getCeremonyState() {
return this.ceremonyState; return this.ceremonyState;
} }

View File

@@ -2,8 +2,23 @@
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.GameState; import pp.mdga.server.automaton.GameState;
import pp.mdga.server.automaton.game.turn.*;
/**
* This class represents the turn state of the server state automaton.
* It will also be used as the turn automaton.
*/
public class TurnState extends GameAutomatonState { public class TurnState extends GameAutomatonState {
/**
* Create TurnState states.
*/
private TurnAutomatonState currentState;
private final PowerCardState powerCardState;
private final PlayPowerCardState playPowerCardState;
private final RollDiceState rollDiceState;
private final ChoosePieceState choosePieceState;
private final MovePieceState movePieceState;
/** /**
* Constructs a server state of the specified game logic. * Constructs a server state of the specified game logic.
* *
@@ -12,6 +27,11 @@ public class TurnState extends GameAutomatonState {
*/ */
public TurnState(GameState gameAutomaton, ServerGameLogic logic) { public TurnState(GameState gameAutomaton, ServerGameLogic logic) {
super(gameAutomaton, logic); super(gameAutomaton, logic);
this.powerCardState = new PowerCardState(this, logic);
this.playPowerCardState = new PlayPowerCardState(this, logic);
this.rollDiceState = new RollDiceState(this, logic);
this.choosePieceState = new ChoosePieceState(this, logic);
this.movePieceState = new MovePieceState(this, logic);
} }
@Override @Override
@@ -23,4 +43,72 @@ public void enter() {
public void exit() { public void exit() {
} }
/**
* This method will be used to return currentState attribute of TurnState class.
*
* @return currentState as a TurnAutomatonState object.
*/
public TurnAutomatonState getCurrentState() {
return this.currentState;
}
/**
* This method will be used to return powerCardState attribute of TurnState class.
*
* @return powerCardState as a PowerCardState object.
*/
public PowerCardState getPowerCardState() {
return this.powerCardState;
}
/**
* This method will be used to return playPowerCardState attribute of TurnState class.
*
* @return playPowerState as a PlayPowerCardState object.
*/
public PlayPowerCardState getPlayPowerCardState() {
return this.playPowerCardState;
}
/**
* This method will be used to return rollDiceState attribute of TurnState class.
*
* @return rollDiceState as a RollDiceState object.
*/
public RollDiceState getRollDiceState() {
return this.rollDiceState;
}
/**
* This method will be used to return choosePieceState attribute of TurnState class.
*
* @return choosePieceState as a ChoosePieceState object.
*/
public ChoosePieceState getChoosePieceState() {
return this.choosePieceState;
}
/**
* This method will be used to return movePieceState attribute of TurnState class.
*
* @return movePieceState as a MovePieceState object.
*/
public MovePieceState getMovePieceState() {
return this.movePieceState;
}
/**
* This method will be used to set currentState attribute of TurnState class to the given state parameter.
* In Addition, the currentState will be exited, changed and entered.
*
* @param state as the new currentState attribute as a TurnAutomatonState object.
*/
public void setCurrentState(TurnAutomatonState state) {
if (this.currentState != null) {
this.currentState.exit();
}
this.currentState = state;
this.currentState.enter();
}
} }

View File

@@ -3,5 +3,24 @@
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.TurnState; import pp.mdga.server.automaton.game.TurnState;
public class ChoosePieceState { public class ChoosePieceState extends TurnAutomatonState {
/**
* Constructs a server state of the specified game logic.
*
* @param turnAutomaton as the automaton of the turn state as a GameState object.
* @param logic the game logic
*/
public ChoosePieceState(TurnState turnAutomaton, ServerGameLogic logic) {
super(turnAutomaton, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -3,6 +3,25 @@
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.TurnState; import pp.mdga.server.automaton.game.TurnState;
public class MovePieceState { public class MovePieceState extends TurnAutomatonState {
/**
* Constructs a server state of the specified game logic.
*
* @param turnAutomaton as the automaton of the turn state as a GameState object.
* @param logic the game logic
*/
public MovePieceState(TurnState turnAutomaton, ServerGameLogic logic) {
super(turnAutomaton, logic);
}
@Override
public void enter() {
} }
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,26 @@
package pp.mdga.server.automaton.game.turn;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.TurnState;
public class PlayPowerCardState extends TurnAutomatonState {
/**
* Constructs a server state of the specified game logic.
*
* @param turnAutomaton as the automaton of the turn state as a GameState object.
* @param logic the game logic
*/
public PlayPowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
super(turnAutomaton, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -3,5 +3,24 @@
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.TurnState; import pp.mdga.server.automaton.game.TurnState;
public class PowerCardState { public class PowerCardState extends TurnAutomatonState {
/**
* Constructs a server state of the specified game logic.
*
* @param turnAutomaton as the automaton of the turn state as a GameState object.
* @param logic the game logic
*/
public PowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
super(turnAutomaton, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -3,5 +3,24 @@
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.TurnState; import pp.mdga.server.automaton.game.TurnState;
public class RollDiceState { public class RollDiceState extends TurnAutomatonState {
/**
* Constructs a server state of the specified game logic.
*
* @param turnAutomaton as the automaton of the turn state as a GameState object.
* @param logic the game logic
*/
public RollDiceState(TurnState turnAutomaton, ServerGameLogic logic) {
super(turnAutomaton, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
} }

View File

@@ -0,0 +1,23 @@
package pp.mdga.server.automaton.game.turn;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.ServerState;
import pp.mdga.server.automaton.game.TurnState;
public abstract class TurnAutomatonState extends ServerState {
/**
* Create TurnAutomatonState attributes.
*/
protected final TurnState turnAutomaton;
/**
* Constructs a server state of the specified game logic.
*
* @param turnAutomaton as the automaton of the turn state as a GameState object.
* @param logic the game logic
*/
public TurnAutomatonState(TurnState turnAutomaton, ServerGameLogic logic) {
super(logic);
this.turnAutomaton = turnAutomaton;
}
}

View File

@@ -0,0 +1,22 @@
package pp.mdga.server.automaton.game.turn.choosepiece;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.ServerState;
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
public abstract class ChoosePieceAutomatonState extends ServerState {
/**
* Create ChoosePieceAutomatonState attributes.
*/
protected final ChoosePieceState choosePieceAutomaton;
/**
* Constructs a server state of the specified game logic.
*
* @param logic the game logic
*/
public ChoosePieceAutomatonState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {
super(logic);
this.choosePieceAutomaton = choosePieceAutomaton;
}
}

View File

@@ -0,0 +1,22 @@
package pp.mdga.server.automaton.game.turn.rolldice;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.ServerState;
import pp.mdga.server.automaton.game.turn.RollDiceState;
public abstract class RollDiceAutomatonState extends ServerState {
/**
* Create RollDiceAutomatonState attributes.
*/
protected final RollDiceState rollDiceAutomaton;
/**
* Constructs a server state of the specified game logic.
*
* @param logic the game logic
*/
public RollDiceAutomatonState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
super(logic);
this.rollDiceAutomaton = rollDiceAutomaton;
}
}