Merge branch 'development2' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development2
This commit is contained in:
@@ -14,6 +14,11 @@ public class BonusNode extends Node {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return true if the node is a bonus node.
|
||||
*
|
||||
* @return true if the node is a bonus node.
|
||||
*/
|
||||
@Override
|
||||
public boolean isBonus() {
|
||||
return true;
|
||||
|
||||
@@ -50,27 +50,6 @@ public boolean isBonus() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method handles the event when a new occupant is moved to the node,
|
||||
* it then returns the old occupant.
|
||||
*
|
||||
* @param newOccupant the new occupant of the node
|
||||
* @return the old occupant of the node
|
||||
*/
|
||||
public Piece moveOccupant(Piece newOccupant) {
|
||||
throw new RuntimeException("BÖSE METHODE !!!!");
|
||||
|
||||
// if (occupant == null) {
|
||||
// setOccupant(newOccupant);
|
||||
// return null;
|
||||
// } else {
|
||||
// occupant.setShield(ShieldState.NONE);
|
||||
// occupant.setState(PieceState.WAITING);
|
||||
// setOccupant(newOccupant);
|
||||
// return occupant;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to clear the node of its occupant
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,11 @@ protected ClientMessage() {
|
||||
*/
|
||||
public abstract void accept(ClientInterpreter interpreter, int from);
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
*
|
||||
* @return a string representation of this object
|
||||
*/
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{}";
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ public AcquireCardNotification(BonusCard bonusCard) {
|
||||
this.bonusCard = bonusCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the bonusCard attribute of AcquireCardNotification class.
|
||||
*
|
||||
* @return bonusCard as a BonusCard object.
|
||||
*/
|
||||
public BonusCard getBonusCard() {
|
||||
return bonusCard;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,21 @@
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
public class FinishNotification extends Notification {
|
||||
private Color colorFinished;
|
||||
|
||||
private final Color colorFinished;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public FinishNotification(Color colorFinished) {
|
||||
this.colorFinished = colorFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the colorFinished attribute of FinishNotification class.
|
||||
*
|
||||
* @return colorFinished as a Color object.
|
||||
*/
|
||||
public Color getColorFinished() {
|
||||
return colorFinished;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ public GameNotification(Color ownColor) {
|
||||
this.ownColor = ownColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the ownColor attribute of GameNotification class.
|
||||
*
|
||||
* @return ownColor as a Color object.
|
||||
*/
|
||||
public Color getOwnColor() {
|
||||
return ownColor;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,20 @@ public InfoNotification(String info, boolean isError) {
|
||||
this.isError = isError;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the message attribute of InfoNotification class.
|
||||
*
|
||||
* @return message as a String object.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the isError attribute of InfoNotification class.
|
||||
*
|
||||
* @return isError as a boolean object.
|
||||
*/
|
||||
public boolean isError() {
|
||||
return isError;
|
||||
}
|
||||
|
||||
@@ -56,18 +56,30 @@ public MovePieceNotification(UUID piece, int startIndex, int moveIndex) {
|
||||
this.moveStart = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the destination node index
|
||||
*/
|
||||
public int getMoveIndex() {
|
||||
return moveIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the starting node index
|
||||
*/
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unique identifier of the piece
|
||||
*/
|
||||
public UUID getPiece() {
|
||||
return piece;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the piece is moving from the waiting area to the start node
|
||||
*/
|
||||
public boolean isMoveStart() {
|
||||
return moveStart;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,24 @@
|
||||
import java.util.UUID;
|
||||
|
||||
public class RemoveShieldNotification extends Notification {
|
||||
|
||||
/**
|
||||
* The UUID of the piece that has had its shield removed
|
||||
*/
|
||||
private final UUID pieceUuid;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pieceUuid the UUID of the piece that has had its shield removed
|
||||
*/
|
||||
public RemoveShieldNotification(UUID pieceUuid) {
|
||||
this.pieceUuid = pieceUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the UUID of the piece that has had its shield removed
|
||||
*/
|
||||
public UUID getPieceUuid() {
|
||||
return pieceUuid;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,13 @@ public RollDiceNotification(Color color, int eyes) {
|
||||
this.isRanking = false;
|
||||
}
|
||||
|
||||
//ranking
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param color the color of the player that rolled the die.
|
||||
* @param eyes the number of eyes that were rolled.
|
||||
* @param isRanking whether the roll is for ranking purposes.
|
||||
*/
|
||||
public RollDiceNotification(Color color, int eyes, boolean isRanking) {
|
||||
this.color = color;
|
||||
this.eyes = eyes;
|
||||
@@ -38,7 +44,13 @@ public RollDiceNotification(Color color, int eyes, boolean isRanking) {
|
||||
this.isRanking = isRanking;
|
||||
}
|
||||
|
||||
//turbo
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param color the color of the player that rolled the die.
|
||||
* @param eyes the number of eyes that were rolled.
|
||||
* @param multiplier the multiplier of the roll.
|
||||
*/
|
||||
public RollDiceNotification(Color color, int eyes, int multiplier) {
|
||||
this.color = color;
|
||||
this.eyes = eyes;
|
||||
@@ -65,14 +77,29 @@ public int getEyes() {
|
||||
return eyes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the multiplier of the roll.
|
||||
*
|
||||
* @return the multiplier of the roll.
|
||||
*/
|
||||
public int getMultiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the roll was a turbo roll.
|
||||
*
|
||||
* @return true if the roll was a turbo roll, false otherwise.
|
||||
*/
|
||||
public boolean isTurbo() {
|
||||
return turbo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the roll was for ranking purposes.
|
||||
*
|
||||
* @return true if the roll was for ranking purposes, false otherwise.
|
||||
*/
|
||||
public boolean isRanking() {
|
||||
return isRanking;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,26 @@
|
||||
import java.util.UUID;
|
||||
|
||||
public class SelectableShieldNotification extends Notification {
|
||||
private List<UUID> pieces;
|
||||
|
||||
/**
|
||||
* The list of piece IDs associated with the player.
|
||||
*/
|
||||
private final List<UUID> pieces;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pieces the list of piece IDs associated with the player.
|
||||
*/
|
||||
public SelectableShieldNotification(List<UUID> pieces) {
|
||||
this.pieces = pieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of piece IDs associated with the player.
|
||||
*
|
||||
* @return the list of piece IDs associated with the player.
|
||||
*/
|
||||
public List<UUID> getPieces() {
|
||||
return pieces;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
private static final Logger LOGGER = System.getLogger(ServerGameLogic.class.getName());
|
||||
|
||||
/**
|
||||
*
|
||||
* Attributes.
|
||||
*/
|
||||
private final ServerSender serverSender;
|
||||
private final Game game;
|
||||
@@ -47,91 +47,199 @@ public ServerGameLogic(ServerSender serverSender, Game game) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles the reception of an AnimationEndMessage.
|
||||
*
|
||||
* @param msg the received AnimationEndMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a DeselectTSKMessage.
|
||||
*
|
||||
* @param msg the received DeselectTSKMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(DeselectTSKMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a StartGameMessage.
|
||||
*
|
||||
* @param msg the received StartGameMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(StartGameMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a JoinedLobbyMessage.
|
||||
*
|
||||
* @param msg the received JoinedLobbyMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(JoinedLobbyMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a LeaveGameMessage.
|
||||
*
|
||||
* @param msg the received LeaveGameMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(LeaveGameMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a LobbyReadyMessage.
|
||||
*
|
||||
* @param msg the received LobbyReadyMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(LobbyReadyMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a LobbyNotReadyMessage.
|
||||
*
|
||||
* @param msg the received LobbyNotReadyMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(LobbyNotReadyMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a DisconnectedMessage.
|
||||
*
|
||||
* @param msg the received DisconnectedMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(DisconnectedMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a RequestBriefingMessage.
|
||||
*
|
||||
* @param msg the received RequestBriefingMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(RequestBriefingMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a RequestDieMessage.
|
||||
*
|
||||
* @param msg the received RequestDieMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(RequestDieMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a RequestMoveMessage.
|
||||
*
|
||||
* @param msg the received RequestMoveMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(RequestMoveMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a RequestPlayCardMessage.
|
||||
*
|
||||
* @param msg the received RequestPlayCardMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(RequestPlayCardMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a SelectCardMessage.
|
||||
*
|
||||
* @param msg the received SelectCardMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(SelectCardMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a SelectTSKMessage.
|
||||
*
|
||||
* @param msg the received SelectTSKMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(SelectTSKMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a ForceContinueGameMessage.
|
||||
*
|
||||
* @param msg the received ForceContinueGameMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(ForceContinueGameMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a ClientStartGameMessage.
|
||||
*
|
||||
* @param msg the received ClientStartGameMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(ClientStartGameMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a NoPowerCardMessage.
|
||||
*
|
||||
* @param msg the received NoPowerCardMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(NoPowerCardMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a SelectedPiecesMessage.
|
||||
*
|
||||
* @param msg the received SelectedPiecesMessage
|
||||
* @param from the sender of the message
|
||||
*/
|
||||
@Override
|
||||
public void received(SelectedPiecesMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
|
||||
@@ -85,19 +85,46 @@ public void received(LeaveGameMessage msg, int from) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an NoPowerCardMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a NoPowerCardMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(NoPowerCardMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectCardMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a SelectCardMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(SelectCardMessage msg, int from) {
|
||||
currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a RequestMoveMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a RequestMoveMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(RequestMoveMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectedPiecesMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a SelectedPiecesMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(SelectedPiecesMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
|
||||
@@ -31,11 +31,17 @@ public AnimationState(GameState gameAutomaton, ServerGameLogic logic) {
|
||||
super(gameAutomaton, logic);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be entered.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered AnimationState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be exited.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Exited AnimationState state.");
|
||||
|
||||
@@ -38,12 +38,18 @@ public DetermineStartPlayerState(GameState gameAutomaton, ServerGameLogic logic)
|
||||
super(gameAutomaton, logic);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be entered.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
LOGGER.log(System.Logger.Level.INFO, "Entered DetermineStartPlayerState state.");
|
||||
playerToStart = this.logic.getGame().getPlayers().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be exited.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
LOGGER.log(Level.INFO, "Exited DetermineStartPlayerState state.");
|
||||
|
||||
@@ -45,6 +45,9 @@ public TurnState(GameState gameAutomaton, ServerGameLogic logic) {
|
||||
this.movePieceState = new MovePieceState(this, logic);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be entered.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
LOGGER.log(Level.INFO, "Entered TurnState state.");
|
||||
@@ -55,6 +58,9 @@ public void enter() {
|
||||
this.setCurrentState(this.powerCardState);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be exited.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
LOGGER.log(Level.DEBUG, "Exited TurnState state.");
|
||||
@@ -108,11 +114,25 @@ public void received(RequestMoveMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a AnimationEndMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectCardMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a SelectCardMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(SelectCardMessage msg, int from) {
|
||||
currentState.received(msg, from);
|
||||
}
|
||||
|
||||
@@ -30,17 +30,31 @@ public MovePieceState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
super(turnAutomaton, logic);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be entered.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered MovePieceState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active player to the next player in the game.
|
||||
*
|
||||
* @param activePlayer the current active player color
|
||||
*/
|
||||
private void setActivePlayer(Color activePlayer) {
|
||||
Color newColor = activePlayer.next(logic.getGame());
|
||||
logic.getGame().setActiveColor(newColor);
|
||||
logic.getServerSender().broadcast(new ActivePlayerMessage(newColor));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the received AnimationEndMessage.
|
||||
*
|
||||
* @param msg the received AnimationEndMessage
|
||||
* @param from the ID of the player who sent the message
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
finishedAnimations.add(logic.getGame().getPlayerById(from));
|
||||
@@ -55,10 +69,12 @@ public void received(AnimationEndMessage msg, int from) {
|
||||
return;
|
||||
}
|
||||
this.turnAutomaton.getGameAutomaton().setCurrentState(this.turnAutomaton.getGameAutomaton().getTurnState());
|
||||
} else if (logic.getGame().getDiceEyes() == 6) {
|
||||
}
|
||||
else if (logic.getGame().getDiceEyes() == 6) {
|
||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(logic.getGame().getActiveColor()), new DiceNowMessage());
|
||||
this.turnAutomaton.setCurrentState(this.turnAutomaton.getRollDiceState());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(logic.getGame().getActiveColor()), new EndOfTurnMessage());
|
||||
setActivePlayer(logic.getGame().getActiveColor());
|
||||
this.turnAutomaton.getGameAutomaton().setCurrentState(this.turnAutomaton.getGameAutomaton().getTurnState());
|
||||
@@ -66,6 +82,9 @@ public void received(AnimationEndMessage msg, int from) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be exited.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
finishedAnimations.clear();
|
||||
|
||||
@@ -17,7 +17,7 @@ public class PlayPowerCardState extends TurnAutomatonState {
|
||||
/**
|
||||
* Create PlayPowerCardState attributes.
|
||||
*/
|
||||
private Set<Integer> messageReceived = new HashSet<Integer>();
|
||||
private final Set<Integer> messageReceived = new HashSet<Integer>();
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
@@ -29,13 +29,20 @@ public PlayPowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
super(turnAutomaton, logic);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be entered.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered PlayPowerCardState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be exited.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
messageReceived.clear();
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Exited PlayPowerCardState state.");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,13 @@ public PowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enters the PowerCardState state.
|
||||
* Clears the checked cards, logs the entry, sets the current state to choosePowerCardState,
|
||||
* initializes the visitor, and processes the player's hand cards.
|
||||
* If no cards are available, sends a DiceNowMessage and transitions to RollDiceState.
|
||||
* Otherwise, sends a PossibleCardsMessage with the available cards.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
chekedCards.clear();
|
||||
@@ -75,11 +82,22 @@ public void enter() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits the PowerCardState state.
|
||||
* Logs the exit.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Exit PowerCardState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the received NoPowerCardMessage.
|
||||
* Delegates the message handling to the current state's received method.
|
||||
*
|
||||
* @param msg the NoPowerCardMessage received
|
||||
* @param form the client id of the player who sent the message
|
||||
*/
|
||||
@Override
|
||||
public void received(NoPowerCardMessage msg, int form) {
|
||||
currentState.received(msg, form);
|
||||
|
||||
@@ -64,6 +64,13 @@ public void received(RequestDieMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a AnimationEndMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
|
||||
@@ -88,6 +88,12 @@ public void received(SelectedPiecesMessage msg, int from) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will swap the pieces of the given messageOwn and messageEnemy.
|
||||
*
|
||||
* @param messageOwn as the own piece as a Piece object.
|
||||
* @param messageEnemy as the enemy piece as a Piece object.
|
||||
*/
|
||||
private void swapPieces(Piece messageOwn, Piece messageEnemy) {
|
||||
//swap Pieces in Model
|
||||
Board board = logic.getGame().getBoard();
|
||||
|
||||
@@ -39,16 +39,4 @@ public void enter() {
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectedPiecesMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a SelectedPiecesMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(SelectedPiecesMessage msg, int from) {
|
||||
// ToDo: We can use this method to catch irregular client messages.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ public void enter() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be exited.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
LOGGER.log(System.Logger.Level.INFO, "Exited FirstRollState state.");
|
||||
@@ -69,6 +72,13 @@ public void received(RequestDieMessage msg, int from) {
|
||||
isDied = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a AnimationEndMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
if (from != this.logic.getGame().getActivePlayerId()) {
|
||||
|
||||
@@ -25,12 +25,18 @@ public SecondRollState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
|
||||
super(rollDiceAutomaton, logic);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be entered.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered SecondRollState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be exited.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Exited SecondRollState state.");
|
||||
@@ -54,6 +60,13 @@ public void received(RequestDieMessage msg, int from) {
|
||||
this.logic.getServerSender().broadcast(new DieMessage(roll));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a AnimationEndMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
if (from != this.logic.getGame().getActivePlayerId()) {
|
||||
|
||||
@@ -23,12 +23,18 @@ public ThirdRollState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
|
||||
super(rollDiceAutomaton, logic);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be entered.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Exited ThirdRollState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used whenever this state will be exited.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered ThirdRollState state.");
|
||||
@@ -52,6 +58,13 @@ public void received(RequestDieMessage msg, int from) {
|
||||
this.logic.getServerSender().broadcast(new DieMessage(roll));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a AnimationEndMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
if (from != this.logic.getGame().getActivePlayerId()) {
|
||||
|
||||
Reference in New Issue
Block a user