Merge commit

This commit is contained in:
Felix Koppe
2024-12-01 23:12:46 +01:00
22 changed files with 337 additions and 29 deletions

View File

@@ -33,6 +33,6 @@ public void enter() {
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited CeremonyState state.");
}
}

View File

@@ -55,7 +55,7 @@ public void enter() {
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited GameState state.");
}
/**

View File

@@ -41,7 +41,7 @@ public void enter() {
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited InterruptState state.");
}
/**

View File

@@ -40,7 +40,7 @@ public void enter() {
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited LobbyState state.");
}
/**
@@ -55,7 +55,9 @@ public void received(JoinedLobbyMessage msg, int from) {
Player player = new Player(msg.getName());
player.setColor(Color.getColorByIndex(this.logic.getGame().getPlayers().size()));
this.logic.getGame().addPlayer(from, player);
this.logic.getServerSender().broadcast(new LobbyPlayerJoinedMessage(from, player));
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
this.logic.getServerSender().broadcast(new LobbyPlayerJoinedMessage(entry.getKey(), entry.getValue()));
}
}
/**

View File

@@ -10,6 +10,11 @@
*
*/
public class AnimationState extends GameAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(AnimationState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
@@ -22,12 +27,12 @@ public AnimationState(GameState gameAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered AnimationState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited AnimationState state.");
}
/**

View File

@@ -5,6 +5,7 @@
import pp.mdga.message.server.DieMessage;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.GameState;
import pp.mdga.server.automaton.game.turn.RollDiceState;
import java.util.HashMap;
import java.util.Map;
@@ -12,6 +13,11 @@
import java.util.stream.Collectors;
public class DetermineStartPlayerState extends GameAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(DetermineStartPlayerState.class.getName());
/**
* Create DetermineStartPlayerState attributes.
*/
@@ -29,12 +35,12 @@ public DetermineStartPlayerState(GameState gameAutomaton, ServerGameLogic logic)
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered DetermineStartPlayerState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited DetermineStartPlayerState state.");
}
/**

View File

@@ -9,6 +9,10 @@
* It will also be used as the turn automaton.
*/
public class TurnState extends GameAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(TurnState.class.getName());
/**
* Create TurnState states.
*/
@@ -36,12 +40,12 @@ public TurnState(GameState gameAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered TurnState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited TurnState state.");
}
/**

View File

@@ -4,6 +4,11 @@
import pp.mdga.server.automaton.game.TurnState;
public class ChoosePieceState extends TurnAutomatonState {
/**
* Create LobbyState constants.
*/
private static final System.Logger LOGGER = System.getLogger(ChoosePieceState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
@@ -16,11 +21,11 @@ public ChoosePieceState(TurnState turnAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited ChoosePieceState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered ChoosePieceState state.");
}
}

View File

@@ -4,6 +4,10 @@
import pp.mdga.server.automaton.game.TurnState;
public class MovePieceState extends TurnAutomatonState {
/**
* Create LobbyState constants.
*/
private static final System.Logger LOGGER = System.getLogger(MovePieceState.class.getName());
/**
* Constructs a server state of the specified game logic.
@@ -17,11 +21,11 @@ public MovePieceState(TurnState turnAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered MovePieceState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited MovePieceState state.");
}
}

View File

@@ -1,9 +1,15 @@
package pp.mdga.server.automaton.game.turn;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.AnimationState;
import pp.mdga.server.automaton.game.TurnState;
public class PlayPowerCardState extends TurnAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(PlayPowerCardState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
@@ -16,11 +22,11 @@ public PlayPowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered PlayPowerCardState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited PlayPowerCardState state.");
}
}

View File

@@ -1,9 +1,15 @@
package pp.mdga.server.automaton.game.turn;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.AnimationState;
import pp.mdga.server.automaton.game.TurnState;
public class PowerCardState extends TurnAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(PowerCardState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
@@ -16,11 +22,11 @@ public PowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited PowerCardState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered PowerCardState state.");
}
}

View File

@@ -2,8 +2,25 @@
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.TurnState;
import pp.mdga.server.automaton.game.turn.rolldice.FirstRollState;
import pp.mdga.server.automaton.game.turn.rolldice.RollDiceAutomatonState;
import pp.mdga.server.automaton.game.turn.rolldice.SecondRollState;
import pp.mdga.server.automaton.game.turn.rolldice.ThirdRollState;
public class RollDiceState extends TurnAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(RollDiceState.class.getName());
/**
* Create RollDiceState attributes.
*/
private RollDiceAutomatonState currentState;
private final FirstRollState firstRollState;
private final SecondRollState secondRollState;
private final ThirdRollState thirdRollState;
/**
* Constructs a server state of the specified game logic.
*
@@ -12,15 +29,68 @@ public class RollDiceState extends TurnAutomatonState {
*/
public RollDiceState(TurnState turnAutomaton, ServerGameLogic logic) {
super(turnAutomaton, logic);
this.firstRollState = new FirstRollState(this, logic);
this.secondRollState = new SecondRollState(this, logic);
this.thirdRollState = new ThirdRollState(this, logic);
}
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered RollDiceState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited RollDiceState state.");
}
/**
* This method will be used to return currentState attribute of RollDiceState class.
*
* @return currentState as a RollDiceAutomatonState object.
*/
public RollDiceAutomatonState getCurrentState() {
return this.currentState;
}
/**
* This method will be used to return firstRollState attribute of RollDiceState class.
*
* @return firstRollState as a FirstRollState object.
*/
public FirstRollState getFirstRollStateState() {
return this.firstRollState;
}
/**
* This method will be used to return secondRollState attribute of RollDiceState class.
*
* @return secondRollState as a SecondRollState object.
*/
public SecondRollState getSecondRollState() {
return this.secondRollState;
}
/**
* This method will be used to return currentState attribute of RollDiceState class.
*
* @return thirdRollState as a ThirdRollState object.
*/
public ThirdRollState getThirdRollState() {
return this.thirdRollState;
}
/**
* This method will be used to set currentState attribute of RollDiceState 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 RollDiceAutomatonState object.
*/
public void setCurrentState(RollDiceAutomatonState state) {
if (this.currentState != null) {
this.currentState.exit();
}
this.currentState = state;
this.currentState.enter();
}
}

View File

@@ -13,6 +13,7 @@ public abstract class ChoosePieceAutomatonState extends ServerState {
/**
* Constructs a server state of the specified game logic.
*
* @param choosePieceAutomaton as the automaton of the choose piece state as a ChoosePieceState object.
* @param logic the game logic
*/
public ChoosePieceAutomatonState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {

View File

@@ -3,5 +3,35 @@
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
public class NoPieceState {
public class NoPieceState extends ChoosePieceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(NoPieceState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param choosePieceAutomaton as the automaton of the choose piece state as a ChoosePieceState object.
* @param logic the game logic
*/
public NoPieceState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {
super(choosePieceAutomaton, logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered NoPieceState state.");
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited NoPieceState state.");
}
}

View File

@@ -3,5 +3,35 @@
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
public class NoTurnState {
public class NoTurnState extends ChoosePieceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(NoTurnState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param choosePieceAutomaton as the automaton of the choose piece state as a ChoosePieceState object.
* @param logic the game logic
*/
public NoTurnState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {
super(choosePieceAutomaton, logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered NoTurnState state.");
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited NoTurnState state.");
}
}

View File

@@ -3,6 +3,35 @@
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
public class SelectPieceState {
public class SelectPieceState extends ChoosePieceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(SelectPieceState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param choosePieceAutomaton as the automaton of the choose piece state as a ChoosePieceState object.
* @param logic the game logic
*/
public SelectPieceState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {
super(choosePieceAutomaton, logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered SelectPieceState state.");
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited SelectPieceState state.");
}
}

View File

@@ -3,5 +3,35 @@
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
public class StartPieceState {
public class StartPieceState extends ChoosePieceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(StartPieceState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param choosePieceAutomaton as the automaton of the choose piece state as a ChoosePieceState object.
* @param logic the game logic
*/
public StartPieceState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {
super(choosePieceAutomaton, logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited StartPieceState state.");
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered StartPieceState state.");
}
}

View File

@@ -2,6 +2,37 @@
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
import pp.mdga.server.automaton.game.turn.rolldice.FirstRollState;
public class WaitingPieceState {
public class WaitingPieceState extends ChoosePieceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(WaitingPieceState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param choosePieceAutomaton as the automaton of the choose piece state as a ChoosePieceState object.
* @param logic the game logic
*/
public WaitingPieceState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {
super(choosePieceAutomaton, logic);
}
/**
* This method will be used whenever this state will be entered.
*/
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered WaitingPieceState state.");
}
/**
* This method will be used whenever this state will be exited.
*/
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited WaitingPieceState state.");
}
}

View File

@@ -26,6 +26,6 @@ public void enter() {
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited FirstRollStatte state.");
LOGGER.log(System.Logger.Level.DEBUG, "Exited FirstRollState state.");
}
}

View File

@@ -13,7 +13,8 @@ public abstract class RollDiceAutomatonState extends ServerState {
/**
* Constructs a server state of the specified game logic.
*
* @param logic the game logic
* @param rollDiceAutomaton as the automaton of the roll dice state as a RollDiceState object.
* @param logic the game logic
*/
public RollDiceAutomatonState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
super(logic);

View File

@@ -3,5 +3,29 @@
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.RollDiceState;
public class SecondRollState {
public class SecondRollState extends RollDiceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(SecondRollState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param rollDiceAutomaton as the automaton of the roll dice state as a RollDiceState object.
* @param logic the game logic
*/
public SecondRollState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
super(rollDiceAutomaton, logic);
}
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered SecondRollState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited SecondRollState state.");
}
}

View File

@@ -3,5 +3,29 @@
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.RollDiceState;
public class ThirdRollState {
public class ThirdRollState extends RollDiceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(ThirdRollState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param rollDiceAutomaton as the automaton of the roll dice state as a RollDiceState object.
* @param logic the game logic
*/
public ThirdRollState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
super(rollDiceAutomaton, logic);
}
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited ThirdRollState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered ThirdRollState state.");
}
}