diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/CeremonyStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/CeremonyStates.java index b60ed5e9..9fe9de1f 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/CeremonyStates.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/CeremonyStates.java @@ -4,6 +4,13 @@ import pp.mdga.client.ClientState; public abstract class CeremonyStates extends ClientState { + + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ protected CeremonyStates(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/PodiumState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/PodiumState.java index 5844e381..a32811ce 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/PodiumState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/PodiumState.java @@ -8,21 +8,36 @@ public class PodiumState extends CeremonyStates { private final CeremonyState parent; + /** + * This constructs a new PodiumState. + * + * @param parent the parent state + * @param logic the client game logic + */ public PodiumState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (CeremonyState) parent; } + /** + * This method will be called whenever the client enters the PodiumState. + */ @Override public void enter() { } + /** + * This method will be called whenever the client exits the PodiumState. + */ @Override public void exit() { } + /** + * This method will be called whenever the client selects the next button. + */ @Override public void selectNext() { parent.setState(parent.getStatisticsState()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/StatisticsState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/StatisticsState.java index 3dcbd1a5..2d3bc943 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/StatisticsState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonystate/StatisticsState.java @@ -4,20 +4,36 @@ import pp.mdga.client.ClientState; public class StatisticsState extends CeremonyStates { + + /** + * This constructs a new StatisticsState. + * + * @param parent the parent state + * @param logic the client game logic + */ public StatisticsState(ClientState parent, ClientGameLogic logic) { super(parent, logic); } + /** + * This method will be called whenever the client enters the StatisticsState. + */ @Override public void enter() { } + /** + * This method will be called whenever the client exits the StatisticsState. + */ @Override public void exit() { } + /** + * This method will be called whenever the client selects the next button. + */ @Override public void selectNext() { logic.setState(logic.getDialogs()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogstate/DialogStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogstate/DialogStates.java index 12a4ad8a..0a62dba8 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogstate/DialogStates.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogstate/DialogStates.java @@ -5,6 +5,12 @@ public abstract class DialogStates extends ClientState { + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public DialogStates(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogstate/LobbyState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogstate/LobbyState.java index 499bcc08..a7c07a31 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogstate/LobbyState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogstate/LobbyState.java @@ -19,20 +19,35 @@ public class LobbyState extends DialogStates { private final DialogsState parent; + /** + * The constructor of the LobbyState. + * + * @param parent the parent state + * @param logic the client game logic + */ public LobbyState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (DialogsState) parent; } + /** + * This method will be called whenever the client enters the LobbyState. + */ @Override public void enter() { logic.send(new JoinedLobbyMessage(logic.getOwnPlayerName())); } + /** + * This method will be called whenever the client exits the LobbyState. + */ @Override public void exit() { } + /** + * This method will be called whenever the client selects the leave button. + */ @Override public void selectLeave() { parent.setState(parent.getStartDialog()); @@ -40,26 +55,45 @@ public void selectLeave() { logic.send(new LeaveGameMessage()); } + /** + * This method will be called whenever the client selects the color of the player. + * + * @param color the color of the player + */ @Override public void selectTSK(Color color) { logic.send(new SelectTSKMessage(color)); } + /** + * This method will be called whenever the client deselects the color of the player. + * + * @param color the color of the player + */ @Override public void deselectTSK(Color color) { logic.send(new DeselectTSKMessage(color)); } + /** + * This method will be called whenever the client selects the ready button. + */ @Override public void selectReady() { logic.send(new LobbyReadyMessage()); } + /** + * This method will be called whenever the client selects the unready button. + */ @Override public void selectUnready() { logic.send(new LobbyNotReadyMessage()); } + /** + * This method will be called whenever the client selects the start button. + */ @Override public void selectStart() { if (logic.isHost() && logic.getGame().areAllReady()) { @@ -70,6 +104,11 @@ public void selectStart() { } } + /** + * This method will be called whenever the client receives a message. + * + * @param msg the message which was received + */ @Override public void received(ServerStartGameMessage msg) { for (Player player : msg.getPlayers()) { @@ -91,6 +130,11 @@ public void received(ServerStartGameMessage msg) { logic.setState(logic.getGameState()); } + /** + * This method will be called whenever the client receives a message. + * + * @param msg the message which was received + */ @Override public void received(LobbyPlayerJoinedMessage msg) { if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) { @@ -105,6 +149,11 @@ public void received(LobbyPlayerJoinedMessage msg) { logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer()); } + /** + * This method will be called whenever the client receives a message. + * + * @param msg the message which was received + */ @Override public void received(UpdateTSKMessage msg) { if (msg.isTaken()) { @@ -116,15 +165,24 @@ public void received(UpdateTSKMessage msg) { logic.getGame().getPlayers().get(msg.getId()).setColor(msg.getColor()); } + /** + * This method will be called whenever the client receives a message. + * + * @param msg the message which was received + */ @Override public void received(LobbyPlayerLeaveMessage msg) { logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor())); logic.getGame().getPlayers().remove(msg.getId()); } + /** + * This method will be called whenever the client receives a message. + * + * @param msg the message which was received + */ @Override public void received(UpdateReadyMessage msg) { - //TODO server sendet kein update on UNready logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady())); logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady()); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/AnimationState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/AnimationState.java index 616ad863..9f36617f 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/AnimationState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/AnimationState.java @@ -11,20 +11,35 @@ public class AnimationState extends GameStates { private final GameState parent; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public AnimationState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (GameState) parent; } + /** + * Enters the state. + */ @Override public void enter() { } + /** + * Exits the state. + */ @Override public void exit() { } + /** + * Selects the animation end. + */ @Override public void selectAnimationEnd() { logic.send(new AnimationEndMessage()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/DetermineStartPlayerState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/DetermineStartPlayerState.java index 46e0596d..d1d4cb39 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/DetermineStartPlayerState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/DetermineStartPlayerState.java @@ -18,41 +18,83 @@ public class DetermineStartPlayerState extends GameStates { private final WaitRankingState waitRankingState = new WaitRankingState(this, logic); private final Intro intro = new Intro(this, logic); + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (GameState) parent; } + /** + * Gets the roll ranking dice. + * + * @return the roll ranking dice + */ public RollRankingDiceState getRollRankingDice() { return rollRankingDiceState; } + /** + * Gets the wait ranking. + * + * @return the wait ranking + */ public WaitRankingState getWaitRanking() { return waitRankingState; } + /** + * Gets the state. + * + * @return the state + */ public DetermineStartPlayerStates getState() { return state; } + /** + * Gets the intro. + * + * @return the intro + */ public Intro getIntro() { return intro; } + /** + * Gets the parent state. + * + * @return the parent state + */ public GameState getParent() { return parent; } + /** + * Enters the state. + */ @Override public void enter() { this.setState(this.rollRankingDiceState); } + /** + * Exits the state. + */ @Override public void exit() { state = null; } + /** + * Sets the state. + * + * @param state the state + */ public void setState(DetermineStartPlayerStates state) { System.out.println("CLIENT STATE old: " + this.state + " new: " + state); if (this.state != null) { @@ -62,36 +104,67 @@ public void setState(DetermineStartPlayerStates state) { this.state.enter(); } + /** + * Selects the dice. + */ @Override public void selectDice() { state.selectDice(); } + /** + * Selects the animation end. + */ @Override public void selectAnimationEnd() { state.selectAnimationEnd(); } + /** + * Receives the die message. + * + * @param msg the die message + */ @Override public void received(DieMessage msg) { state.received(msg); } + /** + * Receives the ceremony message. + * + * @param msg the ceremony message + */ @Override public void received(DiceNowMessage msg) { state.received(msg); } + /** + * Receives the ranking roll again message. + * + * @param msg the ranking roll again message + */ @Override public void received(RankingRollAgainMessage msg) { state.received(msg); } + /** + * Receives the ranking response message. + * + * @param msg the ranking response message + */ @Override public void received(RankingResponseMessage msg) { state.received(msg); } + /** + * Receives the ranking result message. + * + * @param msg the ranking result message + */ @Override public void received(ActivePlayerMessage msg) { state.received(msg); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/GameStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/GameStates.java index 172a9be8..9b0cf0a2 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/GameStates.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/GameStates.java @@ -14,10 +14,21 @@ public abstract class GameStates extends ClientState { private final System.Logger LOGGER = System.getLogger(this.getClass().getName()); + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public GameStates(ClientState parent, ClientGameLogic logic) { super(parent, logic); } + /** + * Handles the power card. + * + * @param msg the play card message + */ protected void handlePowerCard(PlayCardMessage msg) { if (msg.getCard().getCard().equals(BonusCard.TURBO)) { logic.getGame().setTurboFlag(true); @@ -30,6 +41,11 @@ protected void handlePowerCard(PlayCardMessage msg) { logic.getGame().getDiscardPile().add(msg.getCard()); } + /** + * Handles the shield. + * + * @param uuid the uuid + */ private void handleShield(UUID uuid) { Board board = logic.getGame().getBoard(); Piece piece = logic.getGame().getPieceThroughUUID(uuid); @@ -44,6 +60,12 @@ private void handleShield(UUID uuid) { } } + /** + * Swaps the pieces. + * + * @param messageOwn the own piece + * @param messageEnemy the enemy piece + */ private void swapPieces(Piece messageOwn, Piece messageEnemy) { //swap Pieces in Model Board board = logic.getGame().getBoard(); @@ -61,6 +83,12 @@ private void swapPieces(Piece messageOwn, Piece messageEnemy) { } + /** + * Checks the shield after the swap. + * + * @param node the node + * @param piece the piece + */ private void checkShieldAfterSwap(Node node, Piece piece) { if (node.isStart()) { if (piece.isShielded()) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/SpectatorState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/SpectatorState.java index 5c2629f3..9b123bc9 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/SpectatorState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/SpectatorState.java @@ -15,25 +15,45 @@ public class SpectatorState extends GameStates { private final GameState parent; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public SpectatorState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (GameState) parent; } + /** + * Enters the state. + */ @Override public void enter() { } + /** + * Exits the state. + */ @Override public void exit() { } + /** + * Receives the Ceremony Message. + */ @Override public void received(CeremonyMessage msg) { logic.setState(logic.getCeremony()); } + /** + * Receives the Draw card message. + * + * @param msg the draw card message + */ @Override public void received(DrawCardMessage msg) { logic.getGame().getActivePlayer().addHandCard(msg.getCard()); @@ -46,17 +66,19 @@ public void received(DrawCardMessage msg) { logic.getGame().getGameStatistics().increaseActivatedBonusNodes(); } + /** + * Receives the Die Message. + */ @Override public void received(DieMessage msg) { - //logic.getGame().setDiceEyes(msg.getDiceEye()); -// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); - if (msg.getDiceEye() == 6) { - logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6(); - logic.getGame().getGameStatistics().increaseDiced6(); - } + logic.getGame().setDiceEyes(msg.getDiceEye()); + logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); parent.setState(parent.getAnimation()); } + /** + * Receives the PlayCardMessage Message. + */ @Override public void received(PlayCardMessage msg) { logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard())); @@ -66,6 +88,9 @@ public void received(PlayCardMessage msg) { parent.setState(parent.getAnimation()); } + /** + * Receives the ActivePlayerMessage Message. + */ @Override public void received(ActivePlayerMessage msg) { logic.addNotification(new ActivePlayerNotification(msg.getColor())); @@ -73,6 +98,9 @@ public void received(ActivePlayerMessage msg) { parent.setState(parent.getAnimation()); } + /** + * Receives the MoveMessage Message. + */ @Override public void received(MoveMessage msg) { Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/TurnState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/TurnState.java index 835a2a9c..35a29baa 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/TurnState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/TurnState.java @@ -3,11 +3,30 @@ import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientState; import pp.mdga.client.GameState; -import pp.mdga.client.gamestate.turnstate.*; +import pp.mdga.client.gamestate.turnstate.ChoosePieceState; +import pp.mdga.client.gamestate.turnstate.MovePieceState; +import pp.mdga.client.gamestate.turnstate.PlayPowerCardState; +import pp.mdga.client.gamestate.turnstate.PowerCardState; +import pp.mdga.client.gamestate.turnstate.RollDiceState; +import pp.mdga.client.gamestate.turnstate.TurnStates; import pp.mdga.game.BonusCard; import pp.mdga.game.Piece; import pp.mdga.game.ShieldState; -import pp.mdga.message.server.*; +import pp.mdga.message.server.CeremonyMessage; +import pp.mdga.message.server.ChoosePieceStateMessage; +import pp.mdga.message.server.DiceAgainMessage; +import pp.mdga.message.server.DiceNowMessage; +import pp.mdga.message.server.DieMessage; +import pp.mdga.message.server.EndOfTurnMessage; +import pp.mdga.message.server.MoveMessage; +import pp.mdga.message.server.NoTurnMessage; +import pp.mdga.message.server.PlayCardMessage; +import pp.mdga.message.server.PossibleCardsMessage; +import pp.mdga.message.server.PossiblePieceMessage; +import pp.mdga.message.server.SelectPieceMessage; +import pp.mdga.message.server.SpectatorMessage; +import pp.mdga.message.server.StartPieceMessage; +import pp.mdga.message.server.WaitPieceMessage; import pp.mdga.notification.RemoveShieldNotification; public class TurnState extends GameStates { @@ -22,11 +41,20 @@ public class TurnState extends GameStates { private final RollDiceState rollDiceState = new RollDiceState(this, logic); private boolean canChangeTurbo = false; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public TurnState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (GameState) parent; } + /** + * Enters the state. + */ @Override public void enter() { logic = logic; @@ -40,11 +68,19 @@ public void enter() { this.setState(this.powerCardState); } + /** + * Exits the state. + */ @Override public void exit() { state = null; } + /** + * Sets the state. + * + * @param state the state + */ public void setState(TurnStates state) { System.out.println("CLIENT STATE old: " + this.state + " new: " + state); if (this.state != null) { @@ -54,133 +90,269 @@ public void setState(TurnStates state) { this.state = state; } + /** + * Selects the dice. + */ @Override public void selectDice() { state.selectDice(); } + /** + * Selects the piece. + * + * @param piece the piece + */ @Override public void selectPiece(Piece piece) { state.selectPiece(piece); } + /** + * Selects the card. + * + * @param card the card + */ @Override public void selectCard(BonusCard card) { state.selectCard(card); } + /** + * Selects the animation end. + */ @Override public void selectAnimationEnd() { state.selectAnimationEnd(); } + /** + * Receives the select piece message. + * + * @param msg the select piece message + */ @Override public void received(SelectPieceMessage msg) { state.received(msg); } + /** + * Receives the wait piece message. + * + * @param msg the wait piece message + */ @Override public void received(WaitPieceMessage msg) { state.received(msg); } + /** + * Receives the start piece message. + * + * @param msg the start piece message + */ @Override public void received(StartPieceMessage msg) { state.received(msg); } + /** + * Receives the NoTurnMessage message. + * + * @param msg the NoTurnMessage message + */ @Override public void received(NoTurnMessage msg) { state.received(msg); } + /** + * Receives the MoveMessage message. + * + * @param msg the MoveMessage message + */ @Override public void received(MoveMessage msg) { state.received(msg); } + /** + * Receives the CeremonyMessage message. + * + * @param msg the CeremonyMessage message + */ @Override public void received(CeremonyMessage msg) { state.received(msg); } + /** + * Receives the EndOfTurnMessage message. + * + * @param msg the EndOfTurnMessage message + */ @Override public void received(EndOfTurnMessage msg) { state.received(msg); } + /** + * Receives the SpectatorMessage message. + * + * @param msg the SpectatorMessage message + */ @Override public void received(SpectatorMessage msg) { state.received(msg); } + /** + * Receives the DiceAgainMessage message. + * + * @param msg the DiceAgainMessage message + */ @Override public void received(DiceAgainMessage msg) { state.received(msg); } + /** + * Receives the PossibleCardsMessage message. + * + * @param msg the PossibleCardsMessage message + */ @Override public void received(PossibleCardsMessage msg) { state.received(msg); } + /** + * Receives the PlayCardMessage message. + * + * @param msg the PlayCardMessage message + */ @Override public void received(PlayCardMessage msg) { state.received(msg); } + /** + * Receives the DiceNow message. + * + * @param msg the DiceNow message + */ @Override public void received(DiceNowMessage msg) { state.received(msg); } + /** + * Receives the DieMessage message. + * + * @param msg the DieMessage message + */ @Override public void received(DieMessage msg) { state.received(msg); } + /** + * Receives the PossiblePieceMessage message. + * + * @param msg the PossiblePieceMessage message + */ @Override public void received(PossiblePieceMessage msg) { state.received(msg); } + /** + * Receives the ChoosePieceStateMessage message. + * + * @param msg the ChoosePieceStateMessage message + */ @Override public void received(ChoosePieceStateMessage msg) { state.received(msg); } + /** + * Gets the ChoosePieceState. + * + * @return the ChoosePieceState + */ public ChoosePieceState getChoosePiece() { return choosePieceState; } + /** + * Gets the MovePieceState. + * + * @return the MovePieceState + */ public MovePieceState getMovePiece() { return movePieceState; } + /** + * Gets the PlayPowerCardState. + * + * @return the PlayPowerCardState + */ public PlayPowerCardState getPlayPowerCard() { return playPowerCardState; } + /** + * Gets the PowerCardState. + * + * @return the PowerCardState + */ public PowerCardState getPowerCard() { return powerCardState; } + /** + * Gets the RollDiceState. + * + * @return the RollDiceState + */ public RollDiceState getRollDice() { return rollDiceState; } + /** + * Gets the parent GameState. + * + * @return the parent GameState + */ public GameState getParent() { return parent; } + /** + * Gets the current TurnStates. + * + * @return the current TurnStates + */ public TurnStates getState() { return state; } + /** + * Checks if turbo can be changed. + * + * @return true if turbo can be changed, false otherwise + */ public boolean isCanChangeTurbo() { return canChangeTurbo; } + /** + * Sets the turbo change flag. + * + * @param canChangeTurbo the new value for the turbo change flag + */ public void setCanChangeTurbo(boolean canChangeTurbo) { this.canChangeTurbo = canChangeTurbo; } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/WaitingState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/WaitingState.java index 5496f6ca..615f2fcc 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/WaitingState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/WaitingState.java @@ -10,31 +10,56 @@ import pp.mdga.message.server.*; import pp.mdga.notification.*; +/** + * Represents the waiting state in the game. + */ public class WaitingState extends GameStates { private final GameState parent; private final System.Logger LOGGER = System.getLogger(this.getClass().getName()); + /** + * Constructs a new WaitingState. + * + * @param parent the parent state + * @param logic the game logic + */ public WaitingState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (GameState) parent; } + /** + * Called when entering the waiting state. + */ @Override public void enter() { } + /** + * Called when exiting the waiting state. + */ @Override public void exit() { } + /** + * Handles the reception of a CeremonyMessage. + * + * @param msg the ceremony message + */ @Override public void received(CeremonyMessage msg) { logic.setState(logic.getCeremony()); } + /** + * Handles the reception of a DieMessage. + * + * @param msg the die message + */ @Override public void received(DieMessage msg) { logic.getGame().setDiceEyes(msg.getDiceEye()); @@ -51,6 +76,11 @@ public void received(DieMessage msg) { } } + /** + * Handles the reception of a PlayCardMessage. + * + * @param msg the play card message + */ @Override public void received(PlayCardMessage msg) { logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard())); @@ -60,6 +90,11 @@ public void received(PlayCardMessage msg) { parent.setState(parent.getAnimation()); } + /** + * Handles the reception of an ActivePlayerMessage. + * + * @param msg the active player message + */ @Override public void received(ActivePlayerMessage msg) { logic.addNotification(new ActivePlayerNotification(msg.getColor())); @@ -76,6 +111,11 @@ public void received(ActivePlayerMessage msg) { } } + /** + * Handles the reception of a MoveMessage. + * + * @param msg the move message + */ @Override public void received(MoveMessage msg) { Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/DetermineStartPlayerStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/DetermineStartPlayerStates.java index 1ec1ac4d..938c6420 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/DetermineStartPlayerStates.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/DetermineStartPlayerStates.java @@ -5,6 +5,13 @@ import pp.mdga.client.gamestate.GameStates; public abstract class DetermineStartPlayerStates extends GameStates { + + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/RollRankingDiceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/RollRankingDiceState.java index 4b7fcbde..38f4a2bc 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/RollRankingDiceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/RollRankingDiceState.java @@ -15,23 +15,38 @@ public class RollRankingDiceState extends DetermineStartPlayerStates { private final DetermineStartPlayerState parent; private boolean isRolled = false; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public RollRankingDiceState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (DetermineStartPlayerState) parent; } + /** + * Enters the state. + */ @Override public void enter() { LOGGER.log(System.Logger.Level.INFO, "Entering RollRankingDiceState"); logic.addNotification(new DiceNowNotification()); } + /** + * Exits the state. + */ @Override public void exit() { LOGGER.log(System.Logger.Level.INFO, "Exiting RollRankingDiceState"); isRolled = false; } + /** + * Selects the dice. + */ @Override public void selectDice() { if (!isRolled) { @@ -40,6 +55,11 @@ public void selectDice() { } } + /** + * This method is called when the server sends a DieMessage. + * + * @param msg the DieMessage + */ @Override public void received(DieMessage msg) { parent.setState(parent.getWaitRanking()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/WaitRankingState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/WaitRankingState.java index 6077d5d1..d9eebd58 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/WaitRankingState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/determinestartplayerstate/WaitRankingState.java @@ -20,11 +20,20 @@ public class WaitRankingState extends DetermineStartPlayerStates { private final DetermineStartPlayerState parent; private boolean canChange = false; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public WaitRankingState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (DetermineStartPlayerState) parent; } + /** + * Changes the state to the intro state. + */ private void changeToIntro() { if (!canChange) { canChange = true; @@ -33,22 +42,38 @@ private void changeToIntro() { parent.setState(parent.getIntro()); } + /** + * Enters the state. + */ @Override public void enter() { LOGGER.log(System.Logger.Level.INFO, "Entering WaitRankingState"); } + /** + * Exits the state. + */ @Override public void exit() { canChange = false; LOGGER.log(System.Logger.Level.INFO, "Exiting WaitRankingState"); } + /** + * This method is called when the server sends a DiceNowMessage. + * + * @param msg the DiceNowMessage + */ @Override public void received(DiceNowMessage msg) { parent.setState(parent.getRollRankingDice()); } + /** + * This method is called when the server sends a RankingResponseMessage. + * + * @param msg the RankingResponseMessage + */ @Override public void received(RankingResponseMessage msg) { Map rankingResults = new HashMap<>(); @@ -58,12 +83,20 @@ public void received(RankingResponseMessage msg) { logic.addNotification(new RankingResponceNotification(rankingResults)); } + /** + * This method is called when the view has completed the animation. + */ @Override public void selectAnimationEnd() { changeToIntro(); logic.send(new AnimationEndMessage()); } + /** + * This method is called when the server sends an ActivePlayerMessage. + * + * @param msg the ActivePlayerMessage + */ @Override public void received(ActivePlayerMessage msg) { logic.getGame().setActiveColor(msg.getColor()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/ChoosePieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/ChoosePieceState.java index b205b992..bf6058e3 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/ChoosePieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/ChoosePieceState.java @@ -17,22 +17,39 @@ public class ChoosePieceState extends TurnStates { private final StartPieceState startPieceState = new StartPieceState(this, logic); private final WaitingPieceState waitingPieceState = new WaitingPieceState(this, logic); + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public ChoosePieceState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (TurnState) parent; } + /** + * Enters the state. + */ @Override public void enter() { this.setState(this.noPieceState); } + /** + * Exits the state. + */ @Override public void exit() { currentState.exit(); currentState = null; } + /** + * Sets the state. + * + * @param state the state + */ public void setState(ChoosePieceStates state) { System.out.println("CLIENT STATE old: " + this.currentState + " new: " + state); if (currentState != null) { @@ -42,56 +59,104 @@ public void setState(ChoosePieceStates state) { currentState = state; } + /** + * Selects the piece. + * + * @param piece the piece + */ @Override public void selectPiece(Piece piece) { currentState.selectPiece(piece); } + /** + * Receives the select piece message. + * + * @param msg the select piece message + */ @Override public void received(SelectPieceMessage msg) { currentState.received(msg); } + /** + * Receives the wait piece message. + * + * @param msg the wait piece message + */ @Override public void received(WaitPieceMessage msg) { currentState.received(msg); } + /** + * Receives the start piece message. + * + * @param msg the start piece message + */ @Override public void received(StartPieceMessage msg) { currentState.received(msg); } + /** + * Receives the end of turn message. + * + * @param msg the end of turn message + */ @Override public void received(EndOfTurnMessage msg) { currentState.received(msg); } + /** + * Receives the move message. + * + * @param msg the move message + */ @Override public void received(MoveMessage msg) { currentState.received(msg); } + /** + * Returns the no piece state. + */ public NoPieceState getNoPiece() { return noPieceState; } + /** + * Returns the select piece state. + */ public SelectPieceState getSelectPiece() { return selectPieceState; } + /** + * Returns the start piece state. + */ public StartPieceState getStartPiece() { return startPieceState; } + /** + * Returns the waiting piece state. + */ public WaitingPieceState getWaitingPiece() { return waitingPieceState; } + /** + * Returns the current state. + */ public ChoosePieceStates getState() { return currentState; } + /** + * Returns the parent state. + */ public TurnState getParent() { return parent; } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/MovePieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/MovePieceState.java index 5e865e36..83b04d5a 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/MovePieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/MovePieceState.java @@ -13,46 +13,86 @@ public class MovePieceState extends TurnStates { private final TurnState parent; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public MovePieceState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (TurnState) parent; } + /** + * Enters the state. + */ @Override public void enter() { } + /** + * Exits the state. + */ @Override public void exit() { } + /** + * Selects the animation end. + */ @Override public void selectAnimationEnd() { logic.send(new AnimationEndMessage()); } + /** + * Receives the ceremony message. + * + * @param msg the ceremony message + */ @Override public void received(CeremonyMessage msg) { logic.setState(logic.getCeremony()); } + /** + * Receives the end of turn message. + * + * @param msg the end of turn message + */ @Override public void received(EndOfTurnMessage msg) { parent.getParent().setState(parent.getParent().getWaiting()); } + /** + * Receives the spectator message. + * + * @param msg the spectator message + */ @Override public void received(SpectatorMessage msg) { parent.getParent().setState(parent.getParent().getSpectator()); } + /** + * Receives the dice now message. + * + * @param msg the dice now message + */ @Override public void received(DiceNowMessage msg) { parent.setState(parent.getRollDice()); } + /** + * Gets the parent state. + * + * @return the parent state + */ public TurnState getParent() { return parent; } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/PlayPowerCardState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/PlayPowerCardState.java index 3cfb80f1..a1a18dd4 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/PlayPowerCardState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/PlayPowerCardState.java @@ -15,11 +15,20 @@ public class PlayPowerCardState extends TurnStates { private PlayCardMessage playCardMessage; private int extraAnimationCounter = 0; + /** + * Constructor + * + * @param parent parent state + * @param logic game logic + */ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (TurnState) parent; } + /** + * Enter the state + */ @Override public void enter() { if (playCardMessage.getCard().getCard().equals(BonusCard.SWAP)) { @@ -31,15 +40,26 @@ public void enter() { handlePowerCard(playCardMessage); } + /** + * Exits the state + */ @Override public void exit() { playCardMessage = null; } + /** + * Handle the power card + * + * @param playCardMessage the play card message + */ public void setPlayCard(PlayCardMessage playCardMessage) { this.playCardMessage = playCardMessage; } + /** + * The view has finished its animation + */ @Override public void selectAnimationEnd() { if (extraAnimationCounter > 0) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/PowerCardState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/PowerCardState.java index aeb6a58b..4bcea25b 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/PowerCardState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/PowerCardState.java @@ -23,22 +23,38 @@ public class PowerCardState extends TurnStates { private final ShieldState shieldState = new ShieldState(this, logic); private final SwapState swapState = new SwapState(this, logic); - + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public PowerCardState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (TurnState) parent; } + /** + * Enters the state. + */ @Override public void enter() { this.setState(this.choosePowerCardState); } + /** + * Exits the state. + */ public void exit() { state.exit(); state = null; } + /** + * Sets the state. + * + * @param state the state + */ public void setState(PowerCardStates state) { System.out.println("CLIENT STATE old: " + this.state + " new: " + state); @@ -49,52 +65,97 @@ public void setState(PowerCardStates state) { this.state = state; } + /** + * Receives the possible cards message. + * + * @param msg the possible cards message + */ @Override public void received(PossibleCardsMessage msg) { state.received(msg); } + /** + * Receives the play card message. + * + * @param msg the play card message + */ @Override public void received(PlayCardMessage msg) { state.received(msg); } + /** + * Receives the dice now message. + * + * @param msg the dice now message + */ @Override public void received(DiceNowMessage msg) { state.received(msg); } + /** + * Receives the possible piece message. + * + * @param msg the possible piece message + */ @Override public void received(PossiblePieceMessage msg) { state.received(msg); } + /** + * Selects the card. + * + * @param card the card + */ @Override public void selectCard(BonusCard card) { state.selectCard(card); } + /** + * Selects the piece. + * + * @param piece the piece + */ @Override public void selectPiece(Piece piece) { state.selectPiece(piece); } + /** + * Returns the choose power card state. + */ public ChoosePowerCardState getChoosePowerCard() { return choosePowerCardState; } + /** + * Returns the shield state. + */ public ShieldState getShield() { return shieldState; } + /** + * Returns the swap state. + */ public SwapState getSwap() { return swapState; } + /** + * Returns the parent state. + */ public TurnState getParent() { return parent; } + /** + * Returns the state. + */ public PowerCardStates getState() { return state; } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/RollDiceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/RollDiceState.java index e756919e..92c32ecb 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/RollDiceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/RollDiceState.java @@ -17,27 +17,47 @@ public class RollDiceState extends TurnStates { private final TurnState parent; private boolean isRolled = false; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public RollDiceState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (TurnState) parent; } + /** + * Enters the state. + */ @Override public void enter() { isRolled = false; logic.addNotification(new DiceNowNotification()); } + /** + * Exits the state. + */ @Override public void exit() { logic.getGame().setDiceModifier(1); isRolled = false; } + /** + * Gets the parent state. + * + * @return the parent state + */ public TurnState getParent() { return parent; } + /** + * Selects the dice. + */ @Override public void selectDice() { if (!isRolled) { @@ -46,6 +66,11 @@ public void selectDice() { } } + /** + * Receives the die message. + * + * @param msg the die message + */ @Override public void received(DieMessage msg) { logic.getGame().setDiceEyes(msg.getDiceEye()); @@ -58,21 +83,39 @@ public void received(DieMessage msg) { } } + /** + * Selects the animation end. + */ @Override public void selectAnimationEnd() { logic.send(new AnimationEndMessage()); } + /** + * Receives the choose piece state message. + * + * @param msg the choose piece state message + */ @Override public void received(ChoosePieceStateMessage msg) { parent.setState(parent.getChoosePiece()); } + /** + * Receives the no turn message. + * + * @param msg the no turn message + */ @Override public void received(NoTurnMessage msg) { parent.getParent().setState(parent.getParent().getWaiting()); } + /** + * Receives the dice now message. + * + * @param msg the dice now message + */ @Override public void received(DiceNowMessage msg) { isRolled = false; diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/TurnStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/TurnStates.java index 8029e9e0..bb1f47eb 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/TurnStates.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/TurnStates.java @@ -5,6 +5,13 @@ import pp.mdga.client.gamestate.GameStates; public abstract class TurnStates extends GameStates { + + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public TurnStates(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/ChoosePieceStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/ChoosePieceStates.java index 0311ea35..fb01488f 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/ChoosePieceStates.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/ChoosePieceStates.java @@ -5,6 +5,13 @@ import pp.mdga.client.gamestate.turnstate.TurnStates; public abstract class ChoosePieceStates extends TurnStates { + + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public ChoosePieceStates(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/NoPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/NoPieceState.java index cf3860c0..f269adba 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/NoPieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/NoPieceState.java @@ -23,21 +23,36 @@ public class NoPieceState extends ChoosePieceStates { private final ChoosePieceState parent; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public NoPieceState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (ChoosePieceState) parent; } + /** + * Enters the state. + */ @Override public void enter() { LOGGER.log(System.Logger.Level.INFO, "Entering NoPieceState"); } + /** + * Exits the state. + */ @Override public void exit() { } + /** + * Selects the piece. + */ @Override public void received(SelectPieceMessage msg) { ArrayList pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)); @@ -48,6 +63,9 @@ public void received(SelectPieceMessage msg) { parent.setState(parent.getSelectPiece()); } + /** + * Selects the dice. + */ @Override public void received(WaitPieceMessage msg) { LOGGER.log(System.Logger.Level.INFO, "Received WaitPieceMessage"); @@ -56,6 +74,11 @@ public void received(WaitPieceMessage msg) { parent.setState(parent.getWaitingPiece()); } + /** + * This method is called when the server sends a DiceNowMessage. + * + * @param msg the DiceNowMessage + */ @Override public void received(StartPieceMessage msg) { Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()); @@ -71,12 +94,22 @@ public void received(StartPieceMessage msg) { parent.setState(parent.getStartPiece()); } + /** + * This method is called when the server sends a DiceNowMessage. + * + * @param msg the DiceNowMessage + */ @Override public void received(EndOfTurnMessage msg) { logic.getGame().setTurboFlag(false); parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting()); } + /** + * This method is called when the server sends a DiceNowMessage. + * + * @param msg the DiceNowMessage + */ @Override public void received(DiceNowMessage msg){ parent.getParent().setState(parent.getParent().getRollDice()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/SelectPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/SelectPieceState.java index d452da5d..59bd1b7c 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/SelectPieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/SelectPieceState.java @@ -18,25 +18,47 @@ public class SelectPieceState extends ChoosePieceStates { private ArrayList possiblePieces; private final System.Logger LOGGER = System.getLogger(this.getClass().getName()); + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public SelectPieceState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (ChoosePieceState) parent; } + /** + * Enters the state. + */ @Override public void enter() { } + /** + * Exits the state. + */ @Override public void exit() { possiblePieces = new ArrayList<>(); } + /** + * Sets the possible pieces. + * + * @param possiblePieces the possible pieces + */ public void setPossiblePieces(ArrayList possiblePieces) { this.possiblePieces = possiblePieces; } + /** + * Selects the piece. + * + * @param piece the piece + */ @Override public void selectPiece(Piece piece) { if (possiblePieces.contains(piece)) { @@ -44,6 +66,11 @@ public void selectPiece(Piece piece) { } } + /** + * This method is called when the server sends a MoveMessage. + * + * @param msg the MoveMessage + */ @Override public void received(MoveMessage msg) { Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/StartPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/StartPieceState.java index 1e60f45e..592bf8b9 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/StartPieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/StartPieceState.java @@ -17,26 +17,47 @@ public class StartPieceState extends ChoosePieceStates { private final ChoosePieceState parent; private Piece moveablePiece; - + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public StartPieceState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (ChoosePieceState) parent; } + /** + * Enters the state. + */ @Override public void enter() { } + /** + * Exits the state. + */ @Override public void exit() { moveablePiece = null; } + /** + * Sets the moveable piece. + * + * @param moveablePiece the moveable piece + */ public void setMoveablePiece(Piece moveablePiece) { this.moveablePiece = moveablePiece; } + /** + * Selects the piece. + * + * @param piece the piece + */ @Override public void selectPiece(Piece piece) { if (moveablePiece.equals(piece)) { @@ -44,6 +65,11 @@ public void selectPiece(Piece piece) { } } + /** + * Receives the move message. + * + * @param msg the move message + */ @Override public void received(MoveMessage msg) { Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/WaitingPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/WaitingPieceState.java index 80ec310c..40ab704a 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/WaitingPieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/choosepiecestate/WaitingPieceState.java @@ -17,25 +17,47 @@ public class WaitingPieceState extends ChoosePieceStates { private final ChoosePieceState parent; private Piece moveablePiece; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public WaitingPieceState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (ChoosePieceState) parent; } + /** + * Enters the state. + */ @Override public void enter() { moveablePiece = null; } + /** + * Exits the state. + */ @Override public void exit() { } + /** + * Sets the moveable piece. + * + * @param piece the moveable piece + */ @Override public void selectPiece(Piece piece) { logic.send(new RequestMoveMessage(piece)); } + /** + * Receives the move message. + * + * @param msg the move message + */ @Override public void received(MoveMessage msg) { Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/PowerCardStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/PowerCardStates.java index 53482531..d0e0cda9 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/PowerCardStates.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/PowerCardStates.java @@ -5,6 +5,13 @@ import pp.mdga.client.gamestate.turnstate.TurnStates; public abstract class PowerCardStates extends TurnStates { + + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public PowerCardStates(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/ShieldState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/ShieldState.java index f7df51eb..3348e63c 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/ShieldState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/ShieldState.java @@ -18,26 +18,48 @@ public class ShieldState extends PowerCardStates { private ArrayList possiblePieces; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public ShieldState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (PowerCardState) parent; possiblePieces = new ArrayList<>(); } + /** + * Enters the state. + */ @Override public void enter() { logic.addNotification(new SelectableShieldNotification(possiblePieces.stream().map(Piece::getUuid).toList())); } + /** + * Exits the state. + */ @Override public void exit() { possiblePieces = null; } + /** + * Sets the possible pieces. + * + * @param possiblePieces the possible pieces + */ public void setPossiblePieces(ArrayList possiblePieces) { this.possiblePieces = possiblePieces; } + /** + * Selects the piece. + * + * @param piece the piece + */ public void selectPiece(Piece piece) { if (possiblePieces.contains(piece)) { // logic.send(RequestPlayCardMessage.requestPlayShield(piece.getUuid())); @@ -49,7 +71,11 @@ public void selectPiece(Piece piece) { } } - + /** + * This method is called when the server sends a PlayCardMessage. + * + * @param msg the PlayCardMessage + */ @Override public void received(PlayCardMessage msg) { parent.getParent().getPlayPowerCard().setPlayCard(msg); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/SwapState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/SwapState.java index 6d6e40dc..d292c731 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/SwapState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gamestate/turnstate/powercardstate/SwapState.java @@ -22,6 +22,12 @@ public class SwapState extends PowerCardStates { private Piece selectedOwnPiece; private Piece selectedEnemyPiece; + /** + * Constructs a client state of the specified game logic. + * + * @param parent the parent state + * @param logic the client game logic + */ public SwapState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.parent = (PowerCardState) parent; @@ -31,6 +37,9 @@ public SwapState(ClientState parent, ClientGameLogic logic) { selectedEnemyPiece = null; } + /** + * Enters the state. + */ @Override public void enter() { LOGGER.log(System.Logger.Level.INFO, "Entering SwapState"); @@ -41,6 +50,9 @@ public void enter() { selectedEnemyPiece = null; } + /** + * Exits the state. + */ @Override public void exit() { LOGGER.log(System.Logger.Level.INFO, "Exiting SwapState"); @@ -48,14 +60,29 @@ public void exit() { possibleEnemyPieces.clear(); } + /** + * Sets the possible own pieces. + * + * @param possibleOwnPieces the possible own pieces + */ public void setPossibleOwnPieces(ArrayList possibleOwnPieces) { this.possibleOwnPieces = possibleOwnPieces; } + /** + * Sets the possible enemy pieces. + * + * @param possibleEnemyPieces the possible enemy pieces + */ public void setPossibleEnemyPieces(ArrayList possibleEnemyPieces) { this.possibleEnemyPieces = possibleEnemyPieces; } + /** + * Selects the piece. + * + * @param piece the piece + */ @Override public void selectPiece(Piece piece) { if (possibleOwnPieces.contains(piece)) { @@ -74,6 +101,11 @@ public void selectPiece(Piece piece) { } } + /** + * Receive a card + * + * @param msg card message + */ @Override public void received(PlayCardMessage msg) { parent.getParent().getPlayPowerCard().setPlayCard(msg);