From 33dbbdbe5ce5bdd669b8b76cf647c03af72ec35f Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Thu, 14 Nov 2024 18:07:36 +0100 Subject: [PATCH 01/44] initial test commit, added all testclasses except Playertest, Viewtest, Cameratest, SettingsTest, SoundTest, ReactionTest and ClientStateTest. And filled all created testclasses with empty testmethods, except ServerStateTest. --- .../test/java/pp/mdga/client/ClientTest.java | 44 ++++++ .../java/pp/mdga/client/Dialog/LobbyTest.java | 88 +++++++++++ .../Dialog/NetworkDialogClientTest.java | 45 ++++++ .../client/Dialog/NetworkDialogHostTest.java | 35 +++++ .../mdga/client/Dialog/StartDialogTest.java | 39 +++++ .../client/clientState/SettingsStateTest.java | 64 ++++++++ .../src/test/java/pp/mdga/game/GameTest.java | 106 +++++++++++++ .../src/test/java/pp/mdga/game/PieceTest.java | 147 ++++++++++++++++++ .../test/java/pp/mdga/server/ServerTest.java | 49 ++++++ .../server/serverState/ServerStateTest.java | 4 + 10 files changed, 621 insertions(+) create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/ClientTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogClientTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogHostTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/StartDialogTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/server/ServerTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/ClientTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/ClientTest.java new file mode 100644 index 00000000..b9dfba4c --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/ClientTest.java @@ -0,0 +1,44 @@ +package pp.mdga.client; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T066-T071 + */ +public class ClientTest { + @Before + public void Setup() { + + } + + @Test + public void testClientTerminatesConnection() { + + } + + @Test + public void testClientConnects() { + + } + + @Test + public void testClientCantConnect() { + + } + + @Test + public void testClientReconnect() { + + } + + @Test + public void testClientDoesntReconnect() { + + } + + @Test + public void testClientDisconnects() { + + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyTest.java new file mode 100644 index 00000000..fba98391 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyTest.java @@ -0,0 +1,88 @@ +package pp.mdga.client.Dialog; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T084-T095 + */ +public class LobbyTest { + + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Lobby actions. + } + + // UC-Lobby-01 + @Test + public void testSelectTSK() { + // TODO: Implement test logic for selecting a task (TSK) + } + + // UC-Lobby-02 + @Test + public void testDeselectTSK() { + // TODO: Implement test logic for deselecting a previously selected task (TSK) + } + + // UC-Lobby-03 + @Test + public void testChangeTSK() { + // TODO: Implement test logic for changing a selected task (TSK) + } + + // UC-Lobby-04 + @Test + public void testReady() { + // TODO: Implement test logic for setting the player status to "ready" + } + + // UC-Lobby-05 + @Test + public void testNotReady() { + // TODO: Implement test logic for setting the player status to "not ready" + } + + // UC-Lobby-06 + @Test + public void testLeaveLobby() { + // TODO: Implement test logic for a player leaving the lobby + } + + // UC-Lobby-07 + @Test + public void testStartGame() { + // TODO: Implement test logic for starting the game + } + + // UC-Lobby-08 + @Test + public void testShowStatus() { + // TODO: Implement test logic for showing the status of all players (ready/not ready) + } + + // UC-Lobby-09 + @Test + public void testShowNames() { + // TODO: Implement test logic for showing the names of all players in the lobby + } + + // UC-Lobby-10 + @Test + public void testShowAvailableTSKs() { + // TODO: Implement test logic for displaying the list of available tasks (TSKs) + } + + // UC-Lobby-11 + @Test + public void testShowAssignedTSKs() { + // TODO: Implement test logic for showing the tasks assigned to players + } + + // UC-Lobby-12 + @Test + public void testServerAssignsTSK() { + // TODO: Implement test logic for server-side assignment of tasks (TSKs) to players + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogClientTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogClientTest.java new file mode 100644 index 00000000..53e42e3c --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogClientTest.java @@ -0,0 +1,45 @@ +package pp.mdga.client.Dialog; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T079-T083 + */ +public class NetworkDialogClientTest { + + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Network Dialog Client actions. + } + + // UC-NetworkDialogClient-01 + @Test + public void testEnterIP() { + // TODO: Implement test logic for entering an IP address + } + + // UC-NetworkDialogClient-02 + @Test + public void testEnterPort() { + // TODO: Implement test logic for entering a port number + } + + // UC-NetworkDialogClient-03 + @Test + public void testConnectToServer() { + // TODO: Implement test logic for attempting to connect to a server + } + + @Test + public void testCantConnectToServer() { + // TODO: Implement test logic for handling failed server connection attempts + } + + // UC-NetworkDialogClient-04 + @Test + public void testCancelJoining() { + // TODO: Implement test logic for canceling the joining process + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogHostTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogHostTest.java new file mode 100644 index 00000000..71b7198d --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogHostTest.java @@ -0,0 +1,35 @@ +package pp.mdga.client.Dialog; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T076-T078 + */ +public class NetworkDialogHostTest { + + @Before + public void setUp() { + // This method will be executed before each test. + } + + // UC-NetworkDialogHost-01 + @Test + public void testSpecifyPort() { + // TODO: Implement test logic for specifying a port + } + + // UC-NetworkDialogHost-02 + @Test + public void testCreateServer() { + // TODO: Implement test logic for creating a server + // Example: Check that the server is created successfully and starts listening on the specified port. + } + + // UC-NetworkDialogHost-03 + @Test + public void testCancelServer() { + // TODO: Implement test logic for canceling server creation + // Example: Verify that the server creation process is canceled properly without starting a server. + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/StartDialogTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/StartDialogTest.java new file mode 100644 index 00000000..f1d88ac3 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/StartDialogTest.java @@ -0,0 +1,39 @@ +package pp.mdga.client.Dialog; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T072-T075 + */ +public class StartDialogTest { + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Start Dialog actions. + } + + // UC-StartDialog-01 + @Test + public void testEnterName() { + // TODO: Implement test logic for entering a player name + } + + // UC-StartDialog-02 + @Test + public void testJoinServer() { + // TODO: Implement test logic for joining a game server + } + + // UC-StartDialog-03 + @Test + public void testHostServer() { + // TODO: Implement test logic for hosting a server + } + + // UC-StartDialog-04 + @Test + public void testExitGame() { + // TODO: Implement test logic for exiting the game + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java new file mode 100644 index 00000000..43444c3f --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java @@ -0,0 +1,64 @@ +package pp.mdga.client.clientState; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T232-T239 + */ +public class SettingsStateTest { + + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Client State transitions. + } + + // UC-ClientState-63 + @Test + public void testMainSettingsToVideoSettings() { + // TODO: Implement test logic for transitioning from Main Settings to Video Settings + } + + // UC-ClientState-64 + @Test + public void testMainSettingsToAudioSettings() { + // TODO: Implement test logic for transitioning from Main Settings to Audio Settings + } + + // UC-ClientState-65 + @Test + public void testMainSettingsToClientState() { + // TODO: Implement test logic for transitioning from Main Settings to a generic Client State + } + + // UC-ClientState-66 + @Test + public void testStayInVideoSettings() { + // TODO: Implement test logic for staying in Video Settings + } + + // UC-ClientState-67 + @Test + public void testVideoSettingsToMainSettings() { + // TODO: Implement test logic for transitioning from Video Settings to Main Settings + } + + // UC-ClientState-68 + @Test + public void testStayInAudioSettings() { + // TODO: Implement test logic for staying in Audio Settings + } + + // UC-ClientState-69 + @Test + public void testAudioSettingsToMainSettings() { + // TODO: Implement test logic for transitioning from Audio Settings to Main Settings + } + + // UC-ClientState-70 + @Test + public void testClientStateSubStatesToMainSettings() { + // TODO: Implement test logic for transitioning from any sub-state of the client to Main Settings + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java new file mode 100644 index 00000000..225e0db2 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java @@ -0,0 +1,106 @@ +package pp.mdga.game; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T001-T016 + */ +public class GameTest { + + @Before + public void setup() { + + } + + @Test + public void testStartLineUp() { + // TODO: Implement test logic for starting line-up + } + + @Test + public void testCreatePowerCardDeck() { + // TODO: Implement test logic for creating power card deck + } + + // UC-Game-02 + @Test + public void testGameFinishes() { + // TODO: Implement test logic for game finishes + } + + // UC-Game-03 + @Test + public void testPlayerFinishes() { + // TODO: Implement test logic for player finishes + } + + // UC-Game-04 + @Test + public void testAllPiecesInWaitingArea() { + // TODO: Implement test logic for checking if all pieces are in the waiting area + } + + @Test + public void test3TriesFor6() { + // TODO: Implement test logic for checking 3 tries for rolling a 6 + } + + // UC-Game-05 + @Test + public void testGameTerminates() { + // TODO: Implement test logic for game termination + } + + // UC-Game-06 + @Test + public void testStartingOrder() { + // TODO: Implement test logic for verifying starting order of players + } + + // UC-Game-07 + @Test + public void testDouble() { + // TODO: Implement test logic for testing the double rule + } + + // UC-Game-08 + @Test + public void testChangeActivePlayer() { + // TODO: Implement test logic for changing the active player + } + + // UC-Game-09 + @Test + public void testUseTurbo() { + // TODO: Implement test logic for using a turbo power-up + } + + @Test + public void testMuliplicationChance() { + // TODO: Implement test logic for testing multiplication chance power-up + } + + // UC-Game-10 + @Test + public void testTurboOn6() { + // TODO: Implement test logic for turbo activation on rolling a 6 + } + + // UC-Game-11 + @Test + public void testAwardCeremony() { + // TODO: Implement test logic for award ceremony + } + + @Test + public void testStatistics() { + // TODO: Implement test logic for gathering or displaying game statistics + } + + // UC-Game-12 + @Test + public void testRefillPowerCardDeck() { + // TODO: Implement test logic for refilling the power card deck + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java new file mode 100644 index 00000000..30c770c1 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java @@ -0,0 +1,147 @@ +package pp.mdga.game; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T035-T058 + */ +public class PieceTest { + + @Before + public void Setup() { + + } + + // UC-Piece-01 + @Test + public void testMove() { + // TODO: Implement test logic for moving a piece + } + + // UC-Piece-02 + @Test + public void testCantMove() { + // TODO: Implement test logic for when a piece can't move + } + + // UC-Piece-03 + @Test + public void testNoPossibleMove() { + // TODO: Implement test logic for when no possible moves are available + } + + @Test + public void testThrow() { + // TODO: Implement test logic for throwing a piece off the board + } + + // UC-Piece-04 + @Test + public void testGetThrown() { + // TODO: Implement test logic for when a piece gets thrown + } + + // UC-Piece-05 + @Test + public void testLeaveWaitingArea() { + // TODO: Implement test logic for a piece leaving the waiting area + } + + // UC-Piece-06 + @Test + public void testMustLeaveStartingField() { + // TODO: Implement test logic for a piece that must leave the starting field + } + + // UC-Piece-07 + @Test + public void testDontHaveToLeaveStartingField() { + // TODO: Implement test logic for when a piece doesn't have to leave the starting field + } + + // UC-Piece-08 + @Test + public void testCantLeaveStartingField() { + // TODO: Implement test logic for when a piece can't leave the starting field + } + + // UC-Piece-09 + @Test + public void testReachBonusField() { + // TODO: Implement test logic for when a piece reaches a bonus field + } + + @Test + public void testNoPowerCards() { + // TODO: Implement test logic for when there are no power cards available + } + + @Test + public void testShufflePile() { + // TODO: Implement test logic for shuffling the pile of power cards + } + + // UC-Piece-10 + @Test + public void testEnterHouse() { + // TODO: Implement test logic for entering the house area + } + + @Test + public void testOnlyEnterOwnHouse() { + // TODO: Implement test logic to ensure a piece can only enter its own house + } + + // UC-Piece-11 + @Test + public void testActiveHomePiece() { + // TODO: Implement test logic for activating a piece in the home area + } + + @Test + public void testCantJumpOverFigureInHouse() { + // TODO: Implement test logic to prevent jumping over another piece in the house + } + + // UC-Piece-12 + @Test + public void testActiveHomePieceBlocked() { + // TODO: Implement test logic for when an active home piece is blocked + } + + @Test + public void testOnStartingFieldWithShield() { + // TODO: Implement test logic for a piece on the starting field with a shield + } + + // UC-Piece-13 + @Test + public void testThrowFigureWithShield() { + // TODO: Implement test logic for attempting to throw a figure with a shield + } + + // UC-Piece-14 + @Test + public void testUseSwap() { + // TODO: Implement test logic for using a swap power-up + } + + // UC-Piece-15 + @Test + public void testUseShield() { + // TODO: Implement test logic for using a shield power-up + } + + // UC-Piece-16 + @Test + public void testLoseShield() { + // TODO: Implement test logic for when a piece loses its shield + } + + // UC-Piece-17 + @Test + public void testFinishedPiece() { + // TODO: Implement test logic for a piece that has finished the game + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/ServerTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/ServerTest.java new file mode 100644 index 00000000..52a04bc3 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/ServerTest.java @@ -0,0 +1,49 @@ +package pp.mdga.server; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T059-T065 + */ +public class ServerTest { + @Before + public void Setup() { + + } + + @Test + public void testServerStart() { + + } + + @Test + public void testServerDoesntStart() { + + } + + @Test + public void testAcceptRequest() { + + } + + @Test + public void testTerminateServer() { + + } + + @Test + public void testServerEndsGame() { + + } + + @Test + public void testDeclineConnection() { + + } + + @Test + public void testDeclineRequest() { + + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java new file mode 100644 index 00000000..53e9af8d --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -0,0 +1,4 @@ +package pp.mdga.server.serverState; + +public class ServerStateTest { +} From 90fb6e4133f2bd8ed765826b919634a72772bb12 Mon Sep 17 00:00:00 2001 From: Hanno Fleischer Date: Sun, 17 Nov 2024 17:52:25 +0100 Subject: [PATCH 02/44] added the method tryMove and the methods used by it into serverstate --- .../src/main/java/pp.mdga/game/Board.java | 9 ++ .../src/main/java/pp.mdga/game/Piece.java | 11 +- .../main/java/pp.mdga/game/PlayerData.java | 28 ++++ .../main/java/pp.mdga/server/ServerState.java | 127 ++++++++++++++++++ 4 files changed, 174 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Board.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Board.java index 05d4f84f..82554248 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Board.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Board.java @@ -57,4 +57,13 @@ public Node[] getInfield() { public void setPieceOnBoard(int index, Piece piece) { infield[index].setOccupant(piece); } + + public int getInfieldIndexOfPiece(Piece piece) { + for (int i = 0; i < infield.length; i++) { + if (infield[i].getOccupant() == piece) { + return i; + } + } + return -1; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java index e68f3d26..aef3f73f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java @@ -6,7 +6,7 @@ public class Piece { private ShieldState shield; private PieceState state; - private Color color; + private final Color color; /** * This constructor is used to create a new Piece @@ -73,4 +73,13 @@ public boolean isShielded() { public boolean isSuppressed() { return shield == ShieldState.SUPPRESSED; } + + /** + * This method is used to get the color of the piece + * + * @return the color of the piece + */ + public Color getColor() { + return color; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java index eac80356..b82893aa 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java @@ -108,4 +108,32 @@ public Piece removePieceFromWaitingArea() { public void setPieceInHome(int index, Piece piece) { homeNodes[index].setOccupant(piece); } + + /** + * This method returns the homeNodes + * + * @return the homeNodes + */ + public boolean homeIncludes(Piece piece) { + for (int i = 0; i < 4; i++) { + if (homeNodes[i].getOccupant() == piece) { + return true; + } + } + return false; + } + + /** + * This method returns the homeNodes + * + * @return the homeNodes + */ + public int getIndexInHome(Piece piece) { + for (int i = 0; i < 4; i++) { + if (homeNodes[i].getOccupant() == piece) { + return i; + } + } + return -1; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java index ee022302..56ed1be3 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java @@ -1,9 +1,16 @@ package pp.mdga.server; +import pp.mdga.game.Color; +import pp.mdga.game.Node; import pp.mdga.game.Piece; +import pp.mdga.game.PieceState; +import pp.mdga.game.PlayerData; import pp.mdga.message.client.*; import pp.mdga.message.server.PossibleCard; import java.lang.System.Logger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public abstract class ServerState implements Observer { protected static final Logger LOGGER = System.getLogger(ServerState.class.getName()); @@ -58,6 +65,126 @@ public ServerState getParent() { public void update() { /* do nothing */ } + /** + * This method is used to calculate the steps a piece can move + * + * @return the steps a piece can move + */ + private int calculateSteps(){ + return logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier(); + } + + /** + * This method is used to test if u can move a piece + * + * @param piece the piece to be moved + * @return true if the piece can be moved, false otherwise + */ + protected boolean tryMove(Piece piece) { + if (piece.getState() == PieceState.HOME){ + return tryHomeMove(piece, calculateSteps()); + } else { + int homeMoves = getHomeMoves(piece, calculateSteps()); + if (homeMoves > 0){ + return tryHomeMove(piece, homeMoves); + } else { + return tryInfieldMove(piece, calculateSteps()); + } + } + } + + /** + * This method is used to determine if a piece would move into the home area. + * + * @param piece the piece to be moved + * @param steps the steps the piece would move + * @return the number of steps the piece would move into the home area + */ + protected int getHomeMoves(Piece piece, int steps) { + int figureIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); + Color col = piece.getColor(); + int startIndex = logic.getGame().getBoard().getPlayerData().get(col).getStartNodeIndex(); + int moveIndex = startIndex + steps; + if (moveIndex > logic.getGame().getBoard().getInfield().length){ + moveIndex %= logic.getGame().getBoard().getInfield().length; + if(moveIndex >= startIndex){ + return moveIndex - startIndex + 1; + } + } else if (figureIndex < startIndex && moveIndex >= startIndex){ + return moveIndex - startIndex + 1; + } + return 0; + } + + /** + * This method is used to determine if a piece can move in the infield + * + * @param piece the piece to be moved + * @param steps the steps the piece would move + * @return true if the piece can move in the infield, false otherwise + */ + protected boolean tryInfieldMove(Piece piece, int steps){ + int figureIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); + int moveIndex = (figureIndex + steps) % logic.getGame().getBoard().getInfield().length; + Piece occupant = logic.getGame().getBoard().getInfield()[moveIndex].getOccupant(); + if(occupant != null){ + return occupant.getColor() != piece.getColor(); + } + return true; + } + + /** + * This method is used to determine if a piece can move inside the home area + * + * @param piece the piece to be moved + * @param steps the steps the piece would move + * @return true if the piece can move into the home area, false otherwise + */ + protected boolean tryHomeMove(Piece piece, int steps){ + Color col = piece.getColor(); + PlayerData playerData = logic.getGame().getBoard().getPlayerData().get(col); + Node[] homeNodes = playerData.getHomeNodes(); + int index; + + if (playerData.homeIncludes(piece)){ + index = playerData.getIndexInHome(piece); + } else { + index = 0; + } + if(index + steps >= homeNodes.length){ + return false; + } else { + for(int i = index; i <= index + steps; i++){ + if(homeNodes[i].getOccupant() != null){ + return false; + } + } + return true; + } + } + + /** + * This method is used to get the pieces that can be moved + * + * @param color the color of the pieces + * @return the pieces that can be moved + */ + protected List getMoveablePieces(Color color) { + ArrayList moveablePieces = new ArrayList<>(); + ArrayList pieces = new ArrayList<>(); + for (Piece piece : logic.getGame().getBoard().getPlayerData().get(color).getPieces()) { + if(piece.getState() == PieceState.ACTIVE || piece.getState() == PieceState.HOME){ + pieces.add(piece); + } + } + for (Piece piece : pieces) { + if (tryMove(piece)) { + moveablePieces.add(piece); + } + } + return moveablePieces; + } + @Override public String toString() { return getClass().getSimpleName(); From f379a6b638509558786db67df6202b85d7fa64d4 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 17 Nov 2024 20:17:19 +0100 Subject: [PATCH 03/44] added more logic for the server state diagram --- .../src/main/java/pp.mdga/game/Game.java | 83 ++++++++++++++++++- .../main/java/pp.mdga/server/Animation.java | 14 ++++ .../server/ChoosePieceStateMachine.java | 4 +- .../pp.mdga/server/DetermineStartPlayer.java | 35 ++++++++ .../main/java/pp.mdga/server/FirstRoll.java | 24 ++++++ .../main/java/pp.mdga/server/GameState.java | 7 +- .../main/java/pp.mdga/server/Interrupt.java | 9 ++ .../src/main/java/pp.mdga/server/NoPiece.java | 48 +++++++++++ .../src/main/java/pp.mdga/server/NoTurn.java | 7 ++ .../java/pp.mdga/server/PlayPowerCard.java | 7 ++ .../main/java/pp.mdga/server/PowerCard.java | 47 +++++++++++ .../java/pp.mdga/server/RollDiceMachine.java | 4 +- .../main/java/pp.mdga/server/SecondRoll.java | 18 ++++ .../main/java/pp.mdga/server/SelectPiece.java | 14 ++++ .../main/java/pp.mdga/server/ServerState.java | 7 +- .../pp.mdga/server/ServerStateMachine.java | 10 ++- .../main/java/pp.mdga/server/StartPiece.java | 13 +++ .../main/java/pp.mdga/server/ThirdRoll.java | 18 ++++ .../src/main/java/pp.mdga/server/Turn.java | 2 + .../java/pp.mdga/server/TurnStateMachine.java | 4 +- .../java/pp.mdga/server/WaitingPiece.java | 15 ++++ 21 files changed, 374 insertions(+), 16 deletions(-) create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/PlayPowerCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java index 23f135e9..65b37f6d 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java @@ -22,8 +22,12 @@ public class Game { private Map playerConnectionID; private ArrayList observers = new ArrayList<>(); + private Player startPlayer; private Boolean gameHasStarted = false; private Boolean playerHasDisconnected = false; + private Boolean gameIsInterrupted = false; + private Boolean allRanked = false; + private Boolean movablePieces = false; private static final int AMOUNT_OF_TURBO_CARDS = 16; private static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12; @@ -309,6 +313,44 @@ public Boolean playerHasDisconnected() { return playerHasDisconnected; } + /** + * This method sets the game interruption state. + * + * @param gameIsInterrupted the new game interruption state + */ + public void setGameIsInterrupted(Boolean gameIsInterrupted) { + this.gameIsInterrupted = gameIsInterrupted; + if (!gameIsInterrupted) notifyObservers(); + } + + /** + * This method returns whether the game is interrupted. + * + * @return true if the game is interrupted, false otherwise + */ + public Boolean gameIsInterrupted() { + return gameIsInterrupted; + } + + /** + * This method returns whether the game is interrupted. + * + * @return true if the game is interrupted, false otherwise + */ + public Boolean getMovablePieces() { + return movablePieces; + } + + /** + * This method sets the game interruption state. + * + * @param movablePieces the new game interruption state + */ + public void setMovablePieces(Boolean movablePieces) { + this.movablePieces = movablePieces; + if (!movablePieces) notifyObservers(); + } + /** * This method sets the player has disconnected. * @@ -316,9 +358,44 @@ public Boolean playerHasDisconnected() { */ public void setPlayerHasDisconnected(Boolean playerHasDisconnected) { this.playerHasDisconnected = playerHasDisconnected; - if (playerHasDisconnected) { - notifyObservers(); - } + if (playerHasDisconnected) notifyObservers(); + } + + /** + * This method returns whether all players have ranked. + * + * @return true if all players have ranked, false otherwise + */ + public Boolean allRanked() { + return allRanked; + } + + /** + * This method sets whether all players have ranked. + * + * @param allRanked the new all ranked state + */ + public void setAllRanked(Boolean allRanked) { + this.allRanked = allRanked; + if (allRanked) notifyObservers(); + } + + /** + * This method returns the start player. + * + * @return the start player + */ + public Player getStartPlayer() { + return startPlayer; + } + + /** + * This method sets the start player. + * + * @param startPlayer the new start player + */ + public void setStartPlayer(Player startPlayer) { + this.startPlayer = startPlayer; } /** diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java new file mode 100644 index 00000000..c7a71f92 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java @@ -0,0 +1,14 @@ +package pp.mdga.server; + +import pp.mdga.message.client.AnimationEnd; + +public class Animation extends ServerState { + public Animation(ServerState parent, ServerGameLogic logic) { + super(parent, logic); + } + + @Override + public void receivedAnimationEnd(AnimationEnd msg) { + parent.gotoState(new Turn(parent, logic)); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePieceStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePieceStateMachine.java index 89dbefeb..2558e028 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePieceStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePieceStateMachine.java @@ -6,7 +6,7 @@ public ChoosePieceStateMachine(ServerState parent, ServerGameLogic logic) { } @Override - public ServerState initialState() { - return null; + public NoPiece initialState() { + return new NoPiece(this, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java index 6160701f..aaf401e4 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java @@ -1,7 +1,42 @@ package pp.mdga.server; +import pp.mdga.game.Player; +import pp.mdga.message.client.RequestDice; +import pp.mdga.message.server.DiceNow; +import pp.mdga.message.server.RankingRollAgain; + public class DetermineStartPlayer extends ServerState { public DetermineStartPlayer(ServerState parent, ServerGameLogic logic) { super(parent, logic); + logic.getGame().addObserver(this); } + + @Override + public void receivedRequestDice(RequestDice msg) { + // todo: implement + } + + // todo: msg?, sent to everyone? + @Override + public void sentRankingResponse() { + // todo: implemtent + } + + @Override + public void update() { + if (logic.getGame().allRanked()) { + if (logic.getGame().getStartPlayer() == null) { + // todo: send it to everyone? or player with the same dice value? save the players with the same value? + logic.send(new Player(1), new RankingRollAgain()); + } else { + // todo: set start player + Player startPlayer = new Player(1); + logic.getGame().setStartPlayer(startPlayer); + logic.send(startPlayer, new DiceNow()); + parent.gotoState(new Animation(parent, logic)); + logic.getGame().removeObserver(this); + } + } + } + } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java index daa811dd..7787a229 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java @@ -1,7 +1,31 @@ package pp.mdga.server; +import pp.mdga.game.Player; +import pp.mdga.message.client.RequestDice; +import pp.mdga.message.server.Dice; +import pp.mdga.message.server.DiceAgain; + public class FirstRoll extends ServerState { public FirstRoll(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + + @Override + public void receivedRequestDice(RequestDice msg) { + // todo: implement player.hasMovablePieces() + if (player.hasMovablePieces()) { + // todo: goto ChoosePiece + } else { + // todo: implement roll + if (roll == 6) { + // todo: send to everyone? or one player? + logic.send(new Player(1), new Dice()); + // todo: goto ChoosePiece + } else { + // todo: send to everyone? or one player? + logic.send(new Player(1), new DiceAgain()); + parent.gotoState(new SecondRoll(parent, logic)); + } + } + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java index 53ee5901..f94b3bb2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java @@ -34,8 +34,8 @@ public void receivedNoPowerCard(NoPowerCard msg) { } @Override - public void receivedPowerCardChoice(SelectCard msg) { - gameStateMachine.receivedPowerCardChoice(msg); + public void receivedSelectCard(SelectCard msg) { + gameStateMachine.receivedSelectCard(msg); } @Override @@ -68,7 +68,8 @@ public void sentRankingResponse() { @Override public void update() { if (logic.getGame().playerHasDisconnected()) { - parent.gotoState(new Ceremony(parent, logic)); + parent.gotoState(new Interrupt(parent, logic)); + // todo: change to interrupt, save the last state of gamestatemachine, change from interrupt to gamestate has to restore the last state logic.getGame().removeObserver(this); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java index 0f9e0fdc..ae67c4c8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java @@ -3,5 +3,14 @@ public class Interrupt extends ServerState { public Interrupt(ServerState parent, ServerGameLogic logic) { super(parent, logic); + logic.getGame().addObserver(this); + } + + @Override + public void update() { + if (!logic.getGame().gameIsInterrupted()) { + parent.gotoState(new GameState(parent, logic)); + logic.getGame().removeObserver(this); + } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java index 9b2cbb48..59a80020 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java @@ -1,7 +1,55 @@ package pp.mdga.server; +import pp.mdga.game.Player; +import pp.mdga.message.server.WaitPiece; + public class NoPiece extends ServerState { public NoPiece(ServerState parent, ServerGameLogic logic) { super(parent, logic); + entry(); + } + + @Override + public void entry() { + if (hasTurbo() || turbo == 0) { + if (roll == 6 && + logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces() && + logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { + parent.gotoState(new WaitingPiece(parent, logic)); + } else { + parent.gotoState(new NoTurn(parent, logic)); + } + } else { + validateHasPieces(); + } + } + + private void validateHasPieces() { + if (logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces()) { + if (logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { + if (roll == 6) { + logic.send(new Player(1), new WaitPiece()); + } else { + validateMove(); + } + } else { + if (logic.getGame().getBoard().getNodes().getStartNode(Color).getPiece().canMove()) { + logic.send(new Player(1), new WaitPiece()); + parent.gotoState(new StartPiece(parent, logic)); + } else { + validateMove(); + } + } + } else { + validateMove(); + } + } + + private void validateMove() { + if (player.canMove()) { + parent.gotoState(new NoTurn(parent, logic)); + } else { + logic.send(new Player(1), new SelectPiece()); + } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java index 9986437b..810e4966 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java @@ -1,7 +1,14 @@ package pp.mdga.server; +import pp.mdga.message.server.EndOfTurn; + public class NoTurn extends ServerState { public NoTurn(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + + @Override + public void sentEndOfTurn(EndOfTurn msg) { + // todo: goto end of turn + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/PlayPowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/PlayPowerCard.java new file mode 100644 index 00000000..cc7cf7b0 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/PlayPowerCard.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class PlayPowerCard extends ServerState { + public PlayPowerCard(ServerState parent, ServerGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java index fef94ce2..5bc0c495 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java @@ -1,7 +1,54 @@ package pp.mdga.server; +import pp.mdga.game.Player; +import pp.mdga.message.client.NoPowerCard; +import pp.mdga.message.client.SelectCard; +import pp.mdga.message.client.SelectedPieces; +import pp.mdga.message.server.DiceNow; +import pp.mdga.message.server.PossibleCard; + public class PowerCard extends ServerState { public PowerCard(ServerState parent, ServerGameLogic logic) { super(parent, logic); + logic.getGame().addObserver(this); + } + + @Override + public void receivedNoPowerCard(NoPowerCard msg) { + // todo: send to everyone? or one player? + // todo: right msg? + logic.send(new Player(1), new DiceNow()); + parent.gotoState(new RollDice(parent, logic)); + } + + @Override + public void receivedSelectCard(SelectCard msg) { + // todo: send to everyone? or one player? + logic.send(new Player(1), new PossibleCard()); + } + + @Override + public void receivedSelectedPieces(SelectedPieces msg) { + if (verifySelectedPieces()) { + // todo: send to everyone? or one player? + // todo: msg PowerCardAnimation? + logic.send(new Player(1), new PowerCardAnimation()); + parent.gotoState(new PlayPowerCard(parent, logic)); + } + } + + @Override + public void sentPossibleCard(PossibleCard msg) { + // todo: implement + } + + @Override + public void update() { + if (!logic.getGame().getMovablePieces()) { + // todo: send to everyone? or one player? + // todo: right msg? + logic.send(new Player(1), new DiceNow()); + parent.gotoState(new RollDice(parent, logic)); + } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDiceMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDiceMachine.java index 49117d0c..bc788947 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDiceMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDiceMachine.java @@ -6,7 +6,7 @@ public RollDiceMachine(ServerState parent, ServerGameLogic logic) { } @Override - public ServerState initialState() { - return null; + public FirstRoll initialState() { + return new FirstRoll(this, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java index 63b98b9a..a225df40 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java @@ -1,7 +1,25 @@ package pp.mdga.server; +import pp.mdga.game.Player; +import pp.mdga.message.client.RequestDice; +import pp.mdga.message.server.Dice; +import pp.mdga.message.server.DiceAgain; + public class SecondRoll extends ServerState { public SecondRoll(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + + @Override + public void receivedRequestDice(RequestDice msg) { + if (roll == 6) { + // todo: send to everyone? or one player? + logic.send(new Player(1), new Dice()); + // todo: goto ChoosePiece + } else { + // todo: send to everyone? or one player? + logic.send(new Player(1), new DiceAgain()); + parent.gotoState(new ThirdRoll(parent, logic)); + } + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java index f3e21d28..a61bfc27 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java @@ -1,7 +1,21 @@ package pp.mdga.server; +import pp.mdga.game.Piece; +import pp.mdga.game.Player; +import pp.mdga.message.server.StartPiece; + public class SelectPiece extends ServerState { public SelectPiece(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + + @Override + public void receivedConfirmPiece(Piece p) { + if (verifyPiece(p)) { + logic.send(new Player(1), new Animation()); + // todo: goto state + } else { + logic.send(new Player(1), new StartPiece()); + } + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java index ee022302..8cb15d59 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java @@ -2,6 +2,7 @@ import pp.mdga.game.Piece; import pp.mdga.message.client.*; +import pp.mdga.message.server.EndOfTurn; import pp.mdga.message.server.PossibleCard; import java.lang.System.Logger; @@ -28,8 +29,6 @@ public void receivedNoPowerCard(NoPowerCard msg) { /* do nothing */ } public void receivedNotReady(LobbyNotReady msg) { /* do nothing */ } - public void receivedPowerCardChoice(SelectCard msg) { /* do nothing */ } - public void receivedReady(LobbyReady msg) { /* do nothing */ } public void receivedRequestDice(RequestDice msg) { /* do nothing */ } @@ -37,12 +36,16 @@ public void receivedRequestDice(RequestDice msg) { /* do nothing */ } // todo msg? public void receivedRollRankingDice() { /* do nothing */ } + public void receivedSelectCard(SelectCard msg) { /* do nothing */ } + public void receivedSelectTSK(SelectTSK msg) { /* do nothing */ } public void receivedSelectedPieces(SelectedPieces msg) { /* do nothing */ } public void receivedStartGame(ClientStartGame msg) { /* do nothing */ } + public void sentEndOfTurn(EndOfTurn msg) { /* do nothing */ } + public void sentPossibleCard(PossibleCard msg) { /* do nothing */ } // todo msg?, sent to everyone? diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java index f97d54f2..329da544 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java @@ -2,6 +2,7 @@ import pp.mdga.game.Piece; import pp.mdga.message.client.*; +import pp.mdga.message.server.EndOfTurn; import pp.mdga.message.server.PossibleCard; public abstract class ServerStateMachine extends ServerState { @@ -61,8 +62,8 @@ public void receivedNotReady(LobbyNotReady msg) { } @Override - public void receivedPowerCardChoice(SelectCard msg) { - state.receivedPowerCardChoice(msg); + public void receivedSelectCard(SelectCard msg) { + state.receivedSelectCard(msg); } @Override @@ -96,6 +97,11 @@ public void receivedStartGame(ClientStartGame msg) { state.receivedStartGame(msg); } + @Override + public void sentEndOfTurn(EndOfTurn msg) { + state.sentEndOfTurn(msg); + } + @Override public void sentPossibleCard(PossibleCard msg) { state.sentPossibleCard(msg); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java index 24e23b60..0e8d8461 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java @@ -1,7 +1,20 @@ package pp.mdga.server; +import pp.mdga.game.Piece; +import pp.mdga.game.Player; + public class StartPiece extends ServerState { public StartPiece(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + + @Override + public void receivedConfirmPiece(Piece p) { + if (verifyPiece(p)) { + logic.send(new Player(1), new Animation()); + // todo: goto state + } else { + logic.send(new Player(1), new pp.mdga.message.server.StartPiece()); + } + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java index 5f5245d1..496ef8a5 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java @@ -1,7 +1,25 @@ package pp.mdga.server; +import pp.mdga.game.Player; +import pp.mdga.message.client.RequestDice; +import pp.mdga.message.server.Dice; +import pp.mdga.message.server.DiceAgain; + public class ThirdRoll extends ServerState { public ThirdRoll(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + + @Override + public void receivedRequestDice(RequestDice msg) { + if (roll == 6) { + // todo: send to everyone? or one player? + logic.send(new Player(1), new Dice()); + // todo: goto ChoosePiece + } else { + // todo: send to everyone? or one player? + logic.send(new Player(1), new DiceAgain()); + // todo: goto End from Turn + } + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java index ce1447a6..21ec15c7 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java @@ -6,4 +6,6 @@ public class Turn extends ServerState { public Turn(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + + // todo: when TurnStateMachine is in the end state, and then? } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/TurnStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/TurnStateMachine.java index b54f2e07..a5974332 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/TurnStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/TurnStateMachine.java @@ -6,7 +6,7 @@ public TurnStateMachine(ServerState parent, ServerGameLogic logic) { } @Override - public ServerState initialState() { - return null; + public PowerCard initialState() { + return new PowerCard(this, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java index dcc28f3c..b5f39d38 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java @@ -1,7 +1,22 @@ package pp.mdga.server; +import pp.mdga.game.Piece; +import pp.mdga.game.Player; +import pp.mdga.message.client.AnimationEnd; +import pp.mdga.message.server.StartPiece; + public class WaitingPiece extends ServerState { public WaitingPiece(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + + @Override + public void receivedConfirmPiece(Piece p) { + if (verifyPiece(p)) { + logic.send(new Player(1), new Animation()); + // todo: goto state + } else { + logic.send(new Player(1), new StartPiece()); + } + } } From f69a2a9fda407a5669c52904e049add2e43bfbb3 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sun, 17 Nov 2024 21:04:13 +0100 Subject: [PATCH 04/44] added a method to check if a player has pieces in his waiting area --- .../src/main/java/pp.mdga/game/PlayerData.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java index b82893aa..7f2d48d2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java @@ -136,4 +136,18 @@ public int getIndexInHome(Piece piece) { } return -1; } + + /** + * This method returns the homeNodes + * + * @return the homeNodes + */ + public boolean hasPieceInWaitingArea() { + for (Piece piece : waitingArea) { + if (piece != null) { + return true; + } + } + return false; + } } From 9cd9cc871ce805ff88aa37c824b31f28585d6b15 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sun, 17 Nov 2024 21:18:19 +0100 Subject: [PATCH 05/44] fixed a bug with use of addLast method for ArrayList which doesnot exist in Java 20 --- .../client/src/main/java/pp/mdga/client/board/BoardView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardView.java index 01c9e36d..ee2a6c02 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardView.java @@ -60,7 +60,7 @@ private void initMap() { case cir -> addFigureToPlayerMap(assetToColor(BoardAsset.cir), assetOnMap); case marine -> addFigureToPlayerMap(assetToColor(BoardAsset.marine), assetOnMap); case node_normal, node_bonus, node_start -> - infield.addLast(displayAndControl(assetOnMap, new NodeControl())); + infield.add(displayAndControl(assetOnMap, new NodeControl())); default -> displayAsset(assetOnMap); } } From 6790be782ec4cd55b972dfcefa7579df00aff0de Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Tue, 19 Nov 2024 12:42:11 +0100 Subject: [PATCH 06/44] added empty serverstatetests --- .../server/serverState/ServerStateTest.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 53e9af8d..8b76956c 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -1,4 +1,94 @@ package pp.mdga.server.serverState; +import org.junit.Before; +import org.junit.Test; +import pp.mdga.server.ServerGameLogic; +import pp.mdga.server.ServerState; + public class ServerStateTest { + + @Before + public void setUp(){ + ServerGameLogic logic = new ServerGameLogic(); + } + + @Test + public void testInitialStateServerState() { + + } + + @Test + public void testLobbyToDetermineStartPlayer() { + // TODO: Implement test logic for transition from Lobby to Determine Start Player + } + + @Test + public void testStayInLobby() { + // TODO: Implement test logic for staying in the Lobby + } + + @Test + public void testServerGameSubStatesToInterrupt() { + // TODO: Implement test logic for transition from Server Game Sub-States to Interrupt + } + + @Test + public void testServerGameToCeremony() { + // TODO: Implement test logic for transition from Server Game to Ceremony + } + + @Test + public void testInterruptToGameContinue() { + // TODO: Implement test logic for transition from Interrupt to Game Continue + } + + @Test + public void testInterruptToGameReconnect() { + // TODO: Implement test logic for transition from Interrupt to Game Reconnect + } + + @Test + public void testInterruptToGameTimer() { + // TODO: Implement test logic for transition from Interrupt to Game Timer + } + + @Test + public void testCeremonyToServerStateEndState() { + // TODO: Implement test logic for transition from Ceremony to Server State End State + } + + @Test + public void testDeterminStartPlayerToDetermineStartPlayer1() { + // TODO: Implement test logic for Determine Start Player to Determine Start Player (Variant 1) + } + + @Test + public void testDeterminStartPlayerToDetermineStartPlayer2() { + // TODO: Implement test logic for Determine Start Player to Determine Start Player (Variant 2) + } + + @Test + public void testDeterminStartPlayerToAnimation() { + // TODO: Implement test logic for Determine Start Player to Animation + } + + @Test + public void testAnimationToPowerCard() { + // TODO: Implement test logic for transition from Animation to Power Card + } + + @Test + public void testTurnToAnimation() { + // TODO: Implement test logic for transition from Turn to Animation + } + + @Test + public void testTurnToGameEndState() { + // TODO: Implement test logic for transition from Turn to Game End State + } + + @Test + public void testStayInPowerCard() { + // TODO: Implement test logic for staying in Power Card state + } } From 89232901a76d988f0822021166204e73cb9709f4 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Fri, 22 Nov 2024 09:37:49 +0100 Subject: [PATCH 07/44] added more logic for the server state diagram --- .../src/main/java/pp.mdga/game/Game.java | 1 - .../main/java/pp.mdga/server/Animation.java | 4 +- .../pp.mdga/server/DetermineStartPlayer.java | 30 +-- .../main/java/pp.mdga/server/FirstRoll.java | 33 ++- .../main/java/pp.mdga/server/GameState.java | 55 +++-- .../java/pp.mdga/server/GameStateMachine.java | 16 +- .../main/java/pp.mdga/server/Interrupt.java | 12 +- .../src/main/java/pp.mdga/server/Lobby.java | 62 ++++-- .../src/main/java/pp.mdga/server/NoPiece.java | 68 +++--- .../src/main/java/pp.mdga/server/NoTurn.java | 2 +- .../main/java/pp.mdga/server/PowerCard.java | 22 +- .../main/java/pp.mdga/server/SecondRoll.java | 20 +- .../main/java/pp.mdga/server/SelectPiece.java | 15 +- .../java/pp.mdga/server/ServerAutomaton.java | 14 ++ .../java/pp.mdga/server/ServerGameLogic.java | 1 - .../main/java/pp.mdga/server/ServerState.java | 203 ++++++++++++++---- .../pp.mdga/server/ServerStateMachine.java | 186 ++++++++++++---- .../main/java/pp.mdga/server/StartPiece.java | 15 +- .../main/java/pp.mdga/server/ThirdRoll.java | 20 +- .../src/main/java/pp.mdga/server/Turn.java | 25 +++ .../java/pp.mdga/server/WaitingPiece.java | 17 +- 21 files changed, 570 insertions(+), 251 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java index 65b37f6d..4e09869b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java @@ -301,7 +301,6 @@ public Boolean getGameHasStarted() { */ public void setGameHasStarted(Boolean gameHasStarted) { this.gameHasStarted = gameHasStarted; - if (gameHasStarted) notifyObservers(); } /** diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java index c7a71f92..74d95b65 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java @@ -1,6 +1,7 @@ package pp.mdga.server; import pp.mdga.message.client.AnimationEnd; +import pp.mdga.message.server.DiceNow; public class Animation extends ServerState { public Animation(ServerState parent, ServerGameLogic logic) { @@ -8,7 +9,8 @@ public Animation(ServerState parent, ServerGameLogic logic) { } @Override - public void receivedAnimationEnd(AnimationEnd msg) { + public void receivedAnimationEnd(AnimationEnd msg, int from) { + logic.send(logic.getGame().getStartPlayer(), new DiceNow()); parent.gotoState(new Turn(parent, logic)); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java index aaf401e4..0ff4b48e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java @@ -2,41 +2,43 @@ import pp.mdga.game.Player; import pp.mdga.message.client.RequestDice; -import pp.mdga.message.server.DiceNow; -import pp.mdga.message.server.RankingRollAgain; +import pp.mdga.message.server.*; + +import java.util.ArrayList; +import java.util.List; public class DetermineStartPlayer extends ServerState { + private final List player = new ArrayList<>(); + public DetermineStartPlayer(ServerState parent, ServerGameLogic logic) { super(parent, logic); logic.getGame().addObserver(this); } @Override - public void receivedRequestDice(RequestDice msg) { - // todo: implement - } + public void receivedRequestDice(RequestDice msg, int from) { + logic.send(); - // todo: msg?, sent to everyone? - @Override - public void sentRankingResponse() { - // todo: implemtent + broadcastUpdate(new Dice()); } @Override public void update() { - if (logic.getGame().allRanked()) { - if (logic.getGame().getStartPlayer() == null) { - // todo: send it to everyone? or player with the same dice value? save the players with the same value? - logic.send(new Player(1), new RankingRollAgain()); + if (Boolean.TRUE.equals(logic.getGame().allRanked())) { + broadcastUpdate(new RankingResponce()); + if (logic.getGame().getOrder().isEmpty()) { + // todo: save the players with the same value? + broadcastUpdate(new RankingRollAgain()); + broadcastUpdate(new EndOfTurn()); } else { // todo: set start player Player startPlayer = new Player(1); logic.getGame().setStartPlayer(startPlayer); logic.send(startPlayer, new DiceNow()); + broadcastUpdate(new EndOfTurn()); parent.gotoState(new Animation(parent, logic)); logic.getGame().removeObserver(this); } } } - } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java index 7787a229..3c687bf7 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java @@ -1,9 +1,6 @@ package pp.mdga.server; -import pp.mdga.game.Player; import pp.mdga.message.client.RequestDice; -import pp.mdga.message.server.Dice; -import pp.mdga.message.server.DiceAgain; public class FirstRoll extends ServerState { public FirstRoll(ServerState parent, ServerGameLogic logic) { @@ -11,21 +8,21 @@ public FirstRoll(ServerState parent, ServerGameLogic logic) { } @Override - public void receivedRequestDice(RequestDice msg) { + public void receivedRequestDice(RequestDice msg, int from) { // todo: implement player.hasMovablePieces() - if (player.hasMovablePieces()) { - // todo: goto ChoosePiece - } else { - // todo: implement roll - if (roll == 6) { - // todo: send to everyone? or one player? - logic.send(new Player(1), new Dice()); - // todo: goto ChoosePiece - } else { - // todo: send to everyone? or one player? - logic.send(new Player(1), new DiceAgain()); - parent.gotoState(new SecondRoll(parent, logic)); - } - } +// if (player.hasMovablePieces()) { +// // todo: goto ChoosePiece +// } else { +// // todo: implement roll +// if (roll == 6) { +// // todo: send to everyone? or one player? +// logic.send(new Player(1), new Dice()); +// // todo: goto ChoosePiece +// } else { +// // todo: send to everyone? or one player? +// logic.send(new Player(1), new DiceAgain()); +// parent.gotoState(new SecondRoll(parent, logic)); +// } +// } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java index f94b3bb2..dab977c8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java @@ -1,8 +1,9 @@ package pp.mdga.server; -import pp.mdga.game.Piece; import pp.mdga.message.client.*; +import pp.mdga.message.server.PauseGame; import pp.mdga.message.server.PossibleCard; +import pp.mdga.message.server.RankingResponce; public class GameState extends ServerState { private final GameStateMachine gameStateMachine = new GameStateMachine(this, logic); @@ -18,58 +19,50 @@ public void entry() { } @Override - public void receivedAnimationEnd(AnimationEnd msg) { - gameStateMachine.receivedAnimationEnd(msg); - } - - // todo piece? - @Override - public void receivedConfirmPiece(Piece piece) { - gameStateMachine.receivedConfirmPiece(piece); + public void exit() { + parent.gotoState(new Ceremony(parent, logic)); } @Override - public void receivedNoPowerCard(NoPowerCard msg) { - gameStateMachine.receivedNoPowerCard(msg); + public void receivedAnimationEnd(AnimationEnd msg, int from) { + gameStateMachine.receivedAnimationEnd(msg, from); } @Override - public void receivedSelectCard(SelectCard msg) { - gameStateMachine.receivedSelectCard(msg); + public void receivedNoPowerCard(NoPowerCard msg, int from) { + gameStateMachine.receivedNoPowerCard(msg, from); } @Override - public void receivedRequestDice(RequestDice msg) { - gameStateMachine.receivedRequestDice(msg); - } - - // todo msg? - @Override - public void receivedRollRankingDice() { - gameStateMachine.receivedRollRankingDice(); + public void receivedSelectCard(SelectCard msg, int from) { + gameStateMachine.receivedSelectCard(msg, from); } @Override - public void receivedSelectedPieces(SelectedPieces msg) { - gameStateMachine.receivedSelectedPieces(msg); + public void receivedRequestDice(RequestDice msg, int from) { + gameStateMachine.receivedRequestDice(msg, from); } @Override - public void sentPossibleCard(PossibleCard msg) { - gameStateMachine.sentPossibleCard(msg); + public void receivedSelectedPieces(SelectedPieces msg, int from) { + gameStateMachine.receivedSelectedPieces(msg, from); } - // todo msg?, sent to everyone? @Override - public void sentRankingResponse() { - gameStateMachine.sentRankingResponse(); + public void sentPossibleCard(PossibleCard msg, int from) { + gameStateMachine.sentPossibleCard(msg, from); + } + + @Override + public void sentRankingResponse(RankingResponce msg, int from) { + gameStateMachine.sentRankingResponse(msg, from); } @Override public void update() { - if (logic.getGame().playerHasDisconnected()) { - parent.gotoState(new Interrupt(parent, logic)); - // todo: change to interrupt, save the last state of gamestatemachine, change from interrupt to gamestate has to restore the last state + if (Boolean.TRUE.equals(logic.getGame().playerHasDisconnected())) { + broadcastUpdate(new PauseGame()); + parent.gotoState(new Interrupt(parent, logic, this)); logic.getGame().removeObserver(this); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameStateMachine.java index b01981de..2e14808b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameStateMachine.java @@ -1,10 +1,24 @@ package pp.mdga.server; -public class GameStateMachine extends ServerStateMachine{ +/** + * The GameStateMachine class represents the state machine for the game state. + */ +public class GameStateMachine extends ServerStateMachine { + /** + * Constructs a new GameStateMachine with the specified parent state and game logic. + * + * @param parent the parent state + * @param logic the server game logic + */ public GameStateMachine(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + /** + * Returns the initial state of the state machine, which is DetermineStartPlayer. + * + * @return the initial state + */ @Override public DetermineStartPlayer initialState() { return new DetermineStartPlayer(this, logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java index ae67c4c8..ca59ca86 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java @@ -1,15 +1,21 @@ package pp.mdga.server; +import pp.mdga.message.server.ResumeGame; + public class Interrupt extends ServerState { - public Interrupt(ServerState parent, ServerGameLogic logic) { + private final GameState lastState; + + public Interrupt(ServerState parent, ServerGameLogic logic, GameState lastState) { super(parent, logic); + this.lastState = lastState; logic.getGame().addObserver(this); } @Override public void update() { - if (!logic.getGame().gameIsInterrupted()) { - parent.gotoState(new GameState(parent, logic)); + if (Boolean.FALSE.equals(logic.getGame().gameIsInterrupted())) { + broadcastUpdate(new ResumeGame()); + parent.gotoState(lastState); logic.getGame().removeObserver(this); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java index b3bb2330..a612f0f2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java @@ -1,52 +1,74 @@ package pp.mdga.server; import pp.mdga.message.client.*; -import pp.mdga.message.server.ServerMessage; +import pp.mdga.message.server.ServerStartGame; import pp.mdga.message.server.UpdateReady; import pp.mdga.message.server.UpdateTSK; +/** + * Represents the lobby state of the server. + */ public class Lobby extends ServerState { + /** + * Constructs a new Lobby state. + * + * @param parent the parent state + * @param logic the server game logic + */ public Lobby(ServerState parent, ServerGameLogic logic) { super(parent, logic); - logic.getGame().addObserver(this); } + /** + * Handles the DeselectTSK message. + * + * @param msg the DeselectTSK message + */ @Override - public void receivedDeselectTSK(DeselectTSK msg) { + public void receivedDeselectTSK(DeselectTSK msg, int from) { broadcastUpdate(new UpdateTSK()); } + /** + * Handles the LobbyNotReady message. + * + * @param msg the LobbyNotReady message + */ @Override - public void receivedNotReady(LobbyNotReady msg) { + public void receivedNotReady(LobbyNotReady msg, int from) { broadcastUpdate(new UpdateReady()); } + /** + * Handles the LobbyReady message. + * + * @param msg the LobbyReady message + */ @Override - public void receivedReady(LobbyReady msg) { + public void receivedReady(LobbyReady msg, int from) { broadcastUpdate(new UpdateReady()); } + /** + * Handles the SelectTSK message. + * + * @param msg the SelectTSK message + */ @Override - public void receivedSelectTSK(SelectTSK msg) { + public void receivedSelectTSK(SelectTSK msg, int from) { broadcastUpdate(new UpdateTSK()); } - private void broadcastUpdate(ServerMessage updateMessage) { - for (var entry : logic.getGame().getPlayers().entrySet()) { - logic.send(entry.getValue(), updateMessage); - } - } - + /** + * Handles the ClientStartGame message. + * + * @param msg the ClientStartGame message + */ @Override - public void receivedStartGame(ClientStartGame msg) { - // todo: implement?? - } - - @Override - public void update() { - if (logic.getGame().getGameHasStarted()) { + public void receivedStartGame(ClientStartGame msg, int from) { + if (Boolean.TRUE.equals(logic.getGame().allRanked())) { + broadcastUpdate(new ServerStartGame()); parent.gotoState(new GameState(parent, logic)); - logic.getGame().removeObserver(this); } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java index 59a80020..6326bfb1 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java @@ -11,45 +11,45 @@ public NoPiece(ServerState parent, ServerGameLogic logic) { @Override public void entry() { - if (hasTurbo() || turbo == 0) { - if (roll == 6 && - logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces() && - logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { - parent.gotoState(new WaitingPiece(parent, logic)); - } else { - parent.gotoState(new NoTurn(parent, logic)); - } - } else { - validateHasPieces(); - } +// if (hasTurbo() || turbo == 0) { +// if (roll == 6 && +// logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces() && +// logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { +// parent.gotoState(new WaitingPiece(parent, logic)); +// } else { +// parent.gotoState(new NoTurn(parent, logic)); +// } +// } else { +// validateHasPieces(); +// } } private void validateHasPieces() { - if (logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces()) { - if (logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { - if (roll == 6) { - logic.send(new Player(1), new WaitPiece()); - } else { - validateMove(); - } - } else { - if (logic.getGame().getBoard().getNodes().getStartNode(Color).getPiece().canMove()) { - logic.send(new Player(1), new WaitPiece()); - parent.gotoState(new StartPiece(parent, logic)); - } else { - validateMove(); - } - } - } else { - validateMove(); - } +// if (logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces()) { +// if (logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { +// if (roll == 6) { +// logic.send(new Player(1), new WaitPiece()); +// } else { +// validateMove(); +// } +// } else { +// if (logic.getGame().getBoard().getNodes().getStartNode(Color).getPiece().canMove()) { +// logic.send(new Player(1), new WaitPiece()); +// parent.gotoState(new StartPiece(parent, logic)); +// } else { +// validateMove(); +// } +// } +// } else { +// validateMove(); +// } } private void validateMove() { - if (player.canMove()) { - parent.gotoState(new NoTurn(parent, logic)); - } else { - logic.send(new Player(1), new SelectPiece()); - } +// if (player.canMove()) { +// parent.gotoState(new NoTurn(parent, logic)); +// } else { +// logic.send(new Player(1), new SelectPiece()); +// } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java index 810e4966..388f50bf 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java @@ -8,7 +8,7 @@ public NoTurn(ServerState parent, ServerGameLogic logic) { } @Override - public void sentEndOfTurn(EndOfTurn msg) { + public void sentEndOfTurn(EndOfTurn msg, int from) { // todo: goto end of turn } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java index 5bc0c495..a66f0104 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java @@ -14,7 +14,7 @@ public PowerCard(ServerState parent, ServerGameLogic logic) { } @Override - public void receivedNoPowerCard(NoPowerCard msg) { + public void receivedNoPowerCard(NoPowerCard msg, int from) { // todo: send to everyone? or one player? // todo: right msg? logic.send(new Player(1), new DiceNow()); @@ -22,29 +22,29 @@ public void receivedNoPowerCard(NoPowerCard msg) { } @Override - public void receivedSelectCard(SelectCard msg) { + public void receivedSelectCard(SelectCard msg, int from) { // todo: send to everyone? or one player? logic.send(new Player(1), new PossibleCard()); } @Override - public void receivedSelectedPieces(SelectedPieces msg) { - if (verifySelectedPieces()) { - // todo: send to everyone? or one player? - // todo: msg PowerCardAnimation? - logic.send(new Player(1), new PowerCardAnimation()); - parent.gotoState(new PlayPowerCard(parent, logic)); - } + public void receivedSelectedPieces(SelectedPieces msg, int from) { +// if (verifySelectedPieces()) { +// // todo: send to everyone? or one player? +// // todo: msg PowerCardAnimation? +// logic.send(new Player(1), new PowerCardAnimation()); +// parent.gotoState(new PlayPowerCard(parent, logic)); +// } } @Override - public void sentPossibleCard(PossibleCard msg) { + public void sentPossibleCard(PossibleCard msg, int from) { // todo: implement } @Override public void update() { - if (!logic.getGame().getMovablePieces()) { + if (!super.getMoveablePieces(logic.getGame().getActiveColor()).isEmpty()) { // todo: send to everyone? or one player? // todo: right msg? logic.send(new Player(1), new DiceNow()); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java index a225df40..d149236b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java @@ -11,15 +11,15 @@ public SecondRoll(ServerState parent, ServerGameLogic logic) { } @Override - public void receivedRequestDice(RequestDice msg) { - if (roll == 6) { - // todo: send to everyone? or one player? - logic.send(new Player(1), new Dice()); - // todo: goto ChoosePiece - } else { - // todo: send to everyone? or one player? - logic.send(new Player(1), new DiceAgain()); - parent.gotoState(new ThirdRoll(parent, logic)); - } + public void receivedRequestDice(RequestDice msg, int from) { +// if (roll == 6) { +// // todo: send to everyone? or one player? +// logic.send(new Player(1), new Dice()); +// // todo: goto ChoosePiece +// } else { +// // todo: send to everyone? or one player? +// logic.send(new Player(1), new DiceAgain()); +// parent.gotoState(new ThirdRoll(parent, logic)); +// } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java index a61bfc27..9cd71e6a 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java @@ -2,6 +2,7 @@ import pp.mdga.game.Piece; import pp.mdga.game.Player; +import pp.mdga.message.client.RequestMove; import pp.mdga.message.server.StartPiece; public class SelectPiece extends ServerState { @@ -10,12 +11,12 @@ public SelectPiece(ServerState parent, ServerGameLogic logic) { } @Override - public void receivedConfirmPiece(Piece p) { - if (verifyPiece(p)) { - logic.send(new Player(1), new Animation()); - // todo: goto state - } else { - logic.send(new Player(1), new StartPiece()); - } + public void receivedRequestMove(RequestMove msg, int from) { +// if (verifyPiece(p)) { +// logic.send(new Player(1), new Animation()); +// // todo: goto state +// } else { +// logic.send(new Player(1), new StartPiece()); +// } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerAutomaton.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerAutomaton.java index 4d8bbd31..14061e81 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerAutomaton.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerAutomaton.java @@ -1,11 +1,25 @@ package pp.mdga.server; +/** + * The ServerAutomaton class represents the top-level state machine for the server. + * It initializes the state machine and sets the initial state to Lobby. + */ public class ServerAutomaton extends ServerStateMachine { + /** + * Constructs a new ServerAutomaton with the specified game logic. + * + * @param logic the server game logic + */ public ServerAutomaton(ServerGameLogic logic) { super(null, logic); entry(); } + /** + * Returns the initial state of the state machine, which is Lobby. + * + * @return the initial state + */ @Override public Lobby initialState() { return new Lobby(this, logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java index c278a929..2dbb77f5 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java @@ -125,7 +125,6 @@ public Game getGame() { return game; } - // todo: remove public ServerState getState() { return state; } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java index 311c7809..90c08897 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java @@ -8,64 +8,175 @@ import pp.mdga.message.client.*; import pp.mdga.message.server.EndOfTurn; import pp.mdga.message.server.PossibleCard; +import pp.mdga.message.server.RankingResponce; +import pp.mdga.message.server.ServerMessage; + import java.lang.System.Logger; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; +/** + * Abstract class representing a state in the server's state machine. + * Implements the Observer pattern to observe changes in the game state. + */ public abstract class ServerState implements Observer { + /** + * Logger for logging messages within the application. + */ protected static final Logger LOGGER = System.getLogger(ServerState.class.getName()); + + /** + * The parent state of the current state. + */ protected ServerState parent; + + /** + * The game logic associated with the server state. + */ protected ServerGameLogic logic; - public ServerState(ServerState parent, ServerGameLogic logic) { + /** + * Constructs a new ServerState with the specified parent state and game logic. + * + * @param parent the parent state of the current state + * @param logic the game logic associated with the server state + */ + protected ServerState(ServerState parent, ServerGameLogic logic) { this.parent = parent; this.logic = logic; } + /** + * This method is called when the state is entered. + */ public void entry() { /* do nothing */ } - public void receivedAnimationEnd(AnimationEnd msg) { /* do nothing */ } + /** + * This method is called when the state is exited. + */ + public void exit() { /* do nothing */ } - // todo piece? - public void receivedConfirmPiece(Piece piece) { /* do nothing */ } + /** + * This method is called when an animation ends. + * + * @param msg the animation end message + */ + public void receivedAnimationEnd(AnimationEnd msg, int from) { /* do nothing */ } - public void receivedDeselectTSK(DeselectTSK msg) { /* do nothing */ } + /** + * This method is called when a TSK is deselected. + * + * @param msg the deselect TSK message + */ + public void receivedDeselectTSK(DeselectTSK msg, int from) { /* do nothing */ } - public void receivedNoPowerCard(NoPowerCard msg) { /* do nothing */ } + /** + * This method is called when a NoPowerCard message is received. + * + * @param msg the NoPowerCard message + */ + public void receivedNoPowerCard(NoPowerCard msg, int from) { /* do nothing */ } - public void receivedNotReady(LobbyNotReady msg) { /* do nothing */ } + /** + * This method is called when a LobbyNotReady message is received. + * + * @param msg the LobbyNotReady message + */ + public void receivedNotReady(LobbyNotReady msg, int from) { /* do nothing */ } - public void receivedReady(LobbyReady msg) { /* do nothing */ } + /** + * This method is called when a LobbyReady message is received. + * + * @param msg the LobbyReady message + */ + public void receivedReady(LobbyReady msg, int from) { /* do nothing */ } - public void receivedRequestDice(RequestDice msg) { /* do nothing */ } + /** + * This method is called when a RequestDice message is received. + * + * @param msg the RequestDice message + */ + public void receivedRequestDice(RequestDice msg, int from) { /* do nothing */ } - // todo msg? - public void receivedRollRankingDice() { /* do nothing */ } + /** + * This method is called when a RequestMove message is received. + * + * @param msg the RequestMove message + */ + public void receivedRequestMove(RequestMove msg, int from) { /* do nothing */ } - public void receivedSelectCard(SelectCard msg) { /* do nothing */ } + /** + * This method is called when a SelectCard message is received. + * + * @param msg the SelectCard message + */ + public void receivedSelectCard(SelectCard msg, int from) { /* do nothing */ } - public void receivedSelectTSK(SelectTSK msg) { /* do nothing */ } + /** + * This method is called when a SelectTSK message is received. + * + * @param msg the SelectTSK message + */ + public void receivedSelectTSK(SelectTSK msg, int from) { /* do nothing */ } - public void receivedSelectedPieces(SelectedPieces msg) { /* do nothing */ } + /** + * This method is called when a SelectedPieces message is received. + * + * @param msg the SelectedPieces message + */ + public void receivedSelectedPieces(SelectedPieces msg, int from) { /* do nothing */ } - public void receivedStartGame(ClientStartGame msg) { /* do nothing */ } + /** + * This method is called when a StartGame message is received. + * + * @param msg the StartGame message + */ + public void receivedStartGame(ClientStartGame msg, int from) { /* do nothing */ } - public void sentEndOfTurn(EndOfTurn msg) { /* do nothing */ } + /** + * This method is called when an EndOfTurn message is sent. + * + * @param msg the EndOfTurn message + */ + public void sentEndOfTurn(EndOfTurn msg, int from) { /* do nothing */ } - public void sentPossibleCard(PossibleCard msg) { /* do nothing */ } + /** + * This method is called when a PossibleCard message is sent. + * + * @param msg the PossibleCard message + */ + public void sentPossibleCard(PossibleCard msg, int from) { /* do nothing */ } - // todo msg?, sent to everyone? - public void sentRankingResponse() { /* do nothing */ } + /** + * This method is called when a RankingResponce message is sent. + * + * @param msg the RankingResponce message + */ + public void sentRankingResponse(RankingResponce msg, int from) { /* do nothing */ } + /** + * This method transitions to a new state. + * + * @param state the new state to transition to + * @throws IllegalStateException if called outside a state machine + */ public void gotoState(ServerState state) { throw new IllegalStateException("not in a statemachine"); } + /** + * Returns the parent state of the current state. + * + * @return the parent state + */ public ServerState getParent() { return parent; } + /** + * This method is called when the observed object is changed. + * It is part of the Observer pattern implementation. + */ public void update() { /* do nothing */ } /** @@ -73,7 +184,7 @@ public void update() { /* do nothing */ } * * @return the steps a piece can move */ - private int calculateSteps(){ + private int calculateSteps() { return logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier(); } @@ -84,14 +195,15 @@ private int calculateSteps(){ * @return true if the piece can be moved, false otherwise */ protected boolean tryMove(Piece piece) { - if (piece.getState() == PieceState.HOME){ - return tryHomeMove(piece, calculateSteps()); + int steps = calculateSteps(); + if (piece.getState() == PieceState.HOME) { + return tryHomeMove(piece, steps); } else { - int homeMoves = getHomeMoves(piece, calculateSteps()); - if (homeMoves > 0){ + int homeMoves = getHomeMoves(piece, steps); + if (homeMoves > 0) { return tryHomeMove(piece, homeMoves); } else { - return tryInfieldMove(piece, calculateSteps()); + return tryInfieldMove(piece, steps); } } } @@ -108,12 +220,12 @@ protected int getHomeMoves(Piece piece, int steps) { Color col = piece.getColor(); int startIndex = logic.getGame().getBoard().getPlayerData().get(col).getStartNodeIndex(); int moveIndex = startIndex + steps; - if (moveIndex > logic.getGame().getBoard().getInfield().length){ + if (moveIndex > logic.getGame().getBoard().getInfield().length) { moveIndex %= logic.getGame().getBoard().getInfield().length; - if(moveIndex >= startIndex){ + if (moveIndex >= startIndex) { return moveIndex - startIndex + 1; } - } else if (figureIndex < startIndex && moveIndex >= startIndex){ + } else if (figureIndex < startIndex && moveIndex >= startIndex) { return moveIndex - startIndex + 1; } return 0; @@ -126,11 +238,11 @@ protected int getHomeMoves(Piece piece, int steps) { * @param steps the steps the piece would move * @return true if the piece can move in the infield, false otherwise */ - protected boolean tryInfieldMove(Piece piece, int steps){ + protected boolean tryInfieldMove(Piece piece, int steps) { int figureIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); int moveIndex = (figureIndex + steps) % logic.getGame().getBoard().getInfield().length; Piece occupant = logic.getGame().getBoard().getInfield()[moveIndex].getOccupant(); - if(occupant != null){ + if (occupant != null) { return occupant.getColor() != piece.getColor(); } return true; @@ -143,22 +255,23 @@ protected boolean tryInfieldMove(Piece piece, int steps){ * @param steps the steps the piece would move * @return true if the piece can move into the home area, false otherwise */ - protected boolean tryHomeMove(Piece piece, int steps){ + protected boolean tryHomeMove(Piece piece, int steps) { Color col = piece.getColor(); PlayerData playerData = logic.getGame().getBoard().getPlayerData().get(col); Node[] homeNodes = playerData.getHomeNodes(); int index; - if (playerData.homeIncludes(piece)){ + if (playerData.homeIncludes(piece)) { index = playerData.getIndexInHome(piece); } else { index = 0; } - if(index + steps >= homeNodes.length){ + + if (index + steps >= homeNodes.length) { return false; } else { - for(int i = index; i <= index + steps; i++){ - if(homeNodes[i].getOccupant() != null){ + for (int i = index; i <= index + steps; i++) { + if (homeNodes[i].getOccupant() != null) { return false; } } @@ -176,7 +289,7 @@ protected List getMoveablePieces(Color color) { ArrayList moveablePieces = new ArrayList<>(); ArrayList pieces = new ArrayList<>(); for (Piece piece : logic.getGame().getBoard().getPlayerData().get(color).getPieces()) { - if(piece.getState() == PieceState.ACTIVE || piece.getState() == PieceState.HOME){ + if (piece.getState() == PieceState.ACTIVE || piece.getState() == PieceState.HOME) { pieces.add(piece); } } @@ -188,6 +301,22 @@ protected List getMoveablePieces(Color color) { return moveablePieces; } + /** + * Broadcasts an update message to all players. + * + * @param updateMessage the update message to be sent + */ + protected void broadcastUpdate(ServerMessage updateMessage) { + for (var entry : logic.getGame().getPlayers().entrySet()) { + logic.send(entry.getValue(), updateMessage); + } + } + + /** + * Returns a string representation of the object. + * + * @return the simple name of the class + */ @Override public String toString() { return getClass().getSimpleName(); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java index 329da544..a55c0ef0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java @@ -1,26 +1,50 @@ package pp.mdga.server; -import pp.mdga.game.Piece; import pp.mdga.message.client.*; import pp.mdga.message.server.EndOfTurn; import pp.mdga.message.server.PossibleCard; +import pp.mdga.message.server.RankingResponce; +/** + * Abstract class representing a state machine for the server. + * It manages the transitions between different states and delegates + * the handling of messages to the current state. + */ public abstract class ServerStateMachine extends ServerState { - + /** + * The current state of the state machine. + */ private ServerState state; - public ServerStateMachine(ServerState parent, ServerGameLogic logic) { + /** + * Constructs a new instance of ServerStateMachine. + * + * @param parent the parent state + * @param logic the server game logic + */ + protected ServerStateMachine(ServerState parent, ServerGameLogic logic) { super(parent, logic); } + /** + * Creates the initial state of a state machine. + */ public abstract ServerState initialState(); + /** + * Transitions to a new state. + * + * @param newState the new state to transition to + */ @Override public void gotoState(ServerState newState) { LOGGER.log(System.Logger.Level.DEBUG, "{0}: {1} --> {2}", this, state, newState); enter(newState); } + /** + * This method is called when the state is entered. + */ @Override public void entry() { final ServerState newState = initialState(); @@ -28,6 +52,12 @@ public void entry() { enter(newState); } + /** + * Enters a new state. + * + * @param newState the new state to enter + * @throws IllegalArgumentException if the new state does not belong to this state machine + */ private void enter(ServerState newState) { if (newState.parent != this) throw new IllegalArgumentException("Wrong state: " + newState + " belongs to " + newState.parent + " instead of " + this); @@ -35,86 +65,170 @@ private void enter(ServerState newState) { state.entry(); } + /** + * This method is called when the state is exited. + */ @Override - public void receivedAnimationEnd(AnimationEnd msg) { - state.receivedAnimationEnd(msg); + public void exit() { + state.exit(); } - // todo piece? + /** + * This method is called when an animation ends. + * + * @param msg the animation end message + */ @Override - public void receivedConfirmPiece(Piece piece) { - state.receivedConfirmPiece(piece); + public void receivedAnimationEnd(AnimationEnd msg, int from) { + state.receivedAnimationEnd(msg, from); } + /** + * This method is called when a TSK is deselected. + * + * @param msg the deselect TSK message + */ @Override - public void receivedDeselectTSK(DeselectTSK msg) { - state.receivedDeselectTSK(msg); + public void receivedDeselectTSK(DeselectTSK msg, int from) { + state.receivedDeselectTSK(msg, from); } + /** + * This method is called when a NoPowerCard message is received. + * + * @param msg the NoPowerCard message + */ @Override - public void receivedNoPowerCard(NoPowerCard msg) { - state.receivedNoPowerCard(msg); + public void receivedNoPowerCard(NoPowerCard msg, int from) { + state.receivedNoPowerCard(msg, from); } + /** + * This method is called when a LobbyNotReady message is received. + * + * @param msg the LobbyNotReady message + */ @Override - public void receivedNotReady(LobbyNotReady msg) { - state.receivedNotReady(msg); + public void receivedNotReady(LobbyNotReady msg, int from) { + state.receivedNotReady(msg, from); } + /** + * This method is called when a LobbyReady message is received. + * + * @param msg the LobbyReady message + */ @Override - public void receivedSelectCard(SelectCard msg) { - state.receivedSelectCard(msg); + public void receivedReady(LobbyReady msg, int from) { + state.receivedReady(msg, from); } + /** + * This method is called when a RequestDice message is received. + * + * @param msg the RequestDice message + */ @Override - public void receivedReady(LobbyReady msg) { - state.receivedReady(msg); + public void receivedRequestDice(RequestDice msg, int from) { + state.receivedRequestDice(msg, from); } + /** + * This method is called when a RequestMove message is received. + * + * @param msg the RequestMove message + */ @Override - public void receivedRequestDice(RequestDice msg) { - state.receivedRequestDice(msg); + public void receivedRequestMove(RequestMove msg, int from) { + state.receivedRequestMove(msg, from); } - // todo msg? + /** + * This method is called when a SelectCard message is received. + * + * @param msg the SelectCard message + */ @Override - public void receivedRollRankingDice() { - state.receivedRollRankingDice(); + public void receivedSelectCard(SelectCard msg, int from) { + state.receivedSelectCard(msg, from); } + /** + * This method is called when a SelectTSK message is received. + * + * @param msg the SelectTSK message + */ @Override - public void receivedSelectTSK(SelectTSK msg) { - state.receivedSelectTSK(msg); + public void receivedSelectTSK(SelectTSK msg, int from) { + state.receivedSelectTSK(msg, from); } + /** + * This method is called when a SelectedPieces message is received. + * + * @param msg the SelectedPieces message + */ @Override - public void receivedSelectedPieces(SelectedPieces msg) { - state.receivedSelectedPieces(msg); + public void receivedSelectedPieces(SelectedPieces msg, int from) { + state.receivedSelectedPieces(msg, from); } + /** + * This method is called when a StartGame message is received. + * + * @param msg the StartGame message + */ @Override - public void receivedStartGame(ClientStartGame msg) { - state.receivedStartGame(msg); + public void receivedStartGame(ClientStartGame msg, int from) { + state.receivedStartGame(msg, from); } + /** + * This method is called when an EndOfTurn message is sent. + * + * @param msg the EndOfTurn message + */ @Override - public void sentEndOfTurn(EndOfTurn msg) { - state.sentEndOfTurn(msg); + public void sentEndOfTurn(EndOfTurn msg, int from) { + state.sentEndOfTurn(msg, from); } + /** + * This method is called when a PossibleCard message is sent. + * + * @param msg the PossibleCard message + */ @Override - public void sentPossibleCard(PossibleCard msg) { - state.sentPossibleCard(msg); + public void sentPossibleCard(PossibleCard msg, int from) { + state.sentPossibleCard(msg, from); } - // todo msg?, sent to everyone? + /** + * This method is called when a RankingResponce message is sent. + * + * @param msg the RankingResponce message + */ @Override - public void sentRankingResponse() { - state.sentRankingResponse(); + public void sentRankingResponse(RankingResponce msg, int from) { + state.sentRankingResponse(msg, from); } + /** + * Returns a string representation of the object, including the current state. + * + * @return the string representation of the object + */ @Override public String toString() { return super.toString() + "(in " + state + ")"; } + + /** + * Returns the current state. + * + * @return the current state + */ + public ServerState getState() { + return state; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java index 0e8d8461..f18641a2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java @@ -2,6 +2,7 @@ import pp.mdga.game.Piece; import pp.mdga.game.Player; +import pp.mdga.message.client.RequestMove; public class StartPiece extends ServerState { public StartPiece(ServerState parent, ServerGameLogic logic) { @@ -9,12 +10,12 @@ public StartPiece(ServerState parent, ServerGameLogic logic) { } @Override - public void receivedConfirmPiece(Piece p) { - if (verifyPiece(p)) { - logic.send(new Player(1), new Animation()); - // todo: goto state - } else { - logic.send(new Player(1), new pp.mdga.message.server.StartPiece()); - } + public void receivedRequestMove(RequestMove msg, int from) { +// if (verifyPiece(p)) { +// logic.send(new Player(1), new Animation()); +// // todo: goto state +// } else { +// logic.send(new Player(1), new pp.mdga.message.server.StartPiece()); +// } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java index 496ef8a5..ebe9fd77 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java @@ -11,15 +11,15 @@ public ThirdRoll(ServerState parent, ServerGameLogic logic) { } @Override - public void receivedRequestDice(RequestDice msg) { - if (roll == 6) { - // todo: send to everyone? or one player? - logic.send(new Player(1), new Dice()); - // todo: goto ChoosePiece - } else { - // todo: send to everyone? or one player? - logic.send(new Player(1), new DiceAgain()); - // todo: goto End from Turn - } + public void receivedRequestDice(RequestDice msg, int from) { +// if (roll == 6) { +// // todo: send to everyone? or one player? +// logic.send(new Player(1), new Dice()); +// // todo: goto ChoosePiece +// } else { +// // todo: send to everyone? or one player? +// logic.send(new Player(1), new DiceAgain()); +// // todo: goto End from Turn +// } } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java index 21ec15c7..d2eacc7b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java @@ -1,5 +1,11 @@ package pp.mdga.server; +import pp.mdga.client.Spectator; +import pp.mdga.game.Player; +import pp.mdga.message.server.ActivePlayer; +import pp.mdga.message.server.Ceremony; +import pp.mdga.message.server.EndOfTurn; + public class Turn extends ServerState { private final TurnStateMachine turnStateMachine = new TurnStateMachine(this, logic); @@ -8,4 +14,23 @@ public Turn(ServerState parent, ServerGameLogic logic) { } // todo: when TurnStateMachine is in the end state, and then? + @Override + public void exit() { + Player player = logic.getGame().getStartPlayer(); + +// if (player.isFinished()) { +// logic.send(player, new Spectator()); +// } else { +// logic.send(player, new EndOfTurn()); +// } + + if (logic.getGame().getPlayers().size() == 1) { + broadcastUpdate(new Ceremony()); + this.getParent().getParent().exit(); + } else { + // todo: next player + broadcastUpdate(new ActivePlayer()); + parent.gotoState(new Animation(parent, logic)); + } + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java index b5f39d38..a284a451 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java @@ -2,7 +2,8 @@ import pp.mdga.game.Piece; import pp.mdga.game.Player; -import pp.mdga.message.client.AnimationEnd; +import pp.mdga.message.client.RequestDice; +import pp.mdga.message.client.RequestMove; import pp.mdga.message.server.StartPiece; public class WaitingPiece extends ServerState { @@ -11,12 +12,12 @@ public WaitingPiece(ServerState parent, ServerGameLogic logic) { } @Override - public void receivedConfirmPiece(Piece p) { - if (verifyPiece(p)) { - logic.send(new Player(1), new Animation()); - // todo: goto state - } else { - logic.send(new Player(1), new StartPiece()); - } + public void receivedRequestMove(RequestMove msg, int from) { +// if (verifyPiece(p)) { +// logic.send(new Player(1), new Animation()); +// // todo: goto state +// } else { +// logic.send(new Player(1), new StartPiece()); +// } } } From 806f0d7d9d92249b8f8a01b8e9e646da784276c1 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sat, 23 Nov 2024 12:26:20 +0100 Subject: [PATCH 08/44] added message contents to the messages addedn the conentents for all messages regarding the BPMN diagramm and own interpretation. also created an identifier for pieces to be used for network communication between server and client so that they talk about the same piece. --- .../src/main/java/pp.mdga/game/Game.java | 13 ++++++ .../src/main/java/pp.mdga/game/Piece.java | 13 +++++- .../main/java/pp.mdga/game/PlayerData.java | 2 +- .../pp.mdga/message/client/RequestMove.java | 21 ++++++++- .../message/client/RequestPlayCard.java | 21 ++++++++- .../pp.mdga/message/client/SelectCard.java | 13 ++++++ .../pp.mdga/message/client/SelectTSK.java | 13 ++++++ .../message/client/SelectedPieces.java | 19 ++++++++ .../pp.mdga/message/server/ActivePlayer.java | 19 ++++++++ .../java/pp.mdga/message/server/AnyPiece.java | 25 ++++++++++ .../java/pp.mdga/message/server/Dice.java | 46 +++++++++++++++++++ .../message/server/LobbyPlayerJoin.java | 11 +++++ .../message/server/LobbyPlayerLeave.java | 18 ++++++++ .../pp.mdga/message/server/MoveMessage.java | 20 ++++++++ .../java/pp.mdga/message/server/PlayCard.java | 28 +++++++++++ .../pp.mdga/message/server/PossibleCard.java | 27 +++++++++++ .../pp.mdga/message/server/PossiblePiece.java | 34 ++++++++++++++ .../message/server/ReconnectBriefing.java | 12 +++++ .../pp.mdga/message/server/StartPiece.java | 11 +++++ .../pp.mdga/message/server/UpdateReady.java | 18 ++++++++ .../pp.mdga/message/server/UpdateTSK.java | 18 ++++++++ 21 files changed, 398 insertions(+), 4 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java index 4e09869b..7807061f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java @@ -405,4 +405,17 @@ public void notifyObservers() { observer.update(); } } + + /** + * This method returns the piece through its identifier. + * + * @param identifier the identifier of the piece + * @return the piece + */ + public Piece getPieceThroughIdentifier(String identifier) { + String[] parts = identifier.split("-"); + Color color = Color.valueOf(parts[0]); + int index = Integer.parseInt(parts[1]); + return board.getPlayerData().get(color).getPieces()[index]; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java index aef3f73f..96d4419b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java @@ -7,6 +7,7 @@ public class Piece { private ShieldState shield; private PieceState state; private final Color color; + private final int id; /** * This constructor is used to create a new Piece @@ -14,10 +15,11 @@ public class Piece { * @param color the color of the piece * @param state the state of the piece */ - public Piece(Color color, PieceState state) { + public Piece(Color color, PieceState state, int id) { this.color = color; this.state = state; shield = ShieldState.NONE; + this.id = id; } /** @@ -82,4 +84,13 @@ public boolean isSuppressed() { public Color getColor() { return color; } + + /** + * This method is used to get the color of the piece + * + * @return the color of the piece + */ + public String getIdentifier() { + return color.toString() + "-" + id; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java index 7f2d48d2..c68bc8ff 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java @@ -19,7 +19,7 @@ public PlayerData(Color color) { waitingArea = new Piece[4]; for (int i = 0; i < 4; i++) { homeNodes[i] = new HomeNode(); - pieces[i] = new Piece(color, PieceState.WAITING); + pieces[i] = new Piece(color, PieceState.WAITING, i); waitingArea[i] = pieces[i]; } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java index 22bb9e45..48fd187d 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java @@ -1,9 +1,28 @@ package pp.mdga.message.client; +import pp.mdga.game.Color; + public class RequestMove extends ClientMessage { + + private final String pieceIdentifier; + + /** Constructor for RequestMove + * @param pieceIdentifier the piece identifier + */ + public RequestMove(String pieceIdentifier) { + this.pieceIdentifier = pieceIdentifier; + } + + /** Getter for the piece identifier + * @return the piece identifier + */ + public String getPieceIdentifier() { + return pieceIdentifier; + } + @Override public String toString() { - return "null"; + return pieceIdentifier; } @Override diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java index 48be71b7..67885e0f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java @@ -1,9 +1,28 @@ package pp.mdga.message.client; +import pp.mdga.game.BonusCard; + public class RequestPlayCard extends ClientMessage { + + private final BonusCard card; + private final String pieceIdentifier; + + public RequestPlayCard(BonusCard card, String pieceIdentifier) { + this.pieceIdentifier = pieceIdentifier; + this.card = card; + } + + public BonusCard getCard() { + return card; + } + + public String getPieceIdentifier() { + return pieceIdentifier; + } + @Override public String toString() { - return "null"; + return card.toString(); } @Override diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java index ece2ffae..44957a6c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java @@ -1,6 +1,19 @@ package pp.mdga.message.client; +import pp.mdga.game.BonusCard; + public class SelectCard extends ClientMessage { + + private final BonusCard card; + + public SelectCard(BonusCard card) { + this.card = card; + } + + public BonusCard getCard() { + return card; + } + @Override public String toString() { return "null"; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java index 222d07d4..02a5c4cf 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java @@ -1,6 +1,19 @@ package pp.mdga.message.client; +import pp.mdga.game.Color; + public class SelectTSK extends ClientMessage { + + private final Color color; + + public SelectTSK(Color color) { + this.color = color; + } + + public Color getColor() { + return color; + } + @Override public String toString() { return "null"; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java index d8978857..50290e19 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java @@ -1,6 +1,25 @@ package pp.mdga.message.client; +import pp.mdga.game.Color; + public class SelectedPieces extends ClientMessage { + + private String pieceIdentifier; + + /** Constructor for SelectedPieces + * @param pieceIdentifier the piece identifier + */ + public SelectedPieces(String pieceIdentifier) { + this.pieceIdentifier = pieceIdentifier; + } + + /** Getter for the piece identifier + * @return the piece identifier + */ + public String getPieceIdentifier() { + return pieceIdentifier; + } + @Override public String toString() { return "null"; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java index 3ba4a9ce..e7c35daa 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java @@ -1,6 +1,25 @@ package pp.mdga.message.server; +import pp.mdga.game.Color; + public class ActivePlayer extends ServerMessage { + + private Color color; + + /** Constructor for ActivePlayer + * @param color the color of the active player + */ + public ActivePlayer(Color color) { + this.color = color; + } + + /** Getter for the color of the active player + * @return the color of the active player + */ + public Color getColor() { + return color; + } + @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java index 5b4ecdd4..42e3cec6 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java @@ -1,6 +1,31 @@ package pp.mdga.message.server; +import java.util.ArrayList; + public class AnyPiece extends ServerMessage { + + private ArrayList piece; + + /** Constructor for AnyPiece + */ + public AnyPiece() { + piece = new ArrayList<>(); + } + + /** Add a piece to the list of pieces + * @param piece the piece to add + */ + public void addPiece(String piece) { + this.piece.add(piece); + } + + /** Getter for the list of pieces + * @return the list of pieces + */ + public ArrayList getPiece() { + return piece; + } + @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java index f1725669..7330505f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java @@ -1,6 +1,52 @@ package pp.mdga.message.server; +import java.util.ArrayList; + public class Dice extends ServerMessage { + + private final int diceEye; + private final ArrayList moveablePieces; + + /** Constructor for Dice + * @param diceEye the eye of the dice + * @param moveablePieces the pieces that can be moved + */ + public Dice(int diceEye, ArrayList moveablePieces) { + this.diceEye = diceEye; + this.moveablePieces = moveablePieces; + } + + /** Constructor for inactivePlayer + * @param diceEye the eye of the dice + * @return a new Dice object + */ + public static Dice inactivePlayer(int diceEye) { + return new Dice(diceEye, null); + } + + /** Constructor for activePlayer + * @param diceEye the eye of the dice + * @param moveablePieces the pieces that can be moved + * @return a new Dice object + */ + public static Dice activePlayer(int diceEye, ArrayList moveablePieces) { + return new Dice(diceEye, moveablePieces); + } + + /** Getter for the eye of the dice + * @return the eye of the dice + */ + public int getDiceEye() { + return diceEye; + } + + /** Getter for the pieces that can be moved + * @return the pieces that can be moved + */ + public ArrayList getMoveablePieces() { + return moveablePieces; + } + @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java index db6a9bff..5d686153 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java @@ -1,6 +1,17 @@ package pp.mdga.message.server; public class LobbyPlayerJoin extends ServerMessage { + + private final String name; + + public LobbyPlayerJoin(String name) { + this.name = name; + } + + public String getName() { + return name; + } + @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java index 73b7535a..4f4ab6a3 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java @@ -1,6 +1,24 @@ package pp.mdga.message.server; +import pp.mdga.game.Color; + public class LobbyPlayerLeave extends ServerMessage { + + private final String name; + private final Color color; + + public LobbyPlayerLeave(String name, Color color) { + this.name = name; + this.color = color; + } + + public String getName() { + return name; + } + + public Color getColor() { + return color; + } @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java index 9f1cfc18..4a7a3a39 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java @@ -1,6 +1,26 @@ package pp.mdga.message.server; public class MoveMessage extends ServerMessage { + + private final String pieceIdentifier; + + /** + * @param identifier the identifier of the piece that should be moved + */ + public MoveMessage(String identifier) { + this.pieceIdentifier = identifier; + } + + /** + * @return the identifier of the piece that should be moved + */ + public String getIdentifier() { + return pieceIdentifier; + } + + /** + * @return the identifier of the piece that should be moved + */ @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java index 4886ecae..4b5f61ae 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java @@ -1,6 +1,34 @@ package pp.mdga.message.server; +import pp.mdga.game.BonusCard; + public class PlayCard extends ServerMessage { + + private final BonusCard card; + private final String pieceIdentifier; + + /** + * @param card the card that should be played + * @param pieceIdentifier the identifier of the piece that should be moved + */ + public PlayCard(BonusCard card, String pieceIdentifier) { + this.card = card; + this.pieceIdentifier = pieceIdentifier; + } + + /** + * @return the card that should be played + */ + public BonusCard getCard() { + return card; + } + + /** + * @return the identifier of the piece that should be moved + */ + public String getPieceIdentifier() { + return pieceIdentifier; + } @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java index ec45f934..d543b3c6 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java @@ -1,6 +1,33 @@ package pp.mdga.message.server; +import pp.mdga.game.BonusCard; + +import java.util.ArrayList; + public class PossibleCard extends ServerMessage { + + private ArrayList possibleCards; + + /** Constructor for PossibleCard + */ + public PossibleCard() { + possibleCards = new ArrayList<>(); + } + + /** Add a possible card to the list of possible cards + * @param card the possible card to add + */ + public void addPossibleCard(BonusCard card) { + this.possibleCards.add(card); + } + + /** Getter for the list of possible cards + * @return the list of possible cards + */ + public ArrayList getPossibleCards() { + return possibleCards; + } + @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java index 5f0f2786..d85b9453 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java @@ -1,6 +1,40 @@ package pp.mdga.message.server; +import java.util.ArrayList; + public class PossiblePiece extends ServerMessage { + + private final ArrayList possibleOwnPieces; + private final ArrayList possibleEnemyPieces; + + /** Constructor for PossiblePiece + */ + public PossiblePiece() { + possibleOwnPieces = new ArrayList<>(); + possibleEnemyPieces = new ArrayList<>(); + } + + /** Add a piece to the list of possible pieces + * @param piece the piece to add + */ + public void addOwnPossiblePiece(String piece) { + this.possibleOwnPieces.add(piece); + } + + /** Add a piece to the list of possible enemy pieces + * @param piece the piece to add + */ + public void addEnemyPossiblePiece(String piece) { + this.possibleEnemyPieces.add(piece); + } + + /** Getter for the list of possible pieces + * @return the list of possible pieces + */ + public ArrayList getPossiblePieces() { + return possibleOwnPieces; + } + @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java index 9ba5ae73..7910e2c2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java @@ -1,6 +1,18 @@ package pp.mdga.message.server; +import pp.mdga.game.Game; + public class ReconnectBriefing extends ServerMessage { + + private final Game game; + + public ReconnectBriefing(Game game) { + this.game = game; + } + + public Game getGame() { + return game; + } @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java index 5d9131c2..902c467b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java @@ -1,6 +1,17 @@ package pp.mdga.message.server; public class StartPiece extends ServerMessage { + + private final String pieceIdentifier; + + public StartPiece(String pieceIdentifier) { + this.pieceIdentifier = pieceIdentifier; + } + + public String getPieceIdentifier() { + return pieceIdentifier; + } + @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java index 95571da6..c7ad2593 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java @@ -1,6 +1,24 @@ package pp.mdga.message.server; +import pp.mdga.game.Color; + public class UpdateReady extends ServerMessage { + + private final Color color; + private final boolean ready; + + public UpdateReady(Color color, boolean ready) { + this.color = color; + this.ready = ready; + } + + public Color getColor() { + return color; + } + + public boolean isReady() { + return ready; + } @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java index 1cbf752d..c3d8e7fa 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java @@ -1,6 +1,24 @@ package pp.mdga.message.server; +import pp.mdga.game.Color; + public class UpdateTSK extends ServerMessage { + + private final String name; + private final Color color; + + public UpdateTSK(String name, Color color) { + this.name = name; + this.color = color; + } + + public String getName() { + return name; + } + + public Color getColor() { + return color; + } @Override public void accept(ServerInterpreter interpreter) { From 9ab71bfaf6b1b9d0c784bd901f2a7d3279581f40 Mon Sep 17 00:00:00 2001 From: Cedric Beck Date: Sun, 24 Nov 2024 10:34:48 +0100 Subject: [PATCH 09/44] merge dev/client_koppe into dev/client --- Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java index a9b56664..2f2e1638 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java @@ -15,7 +15,7 @@ public class MdgaApp extends SimpleApplication { private ModelSyncronizer modelSyncronizer; MdgaView view = null; - private MdgaState state = MdgaState.GAME; + private MdgaState state = MdgaState.MAIN; private static float resolutionFactor = 1f; From f425eff26bcb0f9150f2cc3c46908b212bbbc4ea Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 24 Nov 2024 15:27:10 +0100 Subject: [PATCH 10/44] added more logic for the server state diagram --- .../src/main/java/pp.mdga/game/Game.java | 21 +++++++++++++ .../pp.mdga/message/client/DeselectTSK.java | 12 ++++++++ .../pp.mdga/message/server/UpdateTSK.java | 1 + .../pp.mdga/server/DetermineStartPlayer.java | 7 +++-- .../src/main/java/pp.mdga/server/Lobby.java | 30 +++++++++++++++---- .../java/pp.mdga/server/ServerGameLogic.java | 14 +++++++++ .../pp.mdga/server/ServerStateMachine.java | 4 +-- .../src/main/java/pp.mdga/server/Turn.java | 2 +- 8 files changed, 80 insertions(+), 11 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java index 7807061f..427ea384 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java @@ -29,6 +29,8 @@ public class Game { private Boolean allRanked = false; private Boolean movablePieces = false; + private Boolean allReady = false; + private static final int AMOUNT_OF_TURBO_CARDS = 16; private static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12; @@ -397,6 +399,25 @@ public void setStartPlayer(Player startPlayer) { this.startPlayer = startPlayer; } + /** + * This method returns the all ready state. + * + * @return the all ready state + */ + public Boolean allReady() { + return allReady; + } + + /** + * This method sets the all ready state. + * + * @param allReady the new all ready state + */ + public void setAllReady(Boolean allReady) { + this.allReady = allReady; + if (allReady) notifyObservers(); + } + /** * This method notifies the observers. */ diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java index 21e0d39d..854c1995 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java @@ -1,6 +1,18 @@ package pp.mdga.message.client; +import pp.mdga.game.Color; + public class DeselectTSK extends ClientMessage { + private final Color color; + + public DeselectTSK(Color color) { + this.color = color; + } + + public Color getColor() { + return color; + } + @Override public String toString() { return "null"; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java index c3d8e7fa..e3280085 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java @@ -19,6 +19,7 @@ public String getName() { public Color getColor() { return color; } + @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java index 0ff4b48e..89020007 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Random; public class DetermineStartPlayer extends ServerState { private final List player = new ArrayList<>(); @@ -17,9 +18,9 @@ public DetermineStartPlayer(ServerState parent, ServerGameLogic logic) { @Override public void receivedRequestDice(RequestDice msg, int from) { - logic.send(); - - broadcastUpdate(new Dice()); + final Random random = new Random(); + final int dice = random.nextInt(6) + 1; + broadcastUpdate(new Dice(dice, new ArrayList<>())); } @Override diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java index a612f0f2..86da598f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java @@ -1,6 +1,9 @@ package pp.mdga.server; +import pp.mdga.game.Color; +import pp.mdga.game.Player; import pp.mdga.message.client.*; +import pp.mdga.message.server.ServerMessage; import pp.mdga.message.server.ServerStartGame; import pp.mdga.message.server.UpdateReady; import pp.mdga.message.server.UpdateTSK; @@ -26,7 +29,7 @@ public Lobby(ServerState parent, ServerGameLogic logic) { */ @Override public void receivedDeselectTSK(DeselectTSK msg, int from) { - broadcastUpdate(new UpdateTSK()); + broadcastUpdate(new UpdateTSK(logic.getPlayerById(from).getName(), msg.getColor())); } /** @@ -36,7 +39,7 @@ public void receivedDeselectTSK(DeselectTSK msg, int from) { */ @Override public void receivedNotReady(LobbyNotReady msg, int from) { - broadcastUpdate(new UpdateReady()); + broadcastUpdate(new UpdateReady(getPlayerColor(from), false)); } /** @@ -46,7 +49,24 @@ public void receivedNotReady(LobbyNotReady msg, int from) { */ @Override public void receivedReady(LobbyReady msg, int from) { - broadcastUpdate(new UpdateReady()); + broadcastUpdate(new UpdateReady(getPlayerColor(from), true)); + } + + /** + * Helper method to get the color associated with a player ID. + * + * @param playerId The ID of the player. + * @return The Color associated with the player, or null if not found. + */ + private Color getPlayerColor(int playerId) { + Player player = logic.getPlayerById(playerId); + + for (var entry : logic.getGame().getPlayers().entrySet()) { + if (entry.getValue().equals(player)) { + return entry.getKey(); + } + } + return null; } /** @@ -56,7 +76,7 @@ public void receivedReady(LobbyReady msg, int from) { */ @Override public void receivedSelectTSK(SelectTSK msg, int from) { - broadcastUpdate(new UpdateTSK()); + broadcastUpdate(new UpdateTSK(logic.getPlayerById(from).getName(), msg.getColor())); } /** @@ -66,7 +86,7 @@ public void receivedSelectTSK(SelectTSK msg, int from) { */ @Override public void receivedStartGame(ClientStartGame msg, int from) { - if (Boolean.TRUE.equals(logic.getGame().allRanked())) { + if (Boolean.TRUE.equals(logic.getGame().allReady())) { broadcastUpdate(new ServerStartGame()); parent.gotoState(new GameState(parent, logic)); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java index 2dbb77f5..64761cf6 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java @@ -125,6 +125,20 @@ public Game getGame() { return game; } + /** + * Returns the player representing the client with the specified connection ID. + * + * @param id the ID of the client + * @return the player associated with the client ID, or null if not found + */ + public Player getPlayerById(int id) { + for (var entry : game.getPlayers().entrySet()) + if (entry.getValue().getId() == id) + return entry.getValue(); + LOGGER.log(Logger.Level.ERROR, "no player found with connection {0}", id); //NON-NLS + return null; + } + public ServerState getState() { return state; } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java index a55c0ef0..7c30384e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java @@ -204,9 +204,9 @@ public void sentPossibleCard(PossibleCard msg, int from) { } /** - * This method is called when a RankingResponce message is sent. + * This method is called when a RankingResponse message is sent. * - * @param msg the RankingResponce message + * @param msg the RankingResponse message */ @Override public void sentRankingResponse(RankingResponce msg, int from) { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java index d2eacc7b..4be9f928 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java @@ -29,7 +29,7 @@ public void exit() { this.getParent().getParent().exit(); } else { // todo: next player - broadcastUpdate(new ActivePlayer()); + broadcastUpdate(new ActivePlayer(null)); parent.gotoState(new Animation(parent, logic)); } } From 2095ea5866e4d190eca71370f0325fce976eb8dc Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 15:49:01 +0100 Subject: [PATCH 11/44] editet tests for the server and client statemachines --- .../client/clientState/ClientStateTest.java | 1001 +++++++++++++++++ .../client/clientState/SettingsStateTest.java | 64 -- .../server/serverState/ServerStateTest.java | 303 ++++- 3 files changed, 1291 insertions(+), 77 deletions(-) create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java delete mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java new file mode 100644 index 00000000..8d8d23c7 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -0,0 +1,1001 @@ +package pp.mdga.client.clientState; + +import org.junit.Before; +import org.junit.Test; +import pp.mdga.client.*; +import pp.mdga.client.Ceremony; +import pp.mdga.client.StartPiece; +import pp.mdga.game.Game; +import pp.mdga.message.server.*; + + + +import static org.junit.Assert.assertTrue; + +/** + * this test-class tests the testcases T232-T239 + */ +public class ClientStateTest { + + + + //sets the variables for the states + private Animation animation; + private AudioSettings audioSettings; + private Ceremony ceremony; + private CeremonyStateMachine ceremonyStateMachine; + private ChoosePiece choosePiece; + private ChoosePieceStateMachine choosePieceStateMachine; + private ChoosePowerCard choosePowerCard; + private ClientAutomaton clientAutomaton; + private ClientGameLogic clientGameLogic; + private DetermineStartPlayer determineStartPlayer; + private DetermineStartPlayerStateMachine determineStartPlayerStateMachine; + private Dialogs dialogs; + private DialogsStateMachine dialogsStateMachine; + private GameState gameState; + private GameStateMachine gameStateMachine; + private Interrupt interrupt; + private Lobby lobby; + private MainSettings mainSettings; + private MovePiece movePiece; + private NetworkDialog networkDialog; + private NoPiece noPiece; + private PlayPowerCard playPowerCard; + private Podium podium; + private PowerCard powerCard; + private PowerCardStateMachine powerCardStateMachine; + private RollDice rollDice; + private RollRankingDice rollRankingDice; + private SelectPiece selectPiece; + private Settings settings; + private SettingsStateMachine settingsStateMachine; + private Shield shield; + private Spectator spectator; + private StartDialog startDialog; + private StartPiece startPiece; + private Statistics statistics; + private Swap swap; + private Turn turn; + private TurnStateMachine turnStateMachine; + private VideoSettings videoSettings; + private Waiting waiting; + private WaitingPiece waitingPiece; + private WaitRanking waitRanking; + + //sets the variables for the messages + private ActivePlayer activePlayer; + private AnyPiece anyPiece; + private Briefing briefing; + private Ceremony ceremonyMessage; + private Dice dice; + private DiceAgain diceAgain; + private DiceNow diceNow; + private EndOfTurn endOfTurn; + private LobbyAccept lobbyAccept; + private LobbyDeny lobbyDeny; + private LobbyPlayerJoin lobbyPlayerJoin; + private LobbyPlayerLeave lobbyPlayerLeave; + private MoveMessage moveMessage; + private NoTurn noTurn; + private PauseGame pauseGame; + private PlayCard playCard; + private PossibleCard possibleCard; + private PossiblePiece possiblePiece; + private RankingResponce rankingResponce; + private RankingRollAgain rankingRollAgain; + private ReconnectBriefing reconnectBriefing; + private ResumeGame resumeGame; + private StartPiece startPieceMessage; + private UpdateReady updateReady; + private UpdateTSK updateTSK; + private WaitPiece waitPiece; + + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Client State transitions. + + //initialize the messages from the server + activePlayer = new ActivePlayer(); + anyPiece = new AnyPiece(); + briefing = new Briefing(); + ceremonyMessage = new Ceremony(); + dice = new Dice(); + diceAgain = new DiceAgain(); + diceNow = new DiceNow(); + endOfTurn = new EndOfTurn(); + lobbyAccept = new LobbyAccept(); + lobbyDeny = new LobbyDeny(); + lobbyPlayerJoin = new LobbyPlayerJoin(); + lobbyPlayerLeave = new LobbyPlayerLeave(); + moveMessage = new MoveMessage(); + noTurn = new NoTurn(); + pauseGame = new PauseGame(); + playCard = new PlayCard(); + possibleCard = new PossibleCard(); + possiblePiece = new PossiblePiece(); + rankingResponce = new RankingResponce(); + rankingRollAgain = new RankingRollAgain(); + reconnectBriefing = new ReconnectBriefing(); + resumeGame = new ResumeGame(); + startPieceMessage = new StartPiece(); + updateReady = new UpdateReady(); + updateTSK = new UpdateTSK(); + waitPiece = new WaitPiece(); + + //initialize the clientGameLogic + clientGameLogic = new ClientGameLogic(); + clientAutomaton = (ClientAutomaton) clientGameLogic.getState(); + + //initialize the settings + mainSettings = new MainSettings(); + videoSettings = new VideoSettings(); + audioSettings = new AudioSettings(); + settings = new Settings(); + + + //initialize the stateMachines + ceremonyStateMachine =ceremony.getCeremonyStateMachine(); + choosePieceStateMachine = choosePiece.getChoosePieceMachine(); + determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerMachine(); + dialogsStateMachine = dialogs.getDialogsStateMachine(); + gameStateMachine = gameState.getGameStateMachine(); + powerCardStateMachine = powerCard.getPowerCardMachine(); + settingsStateMachine = settings.getSettingsStateMachine(); + turnStateMachine = turn.getTurnMachine(); + + + //initialize the states + dialogs = new Dialogs(clientAutomaton,clientGameLogic); + gameState = new GameState(clientAutomaton,clientGameLogic); + ceremony = new Ceremony(clientAutomaton,clientGameLogic); + interrupt = new Interrupt(clientAutomaton,clientGameLogic,gameState); + + startDialog = new StartDialog(dialogsStateMachine,clientGameLogic); + networkDialog = new NetworkDialog(dialogsStateMachine,clientGameLogic); + lobby = new Lobby(dialogsStateMachine,clientGameLogic); + + podium = new Podium(ceremonyStateMachine,clientGameLogic); + statistics = new Statistics(ceremonyStateMachine,clientGameLogic); + + determineStartPlayer = new DetermineStartPlayer(gameStateMachine,clientGameLogic); + waiting= new Waiting(gameStateMachine,clientGameLogic); + animation = new Animation(gameStateMachine,clientGameLogic); + turn = new Turn(gameStateMachine,clientGameLogic); + spectator = new Spectator(gameStateMachine,clientGameLogic); + + rollRankingDice = new RollRankingDice(determineStartPlayerStateMachine,clientGameLogic); + waitRanking = new WaitRanking(determineStartPlayerStateMachine,clientGameLogic); + + powerCard = new PowerCard(turnStateMachine,clientGameLogic); + playPowerCard = new PlayPowerCard(turnStateMachine,clientGameLogic); + rollDice= new RollDice(turnStateMachine,clientGameLogic); + choosePiece = new ChoosePiece(turnStateMachine,clientGameLogic); + movePiece = new MovePiece(turnStateMachine,clientGameLogic); + + choosePowerCard = new ChoosePowerCard(powerCardStateMachine,clientGameLogic); + shield =new Shield(powerCardStateMachine,clientGameLogic); + swap = new Swap(powerCardStateMachine,clientGameLogic); + + noPiece = new NoPiece(choosePieceStateMachine,clientGameLogic); + waitingPiece = new WaitingPiece(choosePieceStateMachine,clientGameLogic); + selectPiece = new SelectPiece(choosePieceStateMachine,clientGameLogic); + startPiece = new StartPiece(choosePieceStateMachine,clientGameLogic); + } + + /** + * UC-ClientState-01: Test the initial state of the ClientState. + */ + @Test + public void testInitialStateClientState() { + //tests if the clientAutomaton is in Dialogs + assertTrue(clientAutomaton.getState() instanceof Dialogs); + //tests if the statemachine is in StartDialog + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + } + + /** + * UC-ClientState-02: Test the transition from dialogs to the game state. + */ + @Test + public void testDialogsToGame() { + //TODO + //tests if the client is in Dialogs + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the startGame-Message to the client + clientGameLogic.receive(startGame); + + //tests if the client is in the gameState after receiving the message + assertTrue(clientAutomaton.getState() instanceof GameState); + + //tests if the new State of the GameStateMachine is in DetermineStartPlayer + GameState gameState1= clientAutomaton.getState(); + GameStateMachine gameStateMachine1 = (GameStateMachine) gameState1.getState(); + assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); + + //tests if the new State of DetermineStartPlayer is RollRankingDice + DetermineStartPlayer determineStartPlayer1=(DetermineStartPlayer) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = (DetermineStartPlayerStateMachine) determineStartPlayer1.getState(); + assertTrue(DetermineStartPlayerStateMachine.getState() instanceof RollRankingDice); + } + + /** + * UC-ClientState-03: Test the transition from dialogs to the end state of ClientState . + */ + @Test + public void testDialogsToClientStateEndState() { + //Todo Implementation goes here + } + + /** + * UC-ClientState-04: Test the transition from ClientGame to Ceremony. + */ + @Test + public void testClientGameToCeremony() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the Ceremony-Message to the client + clientGameLogic.receive(ceremonyMessage); + + //tests if the client is in the ceremony after receiving the message + assertTrue(clientAutomaton.getState() instanceof Ceremony); + + //tests if the state of ceremony is Podium + Ceremony ceremony1 = (Ceremony) clientAutomaton.getState(); + CeremonyStateMachine ceremonyStateMachine1 = (CeremonyStateMachine) ceremony1.getState(); + assertTrue(ceremonyStateMachine1.getState() instanceof Podium); + } + + /** + * UC-ClientState-05: Test the transition from ClientGame substates to Interrupt. + */ + @Test + public void testClientGameSubStatesToInterrupt() { + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the Ceremony-Message to the client + clientGameLogic.receive(interrupt); + + //tests if the client-automaton is in the interrupt state + assertTrue(clientAutomaton.getState() instanceof Interrupt); + } + + /** + * UC-ClientState-06: Test the transition from the game state to dialogs. + */ + @Test + public void testGameToDialogs() { + // Todo Implementation goes here + } + + /** + * UC-ClientState-07: Test remaining in the Interrupt state. + */ + @Test + public void testStayInInterrupt() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(interrupt); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo + } + + /** + * UC-ClientState-08: Test the transition from ClientInterrupt to the game state. + */ + @Test + public void testClientInterruptToGame() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(interrupt); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo + } + + /** + * UC-ClientState-09: Test the transition from Interrupt to dialogs. + */ + @Test + public void testInterruptToDialogs() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(interrupt); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo + } + + /** + * UC-ClientState-10: Test the transition from Ceremony to dialogs. + */ + @Test + public void testCeremonyToDialogs() { + // Todo Implementation goes here + //send the client in the ceremony + clientAutomaton.goto(ceremony); + assertTrue(clientAutomaton.getStates() instanceof Ceremony); + + //Todo + } + + /** + * UC-ClientState-11: Test the transition from StartDialog to NetworkDialog1. + */ + @Test + public void testStartDialogToNetworkDialog1() { + // Implementation goes here + } + + /** + * UC-ClientState-12: Test the transition from StartDialog to NetworkDialog2. + */ + @Test + public void testStartDialogToNetworkDialog2() { + // Implementation goes here + } + + /** + * UC-ClientState-13: Test the transition from StartDialog to the dialogs end state. + */ + @Test + public void testStartDialogToDialogsEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-14: Test the transition from NetworkDialog to StartDialog. + */ + @Test + public void testNetworkDialogToStartDialog() { + // Implementation goes here + } + + /** + * UC-ClientState-15: Test the transition from NetworkDialog to NetworkDialog1. + */ + @Test + public void testNetworkDialogToNetworkDialog1() { + // Implementation goes here + } + + /** + * UC-ClientState-16: Test the transition from NetworkDialog to NetworkDialog2. + */ + @Test + public void testNetworkDialogToNetworkDialog2() { + // Implementation goes here + } + + /** + * UC-ClientState-17: Test the transition from NetworkDialog to Lobby. + */ + @Test + public void testNetworkDialogToLobby() { + // Implementation goes here + } + + /** + * UC-ClientState-18: Test the transition from Lobby to StartDialog. + */ + @Test + public void testLobbyToStartDialog() { + // Implementation goes here + } + + /** + * UC-ClientState-19: Test remaining in the Lobby state. + */ + @Test + public void testStayInLobby() { + // Implementation goes here + } + + /** + * UC-ClientState-20: Test the transition from Lobby to RollRankingDice. + */ + @Test + public void testLobbyToRollRankingDice() { + // Implementation goes here + } + + /** + * UC-ClientState-21: Test the transition from DetermineStartPlayer to Wait. + */ + @Test + public void testDetermineStartPlayerToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-22: Test the transition from Wait to Animation. + */ + @Test + public void testWaitToAnimation() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the client in WaitState + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(waiting); + assertTrue(gameStateMachine1.getState() instanceof Waiting); + + //tests if a piece is moved,that the client goes into Animation + clientGameLogic.receive(moveMessage); //Todo ??? richtige message + assertTrue(gameStateMachine1.getState() instanceof Animation); + + //sends the client in WaitState + gameStateMachine1.goto(waiting); + assertTrue(gameStateMachine1.getState() instanceof Waiting); + + //tests if a powerCard is played,that the client goes into Animation + clientGameLogic.receive(playCard); //Todo ??? richtige message + assertTrue(gameStateMachine1.getState() instanceof Animation); + + //sends the client in WaitState + gameStateMachine1.goto(waiting); + assertTrue(gameStateMachine1.getState() instanceof Waiting); + + //tests if a die is rolled,that the client goes into Animation + clientGameLogic.receive(dice); //Todo ??? richtige message + assertTrue(gameStateMachine1.getState() instanceof Animation); + } + + /** + * UC-ClientState-23: Test the transition from Wait to Turn. + */ + @Test + public void testWaitToTurn() { + //TODo + //sends client in gameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(wait); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //the client receives the message ActivePlayer + clientGameLogic.receive(activePlayer); + + //tests if Client is in Turn + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //tests if Client is in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //tests if Client is in ChoosePowerCard + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + } + + /** + * UC-ClientState-24: Test the transition from Wait to GameEndState. + */ + @Test + public void testWaitToGameEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-25: Test the transition from Turn substates to GameEndState. + */ + @Test + public void testTurnSubStatesToGameEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-26: Test the transition from Turn sub-states to Wait. + */ + @Test + public void testTurnSubStatesToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-27: Test the transition from Turn sub-states to Spectator. + */ + @Test + public void testTurnSubStatesToSpectator() { + // Implementation goes here + } + + /** + * UC-ClientState-28: Test the transition from Spectator to GameEndState. + */ + @Test + public void testSpectatorToGameEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-29: Test the transition from PowerCard sub-states to PlayPowerCard. + */ + @Test + public void testPowerCardSubStatesToPlayPowerCard() { + // Implementation goes here + } + + /** + * UC-ClientState-30: Test the transition from PowerCard sub-states to RollDice. + */ + @Test + public void testPowerCardSubStatesToRollDice() { + // Implementation goes here + } + + /** + * UC-ClientState-31: Test staying in the PlayPowerCard state. + */ + @Test + public void testStayInPlayPowerCard() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PlayPowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(playPowerCard); + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + + //Todo send messages to test to stay in playPowerCard + + } + + /** + * UC-ClientState-32: Test the transition from PlayPowerCard to RollDice. + */ + @Test + public void testPlayPowerCardToRollDice() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PlayPowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(playPowerCard); + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + + //Todo send messages to test the transition in rollDice + //Todo test other messages, that there is no state change + + } + + /** + * UC-ClientState-33: Test staying in the RollDice state. + */ + @Test + public void testStayInRollDice() { + // Implementation goes here + } + + /** + * UC-ClientState-34: Test the transition from RollDice to ChoosePiece. + */ + @Test + public void testRollDiceToChoosePiece() { + // Implementation goes here + } + + /** + * UC-ClientState-35: Test the transition from RollDice to Wait. + */ + @Test + public void testRollDiceToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-36: Test the transition from ChoosePiece to Wait. + */ + @Test + public void testChoosePieceToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-37: Test the transition from ChoosePiece to MovePiece. + */ + @Test + public void testChoosePieceToMovePiece() { + // Implementation goes here + } + + /** + * UC-ClientState-38: Test the transition from MovePiece to Wait. + */ + @Test + public void testMovePieceToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-39: Test the transition from MovePiece to Spectator. + */ + @Test + public void testMovePieceToSpectator() { + // Implementation goes here + } + + /** + * UC-ClientState-40: Test the transition from MovePiece to Ceremony. + */ + @Test + public void testMovePieceToCeremony() { + // Implementation goes here + } + + /** + * UC-ClientState-41: Test staying in the ChoosePowerCard state. + */ + @Test + public void testStayInChoosePowerCard() { + // Implementation goes here + } + + /** + * UC-ClientState-42: Test the transition from ChoosePowerCard to RollDice. + */ + @Test + public void testChoosePowerCardToRollDice() { + // Implementation goes here + } + + /** + * UC-ClientState-43: Test the transition from ChoosePowerCard to Swap. + */ + @Test + public void testChoosePowerCardToSwap() { + // Implementation goes here + } + + /** + * UC-ClientState-44: Test the transition from ChoosePowerCard to Shield. + */ + @Test + public void testChoosePowerCardToShield() { + // Implementation goes here + } + + /** + * UC-ClientState-45: Test staying in the Shield state. + */ + @Test + public void testStayInShield() { + // Implementation goes here + } + + /** + * UC-ClientState-46: Test the transition from Shield to PowerCardEndState. + */ + @Test + public void testShieldToPowerCardEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-47: Test the transition from Swap to PowerCardEndState. + */ + @Test + public void testSwapToPowerCardEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-48: Test no piece in WaitingPiece state. + */ + @Test + public void testNoPieceInWaitingPiece() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message WaitPiece + clientGameLogic.receive(waitPiece); + + assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + } + + /** + * UC-ClientState-49: Test no piece in SelectedPiece state. + */ + @Test + public void testNoPieceInSelectedPiece() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message SelectPiece + clientGameLogic.receive(selectPiece); + + assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + } + + /** + * UC-ClientState-50: Test no piece in StartPiece state. + */ + @Test + public void testNoPieceInStartPiece() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message StartPiece + clientGameLogic.receive(startPiece); + + assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + } + + /** + * UC-ClientState-51: Test no piece in Wait state. + */ + @Test + public void testNoPieceInWait() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message NoTurn + clientGameLogic.receive(noTurn); + + assertTrue(turnStateMachine1.getState() instanceof Waiting); + } + + /** + * UC-ClientState-52: Test staying in the WaitingPiece state. + */ + @Test + public void testStayInWaitingPiece() { + // Implementation goes here + } + + /** + * UC-ClientState-53: Test the WaitingPiece to ChoosePiece end state. + */ + @Test + public void testWaitingPieceInChoosePieceEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-54: Test staying in the SelectedPiece state. + */ + @Test + public void testStayInSelectedPiece() { + // Implementation goes here + } + + /** + * UC-ClientState-55: Test the SelectedPiece to ChoosePiece end state. + */ + @Test + public void testSelectedPieceInChoosePieceEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-56: Test staying in the StartPiece state. + */ + @Test + public void testStayInStartPiece() { + // Implementation goes here + } + + /** + * UC-ClientState-57: Test the StartPiece to ChoosePiece end state. + */ + @Test + public void testStartPieceToChoosePieceEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-58: Test the transition from RollRankingDice to WaitRanking. + */ + @Test + public void testRollRankingDiceToWaitRanking() { + // Implementation goes here + } + + /** + * UC-ClientState-59: Test the transition from WaitRanking to RollRankingDice. + */ + @Test + public void testWaitRankingToRollRankingDice() { + // Implementation goes here + } + + /** + * UC-ClientState-60: Test the transition from WaitRanking to the EndState of determining the starting player. + */ + @Test + public void testWaitRankingToEndStateDetermineStartingPlayer() { + // Implementation goes here + } + + /** + * UC-ClientState-61: Test the transition from Podium to Statistics. + */ + @Test + public void testPodiumToStatistics() { + // Implementation goes here + } + + /** + * UC-ClientState-62: Test the transition from Statistics to the Ceremony end state. + */ + @Test + public void testStatisticsToCeremonyEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-63: Test the transition from MainSettings to VideoSettings. + */ + @Test + public void testMainSettingsToVideoSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-64: Test the transition from MainSettings to AudioSettings. + */ + @Test + public void testMainSettingsToAudioSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-65: Test the transition from MainSettings to ClientState. + */ + @Test + public void testMainSettingsToClientState() { + // Implementation goes here + } + + /** + * UC-ClientState-66: Test staying in the VideoSettings state. + */ + @Test + public void testStayInVideoSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-67: Test the transition from VideoSettings to MainSettings. + */ + @Test + public void testVideoSettingsToMainSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-68: Test staying in the AudioSettings state. + */ + @Test + public void testStayInAudioSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-69: Test the transition from AudioSettings to MainSettings. + */ + @Test + public void testAudioSettingsToMainSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-70: Test the transition from ClientState substates to MainSettings. + */ + @Test + public void testClientStateSubStatesToMainSettings() { + // Implementation goes here + } + +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java deleted file mode 100644 index 43444c3f..00000000 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package pp.mdga.client.clientState; - -import org.junit.Before; -import org.junit.Test; - -/** - * this test-class tests the testcases T232-T239 - */ -public class SettingsStateTest { - - @Before - public void setUp() { - // This method will be executed before each test. - // Initialize common objects or setup required state for Client State transitions. - } - - // UC-ClientState-63 - @Test - public void testMainSettingsToVideoSettings() { - // TODO: Implement test logic for transitioning from Main Settings to Video Settings - } - - // UC-ClientState-64 - @Test - public void testMainSettingsToAudioSettings() { - // TODO: Implement test logic for transitioning from Main Settings to Audio Settings - } - - // UC-ClientState-65 - @Test - public void testMainSettingsToClientState() { - // TODO: Implement test logic for transitioning from Main Settings to a generic Client State - } - - // UC-ClientState-66 - @Test - public void testStayInVideoSettings() { - // TODO: Implement test logic for staying in Video Settings - } - - // UC-ClientState-67 - @Test - public void testVideoSettingsToMainSettings() { - // TODO: Implement test logic for transitioning from Video Settings to Main Settings - } - - // UC-ClientState-68 - @Test - public void testStayInAudioSettings() { - // TODO: Implement test logic for staying in Audio Settings - } - - // UC-ClientState-69 - @Test - public void testAudioSettingsToMainSettings() { - // TODO: Implement test logic for transitioning from Audio Settings to Main Settings - } - - // UC-ClientState-70 - @Test - public void testClientStateSubStatesToMainSettings() { - // TODO: Implement test logic for transitioning from any sub-state of the client to Main Settings - } -} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 8b76956c..10bf1239 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -2,29 +2,243 @@ import org.junit.Before; import org.junit.Test; +import pp.mdga.game.Game; +import pp.mdga.message.client.AnimationEnd; +import pp.mdga.message.client.ClientMessage; +import pp.mdga.message.client.ClientStartGame; +import pp.mdga.message.client.DeselectTSK; +import pp.mdga.message.client.ForceContinueGame; +import pp.mdga.message.client.ForceStartGame; +import pp.mdga.message.client.JoinServer; +import pp.mdga.message.client.LeaveGame; +import pp.mdga.message.client.LobbyNotReady; +import pp.mdga.message.client.LobbyReady; +import pp.mdga.message.client.NoPowerCard; +import pp.mdga.message.client.RequestBriefing; +import pp.mdga.message.client.RequestDice; +import pp.mdga.message.client.RequestMove; +import pp.mdga.message.client.RequestPlayCard; +import pp.mdga.message.client.SelectCard; +import pp.mdga.message.client.SelectTSK; +import pp.mdga.message.client.SelectedPieces; +import pp.mdga.message.server.ServerMessage; +import pp.mdga.server.Animation; +import pp.mdga.server.Ceremony; +import pp.mdga.server.ChoosePiece; +import pp.mdga.server.ChoosePieceStateMachine; +import pp.mdga.server.DetermineStartPlayer; +import pp.mdga.server.FirstRoll; +import pp.mdga.server.GameState; +import pp.mdga.server.GameStateMachine; +import pp.mdga.server.Interrupt; +import pp.mdga.server.Lobby; +import pp.mdga.server.MovePiece; +import pp.mdga.server.NoPiece; +import pp.mdga.server.PlayPowerCard; +import pp.mdga.server.PowerCard; +import pp.mdga.server.RollDice; +import pp.mdga.server.RollDiceMachine; +import pp.mdga.server.SecondRoll; +import pp.mdga.server.SelectPiece; +import pp.mdga.server.ServerAutomaton; import pp.mdga.server.ServerGameLogic; +import pp.mdga.server.ServerSender; +import pp.mdga.server.NoTurn; import pp.mdga.server.ServerState; +import pp.mdga.server.StartPiece; +import pp.mdga.server.ThirdRoll; +import pp.mdga.server.Turn; +import pp.mdga.server.TurnStateMachine; +import pp.mdga.server.WaitingPiece; + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class ServerStateTest { + private ServerGameLogic logic; + private AnimationEnd animationEnd; + private ClientStartGame clientStartGame; + private DeselectTSK deselectTSK; + private ForceContinueGame forceContinueGame; + private ForceStartGame forceStartGame; + private JoinServer joinServer; + private LeaveGame leaveGame; + private LobbyNotReady lobbyNotReady; + private LobbyReady lobbyReady; + private NoPowerCard noPowerCard; + private RequestBriefing requestBriefing; + private RequestDice requestDice; + private RequestMove requestMove; + private RequestPlayCard requestPlayCard; + private SelectCard selectCard; + private SelectedPieces selectedPieces; + private SelectTSK selectTSK; + private ClientMessage[] clientMessages; + private int from; + + private GameStateMachine gameStateMachine; + private TurnStateMachine turnStateMachine; + private RollDiceMachine rollDiceMachine; + private ChoosePieceStateMachine choosePieceStateMachine; + private ServerAutomaton serverAutomaton; + + //TODO + private Animation animation; + private Ceremony ceremony; + private ChoosePiece choosePiece; + private DetermineStartPlayer determineStartPlayer; + private FirstRoll firstRoll; + private GameState gameState; + private Interrupt interrupt; + private Lobby lobby; + private MovePiece movePiece; + private NoPiece noPiece; + private NoTurn noTurn; + private PlayPowerCard playPowerCard; + private PowerCard powerCard; + private RollDice rollDice; + private SecondRoll secondRoll; + private SelectPiece selectPiece; + private StartPiece startPiece; + private ThirdRoll thirdRoll; + private Turn turn; + private WaitingPiece waitingPiece; + @Before - public void setUp(){ - ServerGameLogic logic = new ServerGameLogic(); + public void setUp() { + + logic = new ServerGameLogic(new Game(), new ServerSender() { + @Override + public void send(int id, ServerMessage msg) { + + } + }); + animationEnd = new AnimationEnd(); + clientStartGame = new ClientStartGame(); + deselectTSK = new DeselectTSK(); + forceContinueGame = new ForceContinueGame(); + forceStartGame = new ForceStartGame(); + joinServer = new JoinServer(); + leaveGame = new LeaveGame(); + lobbyReady = new LobbyReady(); + noPowerCard = new NoPowerCard(); + requestBriefing = new RequestBriefing(); + requestDice = new RequestDice(); + requestMove = new RequestMove(); + requestPlayCard = new RequestPlayCard(); + selectCard = new SelectCard(); + selectedPieces = new SelectedPieces(); + selectTSK = new SelectTSK(); + clientMessages = new ClientMessage[]{ + animationEnd, + clientStartGame, + deselectTSK, + forceContinueGame, + forceStartGame, + joinServer, + leaveGame, + lobbyReady, + noPowerCard, + requestBriefing, + requestDice, + requestMove, + requestPlayCard, + selectCard, + selectedPieces, + selectTSK + }; + from=1234; + + choosePieceStateMachine = choosePiece.getChoosePieceMachine(); + rollDiceMachine = rollDice.getRollDicemachine(); + turnStateMachine = turn.getTurnStatemachine(); + serverAutomaton = new ServerAutomaton(logic); + gameStateMachine = gameState.getGameStatemachine(); + + thirdRoll = new ThirdRoll(rollDiceMachine,logic); + secondRoll = new SecondRoll(rollDiceMachine,logic); + firstRoll = new FirstRoll(rollDiceMachine,logic); + + noPiece = new NoPiece(choosePieceStateMachine,logic); + noTurn = new NoTurn(choosePieceStateMachine,logic); + waitingPiece = new WaitingPiece(choosePieceStateMachine,logic); + startPiece = new StartPiece(choosePieceStateMachine,logic); + selectPiece = new SelectPiece(choosePieceStateMachine,logic); + + powerCard = new PowerCard(turnStateMachine,logic); + playPowerCard = new PlayPowerCard(turnStateMachine,logic); + rollDice = new RollDice(turnStateMachine,logic); + choosePiece = new ChoosePiece(turnStateMachine,logic); + movePiece = new MovePiece(turnStateMachine,logic); + + determineStartPlayer = new DetermineStartPlayer(gameStateMachine,logic); + turn = new Turn(gameStateMachine,logic); + animation = new Animation(gameStateMachine,logic); + + lobby = new Lobby(serverAutomaton,logic); + gameState = new GameState(serverAutomaton,logic); + ceremony = new Ceremony(serverAutomaton,logic); + interrupt = new Interrupt(serverAutomaton,logic,gameState); } @Test public void testInitialStateServerState() { - + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof Lobby); } @Test public void testLobbyToDetermineStartPlayer() { - // TODO: Implement test logic for transition from Lobby to Determine Start Player + //tests if Server is in State Lobby + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof Lobby); + Lobby lobby = (Lobby) automaton.getState(); + //tests, when not all players are ready and the hosts send clientStartGame, that the Server stays in Lobby + //TODO set one player not ready + lobby.receivedStartGame(clientStartGame, from); + assertTrue(automaton.getState() instanceof Lobby); + //tests, when all players are ready and the hosts send clientStartGame, that the Server changes to DSP + //TODO set all player Ready + lobby.receivedStartGame(clientStartGame, from); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof DetermineStartPlayer); } @Test public void testStayInLobby() { - // TODO: Implement test logic for staying in the Lobby + //tests if Server is in State Lobby + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof Lobby); + + //lobby gets all possible messages + Lobby lobby = (Lobby) automaton.getState(); + + //logic gets all messages + logic.received(animationEnd, from); + logic.received(clientStartGame, from); + logic.received(deselectTSK, from); + logic.received(forceContinueGame, from); + logic.received(forceStartGame, from); + logic.received(joinServer, from); + logic.received(leaveGame, from); + logic.received(lobbyReady, from); + logic.received(noPowerCard, from); + logic.received(requestBriefing, from); + logic.received(requestDice, from); + logic.received(requestMove, from); + logic.received(requestPlayCard, from); + logic.received(selectCard, from); + logic.received(selectedPieces, from); + logic.received(selectTSK, from); + + //tests if Server is still in Lobby + assertTrue(automaton.getState() instanceof Lobby); } @Test @@ -35,11 +249,26 @@ public void testServerGameSubStatesToInterrupt() { @Test public void testServerGameToCeremony() { // TODO: Implement test logic for transition from Server Game to Ceremony + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof Lobby); + Lobby lobby = (Lobby) automaton.getState(); + //Todo set all players ready + logic.received(clientStartGame, from); + assertTrue(automaton.getState() instanceof GameState); + //Todo game is finished + assertTrue(automaton.getState() instanceof Ceremony); } @Test public void testInterruptToGameContinue() { - // TODO: Implement test logic for transition from Interrupt to Game Continue + //sends the server into the interrupt + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + automaton.gotoState(interrupt); + assertTrue(automaton.getState() instanceof Interrupt); + //sends the continue-message to the server + logic.received(forceContinueGame, from); + //tests if new Stet is in GameState + assertTrue(automaton.getState() instanceof GameState); } @Test @@ -58,23 +287,71 @@ public void testCeremonyToServerStateEndState() { } @Test - public void testDeterminStartPlayerToDetermineStartPlayer1() { - // TODO: Implement test logic for Determine Start Player to Determine Start Player (Variant 1) + public void testDetermineStartPlayerToDetermineStartPlayer1() { + // Implement test logic for Determine Start Player to Determine Start Player (Variant 1) + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof GameStateMachine); + GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + + logic.received(requestDice, from); + + assertTrue(automaton.getState() instanceof DetermineStartPlayer); + } @Test - public void testDeterminStartPlayerToDetermineStartPlayer2() { - // TODO: Implement test logic for Determine Start Player to Determine Start Player (Variant 2) + public void testDetermineStartPlayerToDetermineStartPlayer2() { + // Implement test logic for Determine Start Player to Determine Start Player (Variant 2) + // sends the server in determineStartPlayer + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof GameStateMachine); + GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + //Todo: input same dices for both players + logic.received(requestDice, from); + logic.received(requestDice, 1235); + assertTrue(automaton.getState() instanceof DetermineStartPlayer); } @Test - public void testDeterminStartPlayerToAnimation() { - // TODO: Implement test logic for Determine Start Player to Animation + public void testDetermineStartPlayerToAnimation() { + // Implement test logic for Determine Start Player to Determine Start Player (Variant 2) + // sends the server in determineStartPlayer + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof GameStateMachine); + GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + //Todo: input different dices for both players + logic.received(requestDice, from); + logic.received(requestDice, 1235); + assertTrue(automaton.getState() instanceof Animation); } @Test public void testAnimationToPowerCard() { - // TODO: Implement test logic for transition from Animation to Power Card + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof GameStateMachine); + GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + //Todo: input different dices for both players + logic.received(requestDice, from); + logic.received(requestDice, 1235); + assertTrue(automaton.getState() instanceof Animation); + logic.received(animationEnd, from); + assertTrue(gameStateMachine.getState() instanceof Animation); + logic.received(animationEnd, 1235); + assertTrue(gameStateMachine.getState() instanceof Turn); + TurnStateMachine turnStateMachine = (TurnStateMachine) automaton.getState(); + assertTrue(turnStateMachine.getState() instanceof PowerCard); } @Test From 1d4048cf163d8842401c4c278216a7be4e4098a1 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sun, 24 Nov 2024 16:02:04 +0100 Subject: [PATCH 12/44] added the constructors for all client states and their statemachines --- .../main/java/pp.mdga/client/Animation.java | 3 ++ .../java/pp.mdga/client/AudioSettings.java | 3 ++ .../main/java/pp.mdga/client/Ceremony.java | 7 +++- .../pp.mdga/client/CeremonyStateMachine.java | 10 +++++ .../main/java/pp.mdga/client/ChoosePiece.java | 7 +++- .../client/ChoosePieceStateMachine.java | 8 ++++ .../java/pp.mdga/client/ChoosePowerCard.java | 3 ++ .../java/pp.mdga/client/ClientAutomaton.java | 10 +++++ .../java/pp.mdga/client/ClientGameLogic.java | 32 ++++++++++++++ .../java/pp.mdga/client/ClientSender.java | 7 ++++ .../main/java/pp.mdga/client/ClientState.java | 31 +++++++++++++- .../pp.mdga/client/ClientStateMachine.java | 42 +++++++++++++++++++ .../pp.mdga/client/DetermineStartPlayer.java | 7 +++- .../DetermineStartPlayerStateMachine.java | 8 ++++ .../src/main/java/pp.mdga/client/Dialogs.java | 7 +++- .../pp.mdga/client/DialogsStateMachine.java | 8 ++++ .../main/java/pp.mdga/client/GameState.java | 7 +++- .../java/pp.mdga/client/GameStateMachine.java | 8 ++++ .../main/java/pp.mdga/client/Interrupt.java | 10 +++++ .../src/main/java/pp.mdga/client/Lobby.java | 3 ++ .../java/pp.mdga/client/MainSettings.java | 3 ++ .../main/java/pp.mdga/client/MovePiece.java | 3 ++ .../java/pp.mdga/client/NetworkDialog.java | 3 ++ .../src/main/java/pp.mdga/client/NoPiece.java | 3 ++ .../main/java/pp.mdga/client/Observer.java | 5 +++ .../java/pp.mdga/client/PlayPowerCard.java | 3 ++ .../src/main/java/pp.mdga/client/Podium.java | 3 ++ .../main/java/pp.mdga/client/PowerCard.java | 7 +++- .../pp.mdga/client/PowerCardStateMachine.java | 8 ++++ .../main/java/pp.mdga/client/RollDice.java | 3 ++ .../java/pp.mdga/client/RollRankingDice.java | 3 ++ .../main/java/pp.mdga/client/SelectPiece.java | 3 ++ .../main/java/pp.mdga/client/Settings.java | 7 +++- .../pp.mdga/client/SettingsStateMachine.java | 8 ++++ .../src/main/java/pp.mdga/client/Shield.java | 3 ++ .../main/java/pp.mdga/client/Spectator.java | 3 ++ .../main/java/pp.mdga/client/StartDialog.java | 3 ++ .../main/java/pp.mdga/client/StartPiece.java | 3 ++ .../main/java/pp.mdga/client/Statistics.java | 3 ++ .../src/main/java/pp.mdga/client/Swap.java | 3 ++ .../src/main/java/pp.mdga/client/Turn.java | 7 +++- .../java/pp.mdga/client/TurnStateMachine.java | 8 ++++ .../java/pp.mdga/client/VideoSettings.java | 3 ++ .../main/java/pp.mdga/client/WaitRanking.java | 3 ++ .../src/main/java/pp.mdga/client/Waiting.java | 3 ++ .../java/pp.mdga/client/WaitingPiece.java | 3 ++ 46 files changed, 319 insertions(+), 9 deletions(-) create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/client/ClientSender.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/client/Observer.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java index 73f8f285..6cf3a398 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class Animation extends ClientState { + protected Animation(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java index b1eaade6..dc273447 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class AudioSettings extends ClientState { + protected AudioSettings(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java index 7be5866a..9df52ddb 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java @@ -1,5 +1,10 @@ package pp.mdga.client; public class Ceremony extends ClientState { - private final CeremonyStateMachine ceremonyStateMachine = new CeremonyStateMachine(); + private final CeremonyStateMachine ceremonyStateMachine; + + protected Ceremony(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.ceremonyStateMachine = new CeremonyStateMachine(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java index 0449027d..371401c3 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java @@ -1,4 +1,14 @@ package pp.mdga.client; public class CeremonyStateMachine extends ClientStateMachine { + + protected CeremonyStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + + @Override + public Podium initialState() { + return new Podium(this, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java index 0b9fd192..4adedad0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java @@ -1,5 +1,10 @@ package pp.mdga.client; public class ChoosePiece extends ClientState { - private final ChoosePieceStateMachine choosePieceStateMachine = new ChoosePieceStateMachine(); + private final ChoosePieceStateMachine choosePieceStateMachine; + + protected ChoosePiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.choosePieceStateMachine = new ChoosePieceStateMachine(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java index 45c965b6..18a75c88 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java @@ -1,4 +1,12 @@ package pp.mdga.client; public class ChoosePieceStateMachine extends ClientStateMachine{ + protected ChoosePieceStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public NoPiece initialState() { + return new NoPiece(this, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java index 72a8d3d4..db2bed4c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class ChoosePowerCard extends ClientState { + protected ChoosePowerCard(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientAutomaton.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientAutomaton.java index f5261224..c90e199b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientAutomaton.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientAutomaton.java @@ -1,4 +1,14 @@ package pp.mdga.client; public class ClientAutomaton extends ClientStateMachine { + + public ClientAutomaton(ClientGameLogic logic){ + super(null, logic); + entry(); + } + + @Override + public Dialogs initialState(){ + return new Dialogs(this, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java index 6483e582..a33fe82e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java @@ -1,4 +1,36 @@ package pp.mdga.client; +import pp.mdga.game.Game; +import pp.mdga.message.client.ClientMessage; +import pp.mdga.server.ServerSender; + public class ClientGameLogic { + static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName()); + + private Game game; + private final ClientSender clientSender; + private ClientState state; + + public ClientGameLogic(Game game, ClientSender clientSender) { + this.game = game; + this.clientSender = clientSender; + state = new ClientAutomaton(this); + } + + public void send(ClientMessage msg){ + LOGGER.log(System.Logger.Level.INFO, "send {0}", msg); + clientSender.send(msg); + } + + public ClientSender getClientSender(){ + return clientSender; + } + + public Game getGame(){ + return game; + } + + public ClientState getState(){ + return state; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientSender.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientSender.java new file mode 100644 index 00000000..26f0df85 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientSender.java @@ -0,0 +1,7 @@ +package pp.mdga.client; + +import pp.mdga.message.client.ClientMessage; + +public interface ClientSender { + void send(ClientMessage msg); +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientState.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientState.java index 9e7c3786..2c45fbb7 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientState.java @@ -1,4 +1,33 @@ package pp.mdga.client; -public abstract class ClientState { +public abstract class ClientState implements Observer { + protected static final System.Logger LOGGER = System.getLogger(ClientState.class.getName()); + + protected ClientState parent; + + protected ClientGameLogic logic; + + protected ClientState(ClientState parent, ClientGameLogic logic){ + this.parent = parent; + this.logic = logic; + } + + public void entry(){/* do nothing */} + + public void exit() {/* do nothing*/} + + public void gotoState(ClientState newState){ + throw new IllegalStateException("not in a statemachine"); + } + + public ClientState getParent(){ + return parent; + } + + public void update() {/* do nothing */} + + @Override + public String toString(){ + return getClass().getSimpleName(); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientStateMachine.java index 0c8717e9..92620f35 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientStateMachine.java @@ -1,4 +1,46 @@ package pp.mdga.client; +import pp.mdga.message.server.*; + public abstract class ClientStateMachine extends ClientState { + + private ClientState state; + + protected ClientStateMachine(ClientState parent, ClientGameLogic logic){ + super(parent, logic); + } + + public abstract ClientState initialState(); + + @Override + public void gotoState(ClientState newState){ + LOGGER.log(System.Logger.Level.DEBUG, "{0}: {1} --> {2}", this, state, newState); + enter(newState); + } + + @Override + public void entry(){ + final ClientState newState = initialState(); + LOGGER.log(System.Logger.Level.DEBUG, "{0}: initial state={1}", this, newState); + enter(newState); + } + + private void enter(ClientState newState){ + if(newState.parent != this) + throw new IllegalArgumentException("Wrong state: " + newState + " belongs to " + newState.parent + " instead of " + this); + state = newState; + state.entry(); + } + + @Override + public void exit(){state.exit();} + + @Override + public String toString(){ + return super.toString() + "(in " + state + ")"; + } + + public ClientState getState(){ + return state; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java index b12b6a6d..e06bc1b6 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java @@ -1,5 +1,10 @@ package pp.mdga.client; public class DetermineStartPlayer extends ClientState { - private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine = new DetermineStartPlayerStateMachine(); + private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine; + + protected DetermineStartPlayer(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.determineStartPlayerStateMachine = new DetermineStartPlayerStateMachine(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java index f8a2aeda..d0153139 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java @@ -1,4 +1,12 @@ package pp.mdga.client; public class DetermineStartPlayerStateMachine extends ClientStateMachine{ + protected DetermineStartPlayerStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public RollRankingDice initialState() { + return new RollRankingDice(this, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java index 6b144ca8..f4140223 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java @@ -1,5 +1,10 @@ package pp.mdga.client; public class Dialogs extends ClientState { - private final DialogsStateMachine dialogsStateMachine = new DialogsStateMachine(); + private final DialogsStateMachine dialogsStateMachine; + + public Dialogs(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.dialogsStateMachine = new DialogsStateMachine(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java index a1097aab..f37b1a74 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java @@ -1,4 +1,12 @@ package pp.mdga.client; public class DialogsStateMachine extends ClientStateMachine { + protected DialogsStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public StartDialog initialState() { + return new StartDialog(this, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java index f4ac25fc..35d5221c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java @@ -1,5 +1,10 @@ package pp.mdga.client; public class GameState extends ClientState { - private final GameStateMachine gameStateMachine = new GameStateMachine(); + private final GameStateMachine gameStateMachine; + + protected GameState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.gameStateMachine = new GameStateMachine(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java index 9686b7e6..1a8a95de 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java @@ -1,4 +1,12 @@ package pp.mdga.client; public class GameStateMachine extends ClientStateMachine { + protected GameStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public ClientState initialState() { + return null; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java index 287363cc..4ce1e628 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java @@ -1,4 +1,14 @@ package pp.mdga.client; +import pp.mdga.server.GameState; + public class Interrupt extends ClientState { + + private final GameState lastState; + + public Interrupt(ClientState parent, ClientGameLogic logic, GameState lastState) { + super(parent, logic); + this.lastState = lastState; + } } + diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java index a2f0f1c0..8dbe6356 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class Lobby extends ClientState { + protected Lobby(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java index 67e641bd..95fabebd 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class MainSettings extends ClientState { + protected MainSettings(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java index e8c4c60b..1e3a148b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class MovePiece extends ClientState { + protected MovePiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java index 846a5a02..d065eaaf 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class NetworkDialog extends ClientState { + protected NetworkDialog(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java index a52655b3..55c15632 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class NoPiece extends ClientState { + protected NoPiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Observer.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Observer.java new file mode 100644 index 00000000..73290304 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Observer.java @@ -0,0 +1,5 @@ +package pp.mdga.client; + +public interface Observer { + void update(); +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java index 1d79e516..3bf5f241 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class PlayPowerCard extends ClientState { + protected PlayPowerCard(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java index 8819183e..57532c1e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class Podium extends ClientState { + protected Podium(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java index 2ad3c2d1..62fb0d73 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java @@ -1,5 +1,10 @@ package pp.mdga.client; public class PowerCard extends ClientState { - private final PowerCardStateMachine powerCardStateMachine = new PowerCardStateMachine(); + private final PowerCardStateMachine powerCardStateMachine; + + protected PowerCard(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.powerCardStateMachine = new PowerCardStateMachine(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java index 0bb5c60c..901d9d33 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java @@ -1,4 +1,12 @@ package pp.mdga.client; public class PowerCardStateMachine extends ClientStateMachine { + protected PowerCardStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public ChoosePowerCard initialState() { + return new ChoosePowerCard(this, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java index f1056203..6d5593de 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class RollDice extends ClientState { + protected RollDice(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java index 45871c8d..a0b90bd6 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class RollRankingDice extends ClientState { + protected RollRankingDice(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java index 083ba28f..686b66bc 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class SelectPiece extends ClientState { + protected SelectPiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java index 2c118580..f274ac0e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java @@ -1,5 +1,10 @@ package pp.mdga.client; public class Settings extends ClientState { - private final SettingsStateMachine settingsStateMachine = new SettingsStateMachine(); + private final SettingsStateMachine settingsStateMachine; + + protected Settings(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.settingsStateMachine = new SettingsStateMachine(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java index e45870dd..2ff5f8d4 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java @@ -1,4 +1,12 @@ package pp.mdga.client; public class SettingsStateMachine extends ClientStateMachine { + protected SettingsStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public ClientState initialState() { + return null; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java index eaaa67cc..411ca30a 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class Shield extends ClientState { + protected Shield(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java index 50fc01f7..a93fd2d1 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class Spectator extends ClientState { + protected Spectator(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java index d258c93c..cc08d402 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class StartDialog extends ClientState { + protected StartDialog(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java index 1330df6c..7f6af3ea 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class StartPiece extends ClientState { + protected StartPiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java index e46a5e1d..90b8a985 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class Statistics extends ClientState { + protected Statistics(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java index 60a9d28e..932a668e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class Swap extends ClientState { + protected Swap(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java index db60e158..f1eb1e02 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java @@ -1,5 +1,10 @@ package pp.mdga.client; public class Turn extends ClientState { - private final TurnStateMachine turnStateMachine = new TurnStateMachine(); + private final TurnStateMachine turnStateMachine; + + protected Turn(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.turnStateMachine = new TurnStateMachine(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java index 892cf3e6..4fac2958 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java @@ -1,4 +1,12 @@ package pp.mdga.client; public class TurnStateMachine extends ClientStateMachine { + protected TurnStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public PowerCard initialState() { + return new PowerCard(this, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java index 32d13929..4bce32e4 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class VideoSettings extends ClientState { + protected VideoSettings(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java index 5614da6a..cbe8776a 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class WaitRanking extends ClientState { + protected WaitRanking(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java index 4f0d719b..64838163 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class Waiting extends ClientState { + protected Waiting(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java index d07fe63e..7932cb31 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java @@ -1,4 +1,7 @@ package pp.mdga.client; public class WaitingPiece extends ClientState { + protected WaitingPiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } } From c204984a74e41d79346261596ebf95ca74d1eadd Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 16:03:12 +0100 Subject: [PATCH 13/44] edited a test in the clientStateTest --- .../client/clientState/ClientStateTest.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 8d8d23c7..bccd9618 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -414,7 +414,28 @@ public void testStayInLobby() { */ @Test public void testLobbyToRollRankingDice() { - // Implementation goes here + //sends the clientStatemachine in Lobby + assertTrue(clientAutomaton.getState() instanceof Dialogs); + Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = lobby.getDialogsStatemachine(); + dialogsStateMachine1.goto(lobby); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + + //sends the message to start the game + clientGameLogic.receive();//TODO message + + //tests if the clientStateMachine is in the GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + + //tests if the clientStateMachine is in the DetermineStartPlayer + GameState gameState1 = (GameState) clientAutomaton.getState(); + GameStateMachine gameStateMachine1 = gameState1.getgameSatateMachine(); + assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); + + //tests if the clientStateMachine is in the RollRankingDice + DetermineStartPlayer determineStartPlayer1 = (DetermineStartPlayer) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = gameStateMachine1.getDetermineStartPlayerMachine(); + assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); } /** From a71619612a6fd347ad6cd60cd6239416ba55eb70 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 18:21:26 +0100 Subject: [PATCH 14/44] added the empty testmethods in serverstateTest and edited the testmethods for substates of choocePiece in Client into MovePiece --- .../client/clientState/ClientStateTest.java | 144 ++++++++++++- .../server/serverState/ServerStateTest.java | 198 ++++++++++++++++++ 2 files changed, 333 insertions(+), 9 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index bccd9618..cca467c6 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -13,7 +13,7 @@ import static org.junit.Assert.assertTrue; /** - * this test-class tests the testcases T232-T239 + * this test-class tests the testcases T232-T239 TODO */ public class ClientStateTest { @@ -211,7 +211,7 @@ public void testDialogsToGame() { assertTrue(clientAutomaton.getState() instanceof GameState); //tests if the new State of the GameStateMachine is in DetermineStartPlayer - GameState gameState1= clientAutomaton.getState(); + GameState gameState1 = clientAutomaton.getState(); GameStateMachine gameStateMachine1 = (GameStateMachine) gameState1.getState(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); @@ -840,7 +840,7 @@ public void testNoPieceInStartPiece() { */ @Test public void testNoPieceInWait() { - //TODO + //sends the ClientAutomaton in GameState clientAutomaton.goto(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); @@ -872,7 +872,28 @@ public void testNoPieceInWait() { */ @Test public void testStayInWaitingPiece() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in WaitingPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(waitingPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + + //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change + + assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); } /** @@ -880,7 +901,28 @@ public void testStayInWaitingPiece() { */ @Test public void testWaitingPieceInChoosePieceEndState() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in WaitingPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(waitingPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + + //Todo send the message to the clientGameLogic to force a state change + + assertTrue(turnStateMachine1.getState() instanceof MovePiece); } /** @@ -888,7 +930,28 @@ public void testWaitingPieceInChoosePieceEndState() { */ @Test public void testStayInSelectedPiece() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in SelectPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(selectPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + + //Todo send all server messages which dont force a state change here + + assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); } /** @@ -896,7 +959,28 @@ public void testStayInSelectedPiece() { */ @Test public void testSelectedPieceInChoosePieceEndState() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in SelectPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(selectPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + + //Todo send the message which force a state change + + assertTrue(turnStateMachine1.getState() instanceof MovePiece); } /** @@ -904,7 +988,28 @@ public void testSelectedPieceInChoosePieceEndState() { */ @Test public void testStayInStartPiece() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in StartPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(startPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + + //todo send all messages which dont force a state change + + assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); } /** @@ -912,7 +1017,28 @@ public void testStayInStartPiece() { */ @Test public void testStartPieceToChoosePieceEndState() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in StartPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(startPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + + //Todo send the message which force a state change + + assertTrue(turnStateMachine1.getState() instanceof MovePiece); } /** diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 10bf1239..601ce827 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -368,4 +368,202 @@ public void testTurnToGameEndState() { public void testStayInPowerCard() { // TODO: Implement test logic for staying in Power Card state } + + /** + * Tests the transition from PowerCard state to PlayPowerCard state. + * UC-ServerState-17 + */ + @Test + public void testPowerCardToPlayPowerCard() { + // UC-ServerState-17 + } + + /** + * Tests the transition from PlayPowerCard state to RollDice state. + * UC-ServerState-18 + */ + @Test + public void testPlayPowerCardToRollDice() { + // UC-ServerState-18 + } + + /** + * Tests the transition from ChoosePiece state to MovePiece state. + * UC-ServerState-19 + */ + @Test + public void testChoosePieceToMovePiece() { + // UC-ServerState-19 + } + + /** + * Tests the transition from MovePiece state to TurnEndState. + * UC-ServerState-20 + */ + @Test + public void testMovePiecetoTurnEndState() { + // UC-ServerState-20 + } + + /** + * Tests the transition from MovePiece state to FirstRoll state. + * UC-ServerState-21 + */ + @Test + public void testMovePieceToFirstRoll() { + // UC-ServerState-21 + } + + /** + * Tests the transition from FirstRoll state to RollDiceEndState. + * UC-ServerState-22 + */ + @Test + public void testFirstRollToRollDiceEndState() { + // UC-ServerState-22 + } + + /** + * Tests the transition from FirstRoll state to SecondRoll state. + * UC-ServerState-23 + */ + @Test + public void testFirstRollToSecondRoll() { + // UC-ServerState-23 + } + + /** + * Tests the transition from SecondRoll state to RollDiceEndState. + * UC-ServerState-24 + */ + @Test + public void testSecondRollToRollDiceEndState() { + // UC-ServerState-24 + } + + /** + * Tests the transition from SecondRoll state to ThirdRoll state. + * UC-ServerState-25 + */ + @Test + public void testSecondRollToThirdRoll() { + // UC-ServerState-25 + } + + /** + * Tests the transition from ThirdRoll state to RollDiceEndState. + * UC-ServerState-26 + */ + @Test + public void testThirdRollToRollDiceEndState() { + // UC-ServerState-26 + } + + /** + * Tests the transition from ThirdRoll state to TurnEndState. + * UC-ServerState-27 + */ + @Test + public void testThirdRollToTurnEndState() { + // UC-ServerState-27 + } + + /** + * Tests the transition from NoPiece state to WaitingPiece state. + * UC-ServerState-28 + */ + @Test + public void testNoPieceToWaitingPiece() { + // UC-ServerState-28 + } + + /** + * Tests the transition from NoPiece state to NoTurn state. + * UC-ServerState-29 + */ + @Test + public void testNoPieceToNoTurn() { + // UC-ServerState-29 + } + + /** + * Tests the transition from NoTurn state to TurnEndState. + * UC-ServerState-30 + */ + @Test + public void testNoTurnToTurnEndState() { + // UC-ServerState-30 + } + + /** + * Tests that the system stays in the WaitingPiece state. + * UC-ServerState-31 + */ + @Test + public void testStayInWaitingPiece() { + // UC-ServerState-31 + } + + /** + * Tests the transition from WaitingPiece state to MovePiece state. + * UC-ServerState-32 + */ + @Test + public void testWaitingPieceToMovePiece() { + // UC-ServerState-32 + } + + /** + * Tests the transition from NoPiece state to SelectPiece state. + * UC-ServerState-33 + */ + @Test + public void testNoPieceToSelectPiece() { + // UC-ServerState-33 + } + + /** + * Tests the transition from NoPiece state to StartPiece state. + * UC-ServerState-34 + */ + @Test + public void testNoPieceToStartPiece() { + // UC-ServerState-34 + } + + /** + * Tests that the system stays in the SelectPiece state. + * UC-ServerState-35 + */ + @Test + public void testStayInSelectPiece() { + // UC-ServerState-35 + } + + /** + * Tests the transition from SelectPiece state to MovePiece state. + * UC-ServerState-36 + */ + @Test + public void testSelectPieceToMovePiece() { + // UC-ServerState-36 + } + + /** + * Tests that the system stays in the StartPiece state. + * UC-ServerState-37 + */ + @Test + public void testStayInStartPiece() { + // UC-ServerState-37 + } + + /** + * Tests the transition from StartPiece state to MovePiece state. + * UC-ServerState-38 + */ + @Test + public void testStartPieceToMovePiece() { + // UC-ServerState-38 + } } From 56492cdda608278309e123c14f98448e876eb560 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 18:40:10 +0100 Subject: [PATCH 15/44] added some mor testcases for the clientstatemachine --- .../client/clientState/ClientStateTest.java | 264 ++++++++++++++---- 1 file changed, 203 insertions(+), 61 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index cca467c6..7482ede1 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -236,7 +236,7 @@ public void testDialogsToClientStateEndState() { public void testClientGameToCeremony() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); @@ -259,7 +259,7 @@ public void testClientGameToCeremony() { @Test public void testClientGameSubStatesToInterrupt() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); @@ -286,7 +286,7 @@ public void testGameToDialogs() { public void testStayInInterrupt() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(interrupt); + clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); @@ -301,7 +301,7 @@ public void testStayInInterrupt() { public void testClientInterruptToGame() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(interrupt); + clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); @@ -316,7 +316,7 @@ public void testClientInterruptToGame() { public void testInterruptToDialogs() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(interrupt); + clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); @@ -331,7 +331,7 @@ public void testInterruptToDialogs() { public void testCeremonyToDialogs() { // Todo Implementation goes here //send the client in the ceremony - clientAutomaton.goto(ceremony); + clientAutomaton.gotoState(ceremony); assertTrue(clientAutomaton.getStates() instanceof Ceremony); //Todo @@ -418,7 +418,7 @@ public void testLobbyToRollRankingDice() { assertTrue(clientAutomaton.getState() instanceof Dialogs); Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); DialogsStateMachine dialogsStateMachine1 = lobby.getDialogsStatemachine(); - dialogsStateMachine1.goto(lobby); + dialogsStateMachine1.gotoState(lobby); assertTrue(dialogsStateMachine1.getState() instanceof Lobby); //sends the message to start the game @@ -453,14 +453,14 @@ public void testDetermineStartPlayerToWait() { public void testWaitToAnimation() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); //sends the client in WaitState GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(waiting); + gameStateMachine1.gotoState(waiting); assertTrue(gameStateMachine1.getState() instanceof Waiting); //tests if a piece is moved,that the client goes into Animation @@ -468,7 +468,7 @@ public void testWaitToAnimation() { assertTrue(gameStateMachine1.getState() instanceof Animation); //sends the client in WaitState - gameStateMachine1.goto(waiting); + gameStateMachine1.gotoState(waiting); assertTrue(gameStateMachine1.getState() instanceof Waiting); //tests if a powerCard is played,that the client goes into Animation @@ -476,7 +476,7 @@ public void testWaitToAnimation() { assertTrue(gameStateMachine1.getState() instanceof Animation); //sends the client in WaitState - gameStateMachine1.goto(waiting); + gameStateMachine1.gotoState(waiting); assertTrue(gameStateMachine1.getState() instanceof Waiting); //tests if a die is rolled,that the client goes into Animation @@ -491,12 +491,12 @@ public void testWaitToAnimation() { public void testWaitToTurn() { //TODo //sends client in gameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(wait); + gameStateMachine1.gotoState(wait); assertTrue(gameStateMachine1.getState() instanceof Turn); //the client receives the message ActivePlayer @@ -577,17 +577,17 @@ public void testPowerCardSubStatesToRollDice() { public void testStayInPlayPowerCard() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(playPowerCard); + turnStateMachine1.gotoState(playPowerCard); assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); //Todo send messages to test to stay in playPowerCard @@ -601,17 +601,17 @@ public void testStayInPlayPowerCard() { public void testPlayPowerCardToRollDice() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(playPowerCard); + turnStateMachine1.gotoState(playPowerCard); assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); //Todo send messages to test the transition in rollDice @@ -696,7 +696,31 @@ public void testStayInChoosePowerCard() { */ @Test public void testChoosePowerCardToRollDice() { - // Implementation goes here + + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + + //todo send the messages, to force a state change to rollDice + + //tests if the turnStateMachine is in RollDice + assertTrue(turnStateMachine1.getState() instanceof RollDice); } /** @@ -704,7 +728,31 @@ public void testChoosePowerCardToRollDice() { */ @Test public void testChoosePowerCardToSwap() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + + //todo send the messages, to force a state change to swap + + //tests if the client is in Swap + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof Swap); } /** @@ -712,7 +760,31 @@ public void testChoosePowerCardToSwap() { */ @Test public void testChoosePowerCardToShield() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + + //todo send the messages, to force a state change to shield + + //tests if the client is in Shield + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof Shield); } /** @@ -720,7 +792,31 @@ public void testChoosePowerCardToShield() { */ @Test public void testStayInShield() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in Shield + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(shield); + assertTrue(powerCardStateMachine1.getState() instanceof Shield); + + //todo send the messages, which dont force a statechange + + //tests if the client is in PlayPowerCard + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof PlayPowerCard); } /** @@ -728,7 +824,30 @@ public void testStayInShield() { */ @Test public void testShieldToPowerCardEndState() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in Shield + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(shield); + assertTrue(powerCardStateMachine1.getState() instanceof Shield); + + //todo send the message to force the statechange + + //tests if the client is in PlayPowerCard + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); } /** @@ -736,7 +855,30 @@ public void testShieldToPowerCardEndState() { */ @Test public void testSwapToPowerCardEndState() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in Swap + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(swap); + assertTrue(powerCardStateMachine1.getState() instanceof Swap); + + //todo send the message to force the statechange + + //tests if the client is in PlayPowerCard + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); } /** @@ -746,17 +888,17 @@ public void testSwapToPowerCardEndState() { public void testNoPieceInWaitingPiece() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece @@ -778,17 +920,17 @@ public void testNoPieceInWaitingPiece() { public void testNoPieceInSelectedPiece() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece @@ -810,17 +952,17 @@ public void testNoPieceInSelectedPiece() { public void testNoPieceInStartPiece() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece @@ -842,17 +984,17 @@ public void testNoPieceInStartPiece() { public void testNoPieceInWait() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece @@ -873,22 +1015,22 @@ public void testNoPieceInWait() { @Test public void testStayInWaitingPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(waitingPiece); + choosePieceStateMachine1.gotoState(waitingPiece); assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change @@ -902,22 +1044,22 @@ public void testStayInWaitingPiece() { @Test public void testWaitingPieceInChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(waitingPiece); + choosePieceStateMachine1.gotoState(waitingPiece); assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); //Todo send the message to the clientGameLogic to force a state change @@ -931,22 +1073,22 @@ public void testWaitingPieceInChoosePieceEndState() { @Test public void testStayInSelectedPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in SelectPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(selectPiece); + choosePieceStateMachine1.gotoState(selectPiece); assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); //Todo send all server messages which dont force a state change here @@ -960,22 +1102,22 @@ public void testStayInSelectedPiece() { @Test public void testSelectedPieceInChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in SelectPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(selectPiece); + choosePieceStateMachine1.gotoState(selectPiece); assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); //Todo send the message which force a state change @@ -989,22 +1131,22 @@ public void testSelectedPieceInChoosePieceEndState() { @Test public void testStayInStartPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(startPiece); + choosePieceStateMachine1.gotoState(startPiece); assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); //todo send all messages which dont force a state change @@ -1018,22 +1160,22 @@ public void testStayInStartPiece() { @Test public void testStartPieceToChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(startPiece); + choosePieceStateMachine1.gotoState(startPiece); assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); //Todo send the message which force a state change From 2a97ede98514d4df4eb289fd42f597023d2f7d41 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 19:03:19 +0100 Subject: [PATCH 16/44] added some testmethods for the client testing the statechanges in the dialogs --- .../client/clientState/ClientStateTest.java | 142 ++++++++++++++++-- 1 file changed, 128 insertions(+), 14 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 7482ede1..eb67dc7a 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -314,14 +314,17 @@ public void testClientInterruptToGame() { */ @Test public void testInterruptToDialogs() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(interrupt); - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); - //Todo + //Todo send the server-closed message and the leave option + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = dialogs1.getDialogsStateMachine(); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } /** @@ -329,12 +332,21 @@ public void testInterruptToDialogs() { */ @Test public void testCeremonyToDialogs() { - // Todo Implementation goes here //send the client in the ceremony clientAutomaton.gotoState(ceremony); - assertTrue(clientAutomaton.getStates() instanceof Ceremony); + assertTrue(clientAutomaton.getState() instanceof Ceremony); - //Todo + //sends the ceremony machine in the statistics + CeremonyStateMachine ceremonyStateMachine1 = ceremony.getCeremonyStateMachine(); + ceremonyStateMachine1.gotoState(statistics); + assertTrue(ceremonyStateMachine1.getState() instanceof Statistics); + + //Todo simulate the button next + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = dialogs1.getDialogsStateMachine(); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } /** @@ -342,7 +354,19 @@ public void testCeremonyToDialogs() { */ @Test public void testStartDialogToNetworkDialog1() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in StartDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(startDialog); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); } /** @@ -350,7 +374,19 @@ public void testStartDialogToNetworkDialog1() { */ @Test public void testStartDialogToNetworkDialog2() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in StartDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(startDialog); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); } /** @@ -359,6 +395,7 @@ public void testStartDialogToNetworkDialog2() { @Test public void testStartDialogToDialogsEndState() { // Implementation goes here + //TODO how to test? } /** @@ -366,7 +403,19 @@ public void testStartDialogToDialogsEndState() { */ @Test public void testNetworkDialogToStartDialog() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(networkDialog); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo simulate pushBtn + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } /** @@ -374,7 +423,19 @@ public void testNetworkDialogToStartDialog() { */ @Test public void testNetworkDialogToNetworkDialog1() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(networkDialog); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo test receiving all messages and making input + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); } /** @@ -382,7 +443,24 @@ public void testNetworkDialogToNetworkDialog1() { */ @Test public void testNetworkDialogToNetworkDialog2() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(networkDialog); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo simulate try connect to server ith wrong variables + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo simulate try connect to server with send: join-lobby and receive lobby-refuse-message + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); } /** @@ -390,7 +468,19 @@ public void testNetworkDialogToNetworkDialog2() { */ @Test public void testNetworkDialogToLobby() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(networkDialog); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo simulate connect to server with send lobby request + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); } /** @@ -398,7 +488,19 @@ public void testNetworkDialogToLobby() { */ @Test public void testLobbyToStartDialog() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in Lobby + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(lobby); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + + //todo simulate leave the lobby + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } /** @@ -406,7 +508,19 @@ public void testLobbyToStartDialog() { */ @Test public void testStayInLobby() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in Lobby + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(lobby); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + + //todo send all messages that dont indicate a change-state + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); } /** From 4c078ab0e25543dd1bf84e70d3312394671db9eb Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 19:37:03 +0100 Subject: [PATCH 17/44] added some testmethods and corrected other in the clientStatemachineTests --- .../client/clientState/ClientStateTest.java | 77 ++++++++++++++++--- 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index eb67dc7a..96fd2f57 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -191,8 +191,10 @@ public void setUp() { public void testInitialStateClientState() { //tests if the clientAutomaton is in Dialogs assertTrue(clientAutomaton.getState() instanceof Dialogs); + Dialogs dialogs = (Dialogs) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); //tests if the statemachine is in StartDialog - assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } /** @@ -200,8 +202,8 @@ public void testInitialStateClientState() { */ @Test public void testDialogsToGame() { - //TODO //tests if the client is in Dialogs + clientAutomaton.gotoState(dialogs); assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the startGame-Message to the client @@ -212,12 +214,12 @@ public void testDialogsToGame() { //tests if the new State of the GameStateMachine is in DetermineStartPlayer GameState gameState1 = clientAutomaton.getState(); - GameStateMachine gameStateMachine1 = (GameStateMachine) gameState1.getState(); + GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); //tests if the new State of DetermineStartPlayer is RollRankingDice DetermineStartPlayer determineStartPlayer1=(DetermineStartPlayer) gameStateMachine1.getState(); - DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = (DetermineStartPlayerStateMachine) determineStartPlayer1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); assertTrue(DetermineStartPlayerStateMachine.getState() instanceof RollRankingDice); } @@ -234,7 +236,6 @@ public void testDialogsToClientStateEndState() { */ @Test public void testClientGameToCeremony() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); @@ -249,7 +250,7 @@ public void testClientGameToCeremony() { //tests if the state of ceremony is Podium Ceremony ceremony1 = (Ceremony) clientAutomaton.getState(); - CeremonyStateMachine ceremonyStateMachine1 = (CeremonyStateMachine) ceremony1.getState(); + CeremonyStateMachine ceremonyStateMachine1 = ceremony1.getCeremonyStateMachine(); assertTrue(ceremonyStateMachine1.getState() instanceof Podium); } @@ -284,14 +285,15 @@ public void testGameToDialogs() { */ @Test public void testStayInInterrupt() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); - //Todo + //Todo send all messages except the continue-message + + assertTrue(clientAutomaton.getState() instanceof Interrupt); } /** @@ -299,14 +301,16 @@ public void testStayInInterrupt() { */ @Test public void testClientInterruptToGame() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); - //Todo + //Todo sends the continue-message + + //tests if the client is in the game + assertTrue(clientAutomaton.getState() instanceof GameState); } /** @@ -579,6 +583,7 @@ public void testWaitToAnimation() { //tests if a piece is moved,that the client goes into Animation clientGameLogic.receive(moveMessage); //Todo ??? richtige message + assertTrue(clientAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine1.getState() instanceof Animation); //sends the client in WaitState @@ -587,6 +592,7 @@ public void testWaitToAnimation() { //tests if a powerCard is played,that the client goes into Animation clientGameLogic.receive(playCard); //Todo ??? richtige message + assertTrue(clientAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine1.getState() instanceof Animation); //sends the client in WaitState @@ -595,6 +601,7 @@ public void testWaitToAnimation() { //tests if a die is rolled,that the client goes into Animation clientGameLogic.receive(dice); //Todo ??? richtige message + assertTrue(clientAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine1.getState() instanceof Animation); } @@ -616,6 +623,9 @@ public void testWaitToTurn() { //the client receives the message ActivePlayer clientGameLogic.receive(activePlayer); + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + //tests if Client is in Turn assertTrue(gameStateMachine1.getState() instanceof Turn); @@ -706,6 +716,11 @@ public void testStayInPlayPowerCard() { //Todo send messages to test to stay in playPowerCard + //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + } /** @@ -731,6 +746,10 @@ public void testPlayPowerCardToRollDice() { //Todo send messages to test the transition in rollDice //Todo test other messages, that there is no state change + //tests if the client is in RollDice + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof RollDice); } /** @@ -834,6 +853,8 @@ public void testChoosePowerCardToRollDice() { //todo send the messages, to force a state change to rollDice //tests if the turnStateMachine is in RollDice + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof RollDice); } @@ -865,6 +886,8 @@ public void testChoosePowerCardToSwap() { //todo send the messages, to force a state change to swap //tests if the client is in Swap + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PowerCard); assertTrue(powerCardStateMachine1.getState() instanceof Swap); } @@ -897,6 +920,8 @@ public void testChoosePowerCardToShield() { //todo send the messages, to force a state change to shield //tests if the client is in Shield + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PowerCard); assertTrue(powerCardStateMachine1.getState() instanceof Shield); } @@ -929,6 +954,8 @@ public void testStayInShield() { //todo send the messages, which dont force a statechange //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PowerCard); assertTrue(powerCardStateMachine1.getState() instanceof PlayPowerCard); } @@ -961,6 +988,8 @@ public void testShieldToPowerCardEndState() { //todo send the message to force the statechange //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); } @@ -992,6 +1021,8 @@ public void testSwapToPowerCardEndState() { //todo send the message to force the statechange //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); } @@ -1024,6 +1055,9 @@ public void testNoPieceInWaitingPiece() { //sends to the clientGameLogic the message WaitPiece clientGameLogic.receive(waitPiece); + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); } @@ -1056,6 +1090,9 @@ public void testNoPieceInSelectedPiece() { //sends to the clientGameLogic the message SelectPiece clientGameLogic.receive(selectPiece); + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); } @@ -1088,6 +1125,9 @@ public void testNoPieceInStartPiece() { //sends to the clientGameLogic the message StartPiece clientGameLogic.receive(startPiece); + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); } @@ -1120,6 +1160,8 @@ public void testNoPieceInWait() { //sends to the clientGameLogic the message NoTurn clientGameLogic.receive(noTurn); + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof Waiting); } @@ -1149,6 +1191,9 @@ public void testStayInWaitingPiece() { //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); } @@ -1178,6 +1223,8 @@ public void testWaitingPieceInChoosePieceEndState() { //Todo send the message to the clientGameLogic to force a state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof MovePiece); } @@ -1207,6 +1254,9 @@ public void testStayInSelectedPiece() { //Todo send all server messages which dont force a state change here + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); } @@ -1236,6 +1286,8 @@ public void testSelectedPieceInChoosePieceEndState() { //Todo send the message which force a state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof MovePiece); } @@ -1265,6 +1317,9 @@ public void testStayInStartPiece() { //todo send all messages which dont force a state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); } @@ -1294,6 +1349,8 @@ public void testStartPieceToChoosePieceEndState() { //Todo send the message which force a state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof MovePiece); } From 8932c8a8cdc832d402f13abc9b18302fd6ec449d Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 24 Nov 2024 19:56:51 +0100 Subject: [PATCH 18/44] added javadocs to all client messages --- .../pp.mdga/message/client/AnimationEnd.java | 30 +++- .../message/client/ClientInterpreter.java | 140 +++++++++++++++--- .../pp.mdga/message/client/ClientMessage.java | 13 ++ .../message/client/ClientStartGame.java | 30 +++- .../pp.mdga/message/client/DeselectTSK.java | 32 +++- .../message/client/ForceContinueGame.java | 30 +++- .../message/client/ForceStartGame.java | 26 +++- .../pp.mdga/message/client/JoinServer.java | 30 +++- .../pp.mdga/message/client/LeaveGame.java | 30 +++- .../pp.mdga/message/client/LobbyNotReady.java | 30 +++- .../pp.mdga/message/client/LobbyReady.java | 30 +++- .../pp.mdga/message/client/NoPowerCard.java | 30 +++- .../message/client/RequestBriefing.java | 30 +++- .../pp.mdga/message/client/RequestDice.java | 30 +++- .../pp.mdga/message/client/RequestMove.java | 29 +++- .../message/client/RequestPlayCard.java | 42 +++++- .../pp.mdga/message/client/SelectCard.java | 32 +++- .../pp.mdga/message/client/SelectTSK.java | 17 ++- .../message/client/SelectedPieces.java | 29 +++- 19 files changed, 593 insertions(+), 67 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/AnimationEnd.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/AnimationEnd.java index b564a96b..c6bfa62e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/AnimationEnd.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/AnimationEnd.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message indicating an animation event is finished in the game. + */ +@Serializable public class AnimationEnd extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs an AnimationEnd message. + */ + public AnimationEnd() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "AnimationEnd{}"; + } + + /** + * Accepts a visitor for processing this message. + * + * @param interpreter the visitor to be used for processing + * @param from the connection ID of the sender + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientInterpreter.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientInterpreter.java index 0b7ec4d5..6e0565d0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientInterpreter.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientInterpreter.java @@ -1,37 +1,143 @@ package pp.mdga.message.client; +/** + * Visitor interface for processing all client messages. + */ public interface ClientInterpreter { - void received(AnimationEnd animationEnd, int from); + /** + * Processes a received AnimationEnd message. + * + * @param msg the AnimationEnd message to be processed + * @param from the connection ID from which the message was received + */ + void received(AnimationEnd msg, int from); - void received(DeselectTSK deselectTSK , int from); + /** + * Processes a received DeselectTSK message. + * + * @param msg the DeselectTSK message to be processed + * @param from the connection ID from which the message was received + */ + void received(DeselectTSK msg, int from); - void received(ForceStartGame forceStartGame, int from); - void received(JoinServer joinServer , int from); + /** + * Processes a received ForceStartGame message. + * + * @param msg the ForceStartGame message to be processed + * @param from the connection ID from which the message was received + */ + void received(ForceStartGame msg, int from); - void received(LeaveGame leaveGame , int from); + /** + * Processes a received JoinServer message. + * + * @param msg the JoinServer message to be processed + * @param from the connection ID from which the message was received + */ + void received(JoinServer msg, int from); - void received(LobbyNotReady lobbyNotReady , int from); + /** + * Processes a received LeaveGame message. + * + * @param msg the LeaveGame message to be processed + * @param from the connection ID from which the message was received + */ + void received(LeaveGame msg, int from); - void received(LobbyReady lobbyReady , int from); + /** + * Processes a received LobbyNotReady message. + * + * @param msg the LobbyNotReady message to be processed + * @param from the connection ID from which the message was received + */ + void received(LobbyNotReady msg, int from); - void received(RequestBriefing requestBriefing , int from); + /** + * Processes a received LobbyReady message. + * + * @param msg the LobbyReady message to be processed + * @param from the connection ID from which the message was received + */ + void received(LobbyReady msg, int from); - void received(RequestDice requestDice , int from); + /** + * Processes a received RequestBriefing message. + * + * @param msg the RequestBriefing message to be processed + * @param from the connection ID from which the message was received + */ + void received(RequestBriefing msg, int from); - void received(RequestMove requestMove , int from); + /** + * Processes a received RequestDice message. + * + * @param msg the RequestDice message to be processed + * @param from the connection ID from which the message was received + */ + void received(RequestDice msg, int from); - void received(RequestPlayCard requestPlayCard , int from); + /** + * Processes a received RequestMove message. + * + * @param msg the RequestMove message to be processed + * @param from the connection ID from which the message was received + */ + void received(RequestMove msg, int from); - void received(SelectCard selectCard , int from); + /** + * Processes a received RequestPlayCard message. + * + * @param msg the RequestPlayCard message to be processed + * @param from the connection ID from which the message was received + */ + void received(RequestPlayCard msg, int from); - void received(SelectTSK selectTSK , int from); + /** + * Processes a received SelectCard message. + * + * @param msg the SelectCard message to be processed + * @param from the connection ID from which the message was received + */ + void received(SelectCard msg, int from); - void received(ForceContinueGame forceContinueGame, int from); + /** + * Processes a received SelectTSK message. + * + * @param msg the SelectTSK message to be processed + * @param from the connection ID from which the message was received + */ + void received(SelectTSK msg, int from); - void received(ClientStartGame clientStartGame, int from); + /** + * Processes a received ForceContinueGame message. + * + * @param msg the ForceContinueGame message to be processed + * @param from the connection ID from which the message was received + */ + void received(ForceContinueGame msg, int from); - void received(NoPowerCard noPowerCard, int from); + /** + * Processes a received ClientStartGame message. + * + * @param msg the ClientStartGame message to be processed + * @param from the connection ID from which the message was received + */ + void received(ClientStartGame msg, int from); - void received(SelectedPieces selectedPieces, int from); + /** + * Processes a received NoPowerCard message. + * + * @param msg the NoPowerCard message to be processed + * @param from the connection ID from which the message was received + */ + void received(NoPowerCard msg, int from); + + /** + * Processes a received SelectedPieces message. + * + * @param msg the SelectedPieces message to be processed + * @param from the connection ID from which the message was received + */ + void received(SelectedPieces msg, int from); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientMessage.java index 9ae2d921..35a22cf2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientMessage.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientMessage.java @@ -2,10 +2,23 @@ import com.jme3.network.AbstractMessage; +/** + * An abstract base class for client messages used in network transfer. + * It extends the AbstractMessage class provided by the jme3-network library. + */ public abstract class ClientMessage extends AbstractMessage { + /** + * Constructs a new ClientMessage instance. + */ protected ClientMessage() { super(true); } + /** + * Accepts a visitor for processing this message. + * + * @param interpreter the visitor to be used for processing + * @param from the connection ID of the sender + */ public abstract void accept(ClientInterpreter interpreter, int from); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientStartGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientStartGame.java index 86a69f73..bde881e1 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientStartGame.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientStartGame.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the host to start the game. + */ +@Serializable public class ClientStartGame extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new ClientStartGame instance. + */ + public ClientStartGame() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "ClientStartGame{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java index 854c1995..77e85c03 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java @@ -1,23 +1,53 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.Color; +/** + * A message sent by a client to deselect a TSK. + */ +@Serializable public class DeselectTSK extends ClientMessage { + /** + * The color associated with the TSK to be deselected. + */ private final Color color; + /** + * Constructs a new DeselectTSK message with the specified color. + * + * @param color the color associated with the TSK to be deselected + */ public DeselectTSK(Color color) { + super(); this.color = color; } + /** + * Returns the color associated with the TSK to be deselected. + * + * @return the color associated with the TSK to be deselected + */ public Color getColor() { return color; } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ @Override public String toString() { - return "null"; + return "DeselectTSK{" + "color=" + color + '}'; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceContinueGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceContinueGame.java index 1dd6e603..de6615f1 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceContinueGame.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceContinueGame.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the host to force the continuation of the game, when the game was interrupted. + */ +@Serializable public class ForceContinueGame extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new ForceContinueGame message. + */ + public ForceContinueGame() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "ForceContinueGame{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceStartGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceStartGame.java index 32bf769c..2a98e880 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceStartGame.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceStartGame.java @@ -1,15 +1,35 @@ package pp.mdga.message.client; -public class ForceStartGame extends ClientMessage { - public ForceStartGame() { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the host to force start the game when not everyone is ready or not everyone has selected a TSK. + */ +@Serializable +public class ForceStartGame extends ClientMessage { + /** + * Constructs a new ForceStartGame message. + */ + public ForceStartGame() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ @Override public String toString() { - return "null"; + return "ForceStartGame{}"; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/JoinServer.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/JoinServer.java index 9971ab68..a7192fe9 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/JoinServer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/JoinServer.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by a client when joining the server. + */ +@Serializable public class JoinServer extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new JoinServer instance. + */ + public JoinServer() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "JoinServer{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LeaveGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LeaveGame.java index 2da13e64..c6c7fda3 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LeaveGame.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LeaveGame.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by a client to leave the game. + */ +@Serializable public class LeaveGame extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new LeaveGame instance. + */ + public LeaveGame() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "LeaveGame{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyNotReady.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyNotReady.java index 8709c648..fb853c3f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyNotReady.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyNotReady.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by a client to unready in the lobby. + */ +@Serializable public class LobbyNotReady extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new LobbyNotReady instance. + */ + public LobbyNotReady() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "LobbyNotReady{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyReady.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyReady.java index 838111ba..3427a15c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyReady.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyReady.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the client to ready-up in the lobby. + */ +@Serializable public class LobbyReady extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new LobbyReady instance. + */ + public LobbyReady() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "LobbyReady{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/NoPowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/NoPowerCard.java index 3fa227de..edce79c8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/NoPowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/NoPowerCard.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by a client to indicate that the player is not using a power card. + */ +@Serializable public class NoPowerCard extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new NoPowerCard instance. + */ + public NoPowerCard() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "NoPowerCard{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestBriefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestBriefing.java index d1c12ff8..60fa41ba 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestBriefing.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestBriefing.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by a client to request a briefing from the server. (after a reconnect) + */ +@Serializable public class RequestBriefing extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new RequestBriefing instance. + */ + public RequestBriefing() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "RequestBriefing{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestDice.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestDice.java index 298866d1..bfd687bd 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestDice.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestDice.java @@ -1,11 +1,35 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by a client to request a die roll. + */ +@Serializable public class RequestDice extends ClientMessage { - @Override - public String toString() { - return "null"; + /** + * Constructs a new RequestDice instance. + */ + public RequestDice() { + super(); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "RequestDice{}"; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java index 48fd187d..a2b14f23 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java @@ -1,30 +1,49 @@ package pp.mdga.message.client; -import pp.mdga.game.Color; +import com.jme3.network.serializing.Serializable; +/** + * A message sent by a client to request a move for a piece. + */ +@Serializable public class RequestMove extends ClientMessage { - + /** + * The identifier for the piece. + */ private final String pieceIdentifier; - /** Constructor for RequestMove + /** + * Constructor for RequestMove * @param pieceIdentifier the piece identifier */ public RequestMove(String pieceIdentifier) { this.pieceIdentifier = pieceIdentifier; } - /** Getter for the piece identifier + /** + * Getter for the piece identifier * @return the piece identifier */ public String getPieceIdentifier() { return pieceIdentifier; } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ @Override public String toString() { - return pieceIdentifier; + return "RequestMove{pieceIdentifier = " + pieceIdentifier + '}'; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java index 67885e0f..17c25f61 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java @@ -1,30 +1,68 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.BonusCard; +/** + * A message sent by a client to request playing a bonus card. + */ +@Serializable public class RequestPlayCard extends ClientMessage { - + /** + * The bonus card to be played. + */ private final BonusCard card; + + /** + * The identifier of the piece. + */ private final String pieceIdentifier; + /** + * Constructs a new RequestPlayCard instance. + * + * @param card the bonus card to be played + * @param pieceIdentifier the identifier of the piece + */ public RequestPlayCard(BonusCard card, String pieceIdentifier) { this.pieceIdentifier = pieceIdentifier; this.card = card; } + /** + * Gets the bonus card associated with this request. + * + * @return the bonus card + */ public BonusCard getCard() { return card; } + /** + * Gets the piece identifier associated with this request. + * + * @return the piece identifier + */ public String getPieceIdentifier() { return pieceIdentifier; } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ @Override public String toString() { - return card.toString(); + return "RequestPlayCard={card=" + card.toString() + '}'; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java index 44957a6c..a50d1fe6 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java @@ -1,24 +1,52 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.BonusCard; +/** + * A message sent from the client to the server to select a bonus card. + */ +@Serializable public class SelectCard extends ClientMessage { - + /** + * The bonus card to be selected. + */ private final BonusCard card; + /** + * Constructs a new SelectCard instance. + * + * @param card the bonus card to be selected + */ public SelectCard(BonusCard card) { this.card = card; } + /** + * Gets the bonus card associated with this selection. + * + * @return the bonus card + */ public BonusCard getCard() { return card; } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ @Override public String toString() { - return "null"; + return "SelectCard{card=" + card + '}'; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java index 02a5c4cf..6b870434 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java @@ -1,7 +1,9 @@ package pp.mdga.message.client; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.Color; +@Serializable public class SelectTSK extends ClientMessage { private final Color color; @@ -13,12 +15,23 @@ public SelectTSK(Color color) { public Color getColor() { return color; } - + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ @Override public String toString() { - return "null"; + return "SelectTSK{color=" + color + '}'; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java index 50290e19..2e4f6a8d 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java @@ -1,30 +1,49 @@ package pp.mdga.message.client; -import pp.mdga.game.Color; +import com.jme3.network.serializing.Serializable; +/** + * A message sent by a client to indicate that a piece has been selected for a bonus cards. + */ +@Serializable public class SelectedPieces extends ClientMessage { - + /** + * The piece identifier. + */ private String pieceIdentifier; - /** Constructor for SelectedPieces + /** + * Constructor for SelectedPieces * @param pieceIdentifier the piece identifier */ public SelectedPieces(String pieceIdentifier) { this.pieceIdentifier = pieceIdentifier; } - /** Getter for the piece identifier + /** + * Getter for the piece identifier * @return the piece identifier */ public String getPieceIdentifier() { return pieceIdentifier; } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ @Override public String toString() { - return "null"; + return "SelectedPieces{pieceIdentifier=" + pieceIdentifier + '}'; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + * @param from the connection ID from which the message was received + */ @Override public void accept(ClientInterpreter interpreter, int from) { interpreter.received(this, from); From 653c3fb962bd4f230cad4ac534d973d151c5fe83 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 24 Nov 2024 20:51:03 +0100 Subject: [PATCH 19/44] added javadocs to all server messages --- .../pp.mdga/message/server/ActivePlayer.java | 41 +++- .../java/pp.mdga/message/server/AnyPiece.java | 49 ++++- .../java/pp.mdga/message/server/Briefing.java | 39 +++- .../java/pp.mdga/message/server/Ceremony.java | 39 +++- .../java/pp.mdga/message/server/Dice.java | 71 +++++-- .../pp.mdga/message/server/DiceAgain.java | 39 +++- .../java/pp.mdga/message/server/DiceNow.java | 39 +++- .../pp.mdga/message/server/EndOfTurn.java | 39 +++- .../pp.mdga/message/server/LobbyAccept.java | 39 +++- .../pp.mdga/message/server/LobbyDeny.java | 39 +++- .../message/server/LobbyPlayerJoin.java | 42 +++- .../message/server/LobbyPlayerLeave.java | 53 ++++- .../pp.mdga/message/server/MoveMessage.java | 36 +++- .../java/pp.mdga/message/server/NoTurn.java | 39 +++- .../pp.mdga/message/server/PauseGame.java | 39 +++- .../java/pp.mdga/message/server/PlayCard.java | 45 +++- .../pp.mdga/message/server/PossibleCard.java | 48 ++++- .../pp.mdga/message/server/PossiblePiece.java | 53 ++++- .../message/server/RankingResponce.java | 13 -- .../message/server/RankingResponse.java | 46 +++++ .../message/server/RankingRollAgain.java | 39 +++- .../message/server/ReconnectBriefing.java | 41 +++- .../pp.mdga/message/server/ResumeGame.java | 39 +++- .../message/server/ServerInterpreter.java | 192 ++++++++++++++++++ .../pp.mdga/message/server/ServerMessage.java | 18 ++ .../message/server/ServerStartGame.java | 39 +++- .../pp.mdga/message/server/StartPiece.java | 43 +++- .../pp.mdga/message/server/UpdateReady.java | 53 ++++- .../pp.mdga/message/server/UpdateTSK.java | 51 ++++- .../pp.mdga/message/server/WaitPiece.java | 39 +++- 30 files changed, 1294 insertions(+), 108 deletions(-) delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponce.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java index e7c35daa..6127acff 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java @@ -1,30 +1,63 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.Color; +/** + * A message sent by the server to inform the clients about the active player. + */ +@Serializable public class ActivePlayer extends ServerMessage { - private Color color; + /** + * The color of the active player. + */ + private final Color color; - /** Constructor for ActivePlayer + /** + * Constructor for ActivePlayer + * * @param color the color of the active player */ public ActivePlayer(Color color) { + super(); this.color = color; } - /** Getter for the color of the active player + /** + * Getter for the color of the active player + * * @return the color of the active player */ public Color getColor() { return color; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "ActivePlayer{color=" + color + '}'; + } + + /** + * Returns the key for the informational text associated with this message. + * + * @return the key for the informational text + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java index 42e3cec6..eaf69c6d 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java @@ -1,36 +1,71 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; + import java.util.ArrayList; +import java.util.List; +/** + * A message sent by the server to the active player containing a list of pieces that the player can move any piece of the list on the board. + */ +@Serializable public class AnyPiece extends ServerMessage { + /** + * The list of pieces + */ + private final ArrayList piece; - private ArrayList piece; - - /** Constructor for AnyPiece + /** + * Constructor for AnyPiece */ public AnyPiece() { + super(); piece = new ArrayList<>(); } - /** Add a piece to the list of pieces + /** + * Add a piece to the list of pieces + * * @param piece the piece to add */ public void addPiece(String piece) { this.piece.add(piece); } - /** Getter for the list of pieces + /** + * Getter for the list of pieces + * * @return the list of pieces */ - public ArrayList getPiece() { + public List getPiece() { return piece; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "AnyPiece{piece=" + piece + '}'; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java index db89d408..86942872 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class Briefing extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to the reconnected player to provide a briefing about the current game state. + */ +@Serializable +public class Briefing extends ServerMessage { + /** + * Constructs a new Briefing instance. + */ + public Briefing() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java index 8a13db46..3bff739c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class Ceremony extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to indicate the beginning of the ceremony. + */ +@Serializable +public class Ceremony extends ServerMessage { + /** + * Constructs a new Ceremony instance. + */ + public Ceremony() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java index 7330505f..255a81b5 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java @@ -1,22 +1,39 @@ package pp.mdga.message.server; -import java.util.ArrayList; +import com.jme3.network.serializing.Serializable; +import java.util.List; + +/** + * A message sent by the server to the client to inform about the dice roll. + */ +@Serializable public class Dice extends ServerMessage { - + /** + * The eye of the dice + */ private final int diceEye; - private final ArrayList moveablePieces; - /** Constructor for Dice - * @param diceEye the eye of the dice + /** + * The pieces that can be moved + */ + private final List moveablePieces; + + /** + * Constructor for Dice + * + * @param diceEye the eye of the dice * @param moveablePieces the pieces that can be moved */ - public Dice(int diceEye, ArrayList moveablePieces) { + public Dice(int diceEye, List moveablePieces) { + super(); this.diceEye = diceEye; this.moveablePieces = moveablePieces; } - /** Constructor for inactivePlayer + /** + * Constructor for inactivePlayer + * * @param diceEye the eye of the dice * @return a new Dice object */ @@ -24,34 +41,60 @@ public static Dice inactivePlayer(int diceEye) { return new Dice(diceEye, null); } - /** Constructor for activePlayer - * @param diceEye the eye of the dice + /** + * Constructor for activePlayer + * + * @param diceEye the eye of the dice * @param moveablePieces the pieces that can be moved * @return a new Dice object */ - public static Dice activePlayer(int diceEye, ArrayList moveablePieces) { + public static Dice activePlayer(int diceEye, List moveablePieces) { return new Dice(diceEye, moveablePieces); } - /** Getter for the eye of the dice + /** + * Getter for the eye of the dice + * * @return the eye of the dice */ public int getDiceEye() { return diceEye; } - /** Getter for the pieces that can be moved + /** + * Getter for the pieces that can be moved + * * @return the pieces that can be moved */ - public ArrayList getMoveablePieces() { + public List getMoveablePieces() { return moveablePieces; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java index ee1798ee..c3402946 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class DiceAgain extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to the active player to indicate that they can roll the dice again. + */ +@Serializable +public class DiceAgain extends ServerMessage { + /** + * Constructs a new DiceAgain instance. + */ + public DiceAgain() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java index 3a87ca60..b72f22a7 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class DiceNow extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to the active player to enable the dice now button. + */ +@Serializable +public class DiceNow extends ServerMessage { + /** + * Constructs a new DiceNow instance. + */ + public DiceNow() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java index 62c33df2..d9ac9cb0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class EndOfTurn extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to indicate the end of the turn of the active player. + */ +@Serializable +public class EndOfTurn extends ServerMessage { + /** + * Constructs a new EndOfTurn instance. + */ + public EndOfTurn() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java index 324c69e5..d252148d 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class LobbyAccept extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to indicate that the client has been accepted into the lobby. + */ +@Serializable +public class LobbyAccept extends ServerMessage { + /** + * Constructs a new LobbyAccept instance. + */ + public LobbyAccept() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java index 0cbd29f0..0717f814 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class LobbyDeny extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to deny a client's request to join the lobby. + */ +@Serializable +public class LobbyDeny extends ServerMessage { + /** + * Constructs a new LobbyDeny instance. + */ + public LobbyDeny() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java index 5d686153..1eb189a0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java @@ -1,22 +1,62 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent from the server to the client indicating that a player has joined the lobby. + */ +@Serializable public class LobbyPlayerJoin extends ServerMessage { + /** + * The name of the player joining the lobby. + */ private final String name; + /** + * Constructs a new LobbyPlayerJoin instance with the specified player name. + * + * @param name the name of the player joining the lobby + */ public LobbyPlayerJoin(String name) { + super(); this.name = name; } + /** + * Returns the name of the player joining the lobby. + * + * @return the name of the player joining the lobby + */ public String getName() { return name; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java index 4f4ab6a3..267a368f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java @@ -1,29 +1,78 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.Color; +/** + * A message sent by the server to indicate that a player has left the lobby. + */ +@Serializable public class LobbyPlayerLeave extends ServerMessage { - + /** + * The name of the player leaving the lobby. + */ private final String name; + + /** + * The color associated with the player leaving the lobby. + */ private final Color color; + /** + * Constructs a new LobbyPlayerLeave instance with the specified player name and color. + * + * @param name the name of the player leaving the lobby + * @param color the color associated with the player leaving the lobby + */ public LobbyPlayerLeave(String name, Color color) { + super(); this.name = name; this.color = color; } + /** + * Returns the name of the player leaving the lobby. + * + * @return the name of the player leaving the lobby + */ public String getName() { return name; } + /** + * Returns the color associated with the player leaving the lobby. + * + * @return the color associated with the player leaving the lobby + */ public Color getColor() { return color; } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java index 4a7a3a39..d3df9f6c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java @@ -1,17 +1,30 @@ package pp.mdga.message.server; -public class MoveMessage extends ServerMessage { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to the client to move a piece on the board. + */ +@Serializable +public class MoveMessage extends ServerMessage { + /** + * The identifier of the piece that should be moved. + */ private final String pieceIdentifier; /** + * Constructs a new MoveMessage instance. + * * @param identifier the identifier of the piece that should be moved */ public MoveMessage(String identifier) { + super(); this.pieceIdentifier = identifier; } /** + * Returns the identifier of the piece that should be moved. + * * @return the identifier of the piece that should be moved */ public String getIdentifier() { @@ -19,13 +32,30 @@ public String getIdentifier() { } /** - * @return the identifier of the piece that should be moved + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java index c1b1f436..8a412de4 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class NoTurn extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to the active player to indicate that he has no valid moves. + */ +@Serializable +public class NoTurn extends ServerMessage { + /** + * Constructs a new NoTurn instance. + */ + public NoTurn() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java index d9416c30..19c95651 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class PauseGame extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to indicate that the game is paused. + */ +@Serializable +public class PauseGame extends ServerMessage { + /** + * Constructs a new PauseGame instance. + */ + public PauseGame() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java index 4b5f61ae..4d027172 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java @@ -1,22 +1,38 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.BonusCard; +/** + * A message sent by the server to the active player to play a card. + */ +@Serializable public class PlayCard extends ServerMessage { - + /** + * The card that should be played. + */ private final BonusCard card; + + /** + * The identifier of the piece that should be moved. + */ private final String pieceIdentifier; /** - * @param card the card that should be played + * Constructs a new PlayCard message. + * + * @param card the card that should be played * @param pieceIdentifier the identifier of the piece that should be moved */ public PlayCard(BonusCard card, String pieceIdentifier) { + super(); this.card = card; this.pieceIdentifier = pieceIdentifier; } /** + * Returns the card that should be played. + * * @return the card that should be played */ public BonusCard getCard() { @@ -24,16 +40,39 @@ public BonusCard getCard() { } /** + * Returns the identifier of the piece that should be moved. + * * @return the identifier of the piece that should be moved */ public String getPieceIdentifier() { return pieceIdentifier; } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java index d543b3c6..35df9bef 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java @@ -1,38 +1,72 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.BonusCard; import java.util.ArrayList; +import java.util.List; +/** + * A message sent by the server to the client to indicate the possible cards that can be chosen. + */ +@Serializable public class PossibleCard extends ServerMessage { + /** + * The list of possible cards. + */ + private final List possibleCards; - private ArrayList possibleCards; - - /** Constructor for PossibleCard + /** + * Constructor for a PossibleCard instance. */ public PossibleCard() { + super(); possibleCards = new ArrayList<>(); } - /** Add a possible card to the list of possible cards + /** + * Add a possible card to the list of possible cards + * * @param card the possible card to add */ public void addPossibleCard(BonusCard card) { this.possibleCards.add(card); } - /** Getter for the list of possible cards + /** + * Getter for the list of possible cards + * * @return the list of possible cards */ - public ArrayList getPossibleCards() { + public List getPossibleCards() { return possibleCards; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java index d85b9453..4755b9c8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java @@ -1,27 +1,46 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; + import java.util.ArrayList; +import java.util.List; +/** + * A message sent by the server to the active player to give all possible pieces to choose from. + */ +@Serializable public class PossiblePiece extends ServerMessage { + /** + * The list of possible own pieces + */ + private final List possibleOwnPieces; - private final ArrayList possibleOwnPieces; - private final ArrayList possibleEnemyPieces; + /** + * The list of possible enemy pieces + */ + private final List possibleEnemyPieces; - /** Constructor for PossiblePiece + /** + * Constructor for PossiblePiece */ public PossiblePiece() { + super(); possibleOwnPieces = new ArrayList<>(); possibleEnemyPieces = new ArrayList<>(); } - /** Add a piece to the list of possible pieces + /** + * Add a piece to the list of possible pieces + * * @param piece the piece to add */ public void addOwnPossiblePiece(String piece) { this.possibleOwnPieces.add(piece); } - /** Add a piece to the list of possible enemy pieces + /** + * Add a piece to the list of possible enemy pieces + * * @param piece the piece to add */ public void addEnemyPossiblePiece(String piece) { @@ -31,15 +50,35 @@ public void addEnemyPossiblePiece(String piece) { /** Getter for the list of possible pieces * @return the list of possible pieces */ - public ArrayList getPossiblePieces() { + public List getPossiblePieces() { return possibleOwnPieces; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponce.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponce.java deleted file mode 100644 index 4464bf2c..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponce.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class RankingResponce extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { - - } - - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java new file mode 100644 index 00000000..9b5eda2f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to all client to inform them about the current ranking. (only in DetermineStartPlayer) + */ +@Serializable +public class RankingResponse extends ServerMessage { + /** + * Constructs a new RankingResponse instance. + */ + public RankingResponse() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java index a1c200f9..eaf06392 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class RankingRollAgain extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to the clients to indicate that the ranking shall be rolled again. (only in DetermineStartPlayer) + */ +@Serializable +public class RankingRollAgain extends ServerMessage { + /** + * Constructs a new RankingRollAgain instance. + */ + public RankingRollAgain() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java index 7910e2c2..08f93d52 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java @@ -1,23 +1,60 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.Game; +/** + * A message sent by the server to a client that has reconnected to the game. (give the last saved model) + */ +@Serializable public class ReconnectBriefing extends ServerMessage { - + /** + * The game. + */ private final Game game; + /** + * Constructs a new ReconnectBriefing message. + */ public ReconnectBriefing(Game game) { + super(); this.game = game; } + /** + * Returns the game. + * + * @return the game + */ public Game getGame() { return game; } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java index 764dbb52..1ebfd673 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class ResumeGame extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to resume the game. + */ +@Serializable +public class ResumeGame extends ServerMessage { + /** + * Constructs a new ResumeGame instance. + */ + public ResumeGame() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java index d8f068cc..e9dde28a 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java @@ -1,4 +1,196 @@ package pp.mdga.message.server; +/** + * An interface for processing server messages. + * Implementations of this interface can be used to handle different types of server messages. + */ public interface ServerInterpreter { + /** + * Handles an ActivePlayer message received from the server. + * + * @param msg the ActivePlayer message received + */ + void received(ActivePlayer msg); + + /** + * Handles an AnyPiece message received from the server. + * + * @param msg the AnyPiece message received + */ + void received(AnyPiece msg); + + /** + * Handles a Briefing message received from the server. + * + * @param msg the Briefing message received + */ + void received(Briefing msg); + + /** + * Handles a Ceremony message received from the server. + * + * @param msg the Ceremony message received + */ + void received(Ceremony msg); + + /** + * Handles a Dice message received from the server. + * + * @param msg the Dice message received + */ + void received(Dice msg); + + /** + * Handles a DiceAgain message received from the server. + * + * @param msg the DiceAgain message received + */ + void received(DiceAgain msg); + + /** + * Handles a DiceNow message received from the server. + * + * @param msg the DiceNow message received + */ + void received(DiceNow msg); + + /** + * Handles an EndOfGame message received from the server. + * + * @param msg the EndOfGame message received + */ + void received(EndOfTurn msg); + + /** + * Handles a GameOver message received from the server. + * + * @param msg the GameOver message received + */ + void received(LobbyAccept msg); + + /** + * Handles a LobbyDeny message received from the server. + * + * @param msg the LobbyDeny message received + */ + void received(LobbyDeny msg); + + /** + * Handles a LobbyPlayerJoin message received from the server. + * + * @param msg the LobbyPlayerJoin message received + */ + void received(LobbyPlayerJoin msg); + + /** + * Handles a LobbyPlayerLeave message received from the server. + * + * @param msg the LobbyPlayerLeave message received + */ + void received(LobbyPlayerLeave msg); + + /** + * Handles a MoveMessage message received from the server. + * + * @param msg the MoveMessage message received + */ + void received(MoveMessage msg); + + /** + * Handles a NoTurn message received from the server. + * + * @param msg the NoTurn message received + */ + void received(NoTurn msg); + + /** + * Handles a PauseGame message received from the server. + * + * @param msg the PauseGame message received + */ + void received(PauseGame msg); + + /** + * Handles a PlayCard message received from the server. + * + * @param msg the PlayCard message received + */ + void received(PlayCard msg); + + /** + * Handles a PossibleCard message received from the server. + * + * @param msg the PossibleCard message received + */ + void received(PossibleCard msg); + + /** + * Handles a PossiblePiece message received from the server. + * + * @param msg the PossiblePiece message received + */ + void received(PossiblePiece msg); + + /** + * Handles a RankingResponce message received from the server. + * + * @param msg the RankingResponce message received + */ + void received(RankingResponse msg); + + /** + * Handles a RankingRollAgain message received from the server. + * + * @param msg the RankingRollAgain message received + */ + void received(RankingRollAgain msg); + + /** + * Handles a ReconnectBriefing message received from the server. + * + * @param msg the ReconnectBriefing message received + */ + void received(ReconnectBriefing msg); + + /** + * Handles a ResumeGame message received from the server. + * + * @param msg the ResumeGame message received + */ + void received(ResumeGame msg); + + /** + * Handles a ServerStartGame message received from the server. + * + * @param msg the ServerStartGame message received + */ + void received(ServerStartGame msg); + + /** + * Handles a StartPiece message received from the server. + * + * @param msg the StartPiece message received + */ + void received(StartPiece msg); + + /** + * Handles a UpdateReady message received from the server. + * + * @param msg the UpdateReady message received + */ + void received(UpdateReady msg); + + /** + * Handles a UpdateTSK message received from the server. + * + * @param msg the UpdateTSK message received + */ + void received(UpdateTSK msg); + + /** + * Handles a WaitPiece message received from the server. + * + * @param msg the WaitPiece message received + */ + void received(WaitPiece msg); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java index b97aec1a..bc1d6b7d 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java @@ -2,12 +2,30 @@ import com.jme3.network.AbstractMessage; +/** + * An abstract base class for server messages used in network transfer. + * It extends the AbstractMessage class provided by the jme3-network library. + */ public abstract class ServerMessage extends AbstractMessage { + /** + * Constructs a new ServerMessage instance. + */ protected ServerMessage() { super(true); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ public abstract void accept(ServerInterpreter interpreter); + /** + * Gets the bundle key of the informational text to be shown at the client. + * This key is used to retrieve the appropriate localized text for display. + * + * @return the bundle key of the informational text + */ public abstract String getInfoTextKey(); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java index 5a684bb8..d6ec553d 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; -public class ServerStartGame extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { +import com.jme3.network.serializing.Serializable; +/** + * A message indicating that the game shall start. + */ +@Serializable +public class ServerStartGame extends ServerMessage { + /** + * Constructs a new ServerStartGame instance. + */ + public ServerStartGame() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java index 902c467b..37baf781 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java @@ -1,22 +1,61 @@ package pp.mdga.message.server; -public class StartPiece extends ServerMessage { +import com.jme3.network.serializing.Serializable; +/** + * A message sent by the server to the active player that he has to move a start piece. + */ +@Serializable +public class StartPiece extends ServerMessage { + /** + * The identifier for the piece. + */ private final String pieceIdentifier; + /** + * Constructs a new StartPiece instance with the specified piece identifier. + * + * @param pieceIdentifier the identifier for the piece + */ public StartPiece(String pieceIdentifier) { + super(); this.pieceIdentifier = pieceIdentifier; } + /** + * Gets the identifier for the piece. + * + * @return the piece identifier + */ public String getPieceIdentifier() { return pieceIdentifier; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java index c7ad2593..cd728468 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java @@ -1,29 +1,78 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.Color; +/** + * A message sent by the server to every client to update the readiness status of a player. + */ +@Serializable public class UpdateReady extends ServerMessage { - + /** + * The color associated with the update. + */ private final Color color; + + /** + * Indicates whether the player is ready. + */ private final boolean ready; + /** + * Constructs a new UpdateReady instance with the specified color and readiness status. + * + * @param color the color associated with the update + * @param ready the readiness status + */ public UpdateReady(Color color, boolean ready) { + super(); this.color = color; this.ready = ready; } + /** + * Gets the color associated with the update. + * + * @return the color + */ public Color getColor() { return color; } + /** + * Checks if the player is ready. + * + * @return true if the player is ready, false otherwise + */ public boolean isReady() { return ready; } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java index e3280085..f8caa21f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java @@ -1,30 +1,77 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; import pp.mdga.game.Color; +/** + * A message sent by the server to every client to update the TSK. + */ +@Serializable public class UpdateTSK extends ServerMessage { - + /** + * The name associated with the update. + */ private final String name; + + /** + * The color associated with the update. + */ private final Color color; + /** + * Constructs a new UpdateTSK instance with the specified name and color. + * + * @param name the name associated with the update + * @param color the color associated with the update + */ public UpdateTSK(String name, Color color) { this.name = name; this.color = color; } + /** + * Gets the name associated with the update. + * + * @return the name + */ public String getName() { return name; } + /** + * Gets the color associated with the update. + * + * @return the color + */ public Color getColor() { return color; } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ @Override public void accept(ServerInterpreter interpreter) { - + interpreter.received(this); } + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java index 41cd1151..5e32338a 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java @@ -1,11 +1,44 @@ package pp.mdga.message.server; +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the active player to choose a piece from the waiting area. + */ +@Serializable public class WaitPiece extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { - + /** + * Constructs a new WaitPiece instance. + */ + public WaitPiece() { + super(); } + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ @Override public String getInfoTextKey() { return ""; From 83c79af31aff826e42a1b195e63d30fd17a6f33c Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sun, 24 Nov 2024 21:56:32 +0100 Subject: [PATCH 20/44] made all con structors of clients states public --- .../mdga/model/src/main/java/pp.mdga/client/Animation.java | 2 +- .../model/src/main/java/pp.mdga/client/AudioSettings.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/Ceremony.java | 6 +++++- .../src/main/java/pp.mdga/client/CeremonyStateMachine.java | 2 +- .../model/src/main/java/pp.mdga/client/ChoosePiece.java | 7 ++++++- .../main/java/pp.mdga/client/ChoosePieceStateMachine.java | 2 +- .../src/main/java/pp.mdga/client/ChoosePowerCard.java | 2 +- .../src/main/java/pp.mdga/client/ClientGameLogic.java | 1 - .../src/main/java/pp.mdga/client/DetermineStartPlayer.java | 6 +++++- .../pp.mdga/client/DetermineStartPlayerStateMachine.java | 2 +- .../src/main/java/pp.mdga/client/DialogsStateMachine.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/GameState.java | 6 +++++- .../src/main/java/pp.mdga/client/GameStateMachine.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/Interrupt.java | 3 --- .../mdga/model/src/main/java/pp.mdga/client/Lobby.java | 2 +- .../model/src/main/java/pp.mdga/client/MainSettings.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/MovePiece.java | 2 +- .../model/src/main/java/pp.mdga/client/NetworkDialog.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/NoPiece.java | 2 +- .../model/src/main/java/pp.mdga/client/PlayPowerCard.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/Podium.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/PowerCard.java | 6 +++++- .../main/java/pp.mdga/client/PowerCardStateMachine.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/RollDice.java | 2 +- .../src/main/java/pp.mdga/client/RollRankingDice.java | 2 +- .../model/src/main/java/pp.mdga/client/SelectPiece.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/Settings.java | 6 +++++- .../src/main/java/pp.mdga/client/SettingsStateMachine.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/Shield.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/Spectator.java | 2 +- .../model/src/main/java/pp.mdga/client/StartDialog.java | 2 +- .../model/src/main/java/pp.mdga/client/StartPiece.java | 2 +- .../model/src/main/java/pp.mdga/client/Statistics.java | 2 +- Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java | 2 +- Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java | 6 +++++- .../src/main/java/pp.mdga/client/TurnStateMachine.java | 2 +- .../model/src/main/java/pp.mdga/client/VideoSettings.java | 2 +- .../model/src/main/java/pp.mdga/client/WaitRanking.java | 2 +- .../mdga/model/src/main/java/pp.mdga/client/Waiting.java | 2 +- .../model/src/main/java/pp.mdga/client/WaitingPiece.java | 2 +- .../src/main/java/pp.mdga/notification/Notification.java | 4 ++++ 41 files changed, 71 insertions(+), 42 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java index 6cf3a398..6ed12c3b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class Animation extends ClientState { - protected Animation(ClientState parent, ClientGameLogic logic) { + public Animation(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java index dc273447..add83883 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class AudioSettings extends ClientState { - protected AudioSettings(ClientState parent, ClientGameLogic logic) { + public AudioSettings(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java index 9df52ddb..432f90f9 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java @@ -3,8 +3,12 @@ public class Ceremony extends ClientState { private final CeremonyStateMachine ceremonyStateMachine; - protected Ceremony(ClientState parent, ClientGameLogic logic) { + public Ceremony(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.ceremonyStateMachine = new CeremonyStateMachine(parent, logic); } + + public CeremonyStateMachine getCeremonyStateMachine() { + return ceremonyStateMachine; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java index 371401c3..758950f8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java @@ -2,7 +2,7 @@ public class CeremonyStateMachine extends ClientStateMachine { - protected CeremonyStateMachine(ClientState parent, ClientGameLogic logic) { + public CeremonyStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java index 4adedad0..828b12bd 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java @@ -1,10 +1,15 @@ package pp.mdga.client; public class ChoosePiece extends ClientState { + private final ChoosePieceStateMachine choosePieceStateMachine; - protected ChoosePiece(ClientState parent, ClientGameLogic logic) { + public ChoosePiece(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.choosePieceStateMachine = new ChoosePieceStateMachine(parent, logic); } + + public ChoosePieceStateMachine getChoosePieceStateMachine() { + return choosePieceStateMachine; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java index 18a75c88..5346214c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class ChoosePieceStateMachine extends ClientStateMachine{ - protected ChoosePieceStateMachine(ClientState parent, ClientGameLogic logic) { + public ChoosePieceStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java index db2bed4c..a11259b0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class ChoosePowerCard extends ClientState { - protected ChoosePowerCard(ClientState parent, ClientGameLogic logic) { + public ChoosePowerCard(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java index a33fe82e..dcad3574 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java @@ -2,7 +2,6 @@ import pp.mdga.game.Game; import pp.mdga.message.client.ClientMessage; -import pp.mdga.server.ServerSender; public class ClientGameLogic { static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName()); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java index e06bc1b6..3a773bc8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java @@ -3,8 +3,12 @@ public class DetermineStartPlayer extends ClientState { private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine; - protected DetermineStartPlayer(ClientState parent, ClientGameLogic logic) { + public DetermineStartPlayer(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.determineStartPlayerStateMachine = new DetermineStartPlayerStateMachine(parent, logic); } + + public DetermineStartPlayerStateMachine getDetermineStartPlayerStateMachine() { + return determineStartPlayerStateMachine; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java index d0153139..16c192c7 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class DetermineStartPlayerStateMachine extends ClientStateMachine{ - protected DetermineStartPlayerStateMachine(ClientState parent, ClientGameLogic logic) { + public DetermineStartPlayerStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java index f37b1a74..e1b833ad 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class DialogsStateMachine extends ClientStateMachine { - protected DialogsStateMachine(ClientState parent, ClientGameLogic logic) { + public DialogsStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java index 35d5221c..8819c103 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java @@ -3,8 +3,12 @@ public class GameState extends ClientState { private final GameStateMachine gameStateMachine; - protected GameState(ClientState parent, ClientGameLogic logic) { + public GameState(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.gameStateMachine = new GameStateMachine(parent, logic); } + + public GameStateMachine getGameStateMachine() { + return gameStateMachine; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java index 1a8a95de..4028c28e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class GameStateMachine extends ClientStateMachine { - protected GameStateMachine(ClientState parent, ClientGameLogic logic) { + public GameStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java index 4ce1e628..739a6bd2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java @@ -1,7 +1,5 @@ package pp.mdga.client; -import pp.mdga.server.GameState; - public class Interrupt extends ClientState { private final GameState lastState; @@ -11,4 +9,3 @@ public Interrupt(ClientState parent, ClientGameLogic logic, GameState lastState) this.lastState = lastState; } } - diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java index 8dbe6356..0f23c854 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class Lobby extends ClientState { - protected Lobby(ClientState parent, ClientGameLogic logic) { + public Lobby(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java index 95fabebd..e8af6b05 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class MainSettings extends ClientState { - protected MainSettings(ClientState parent, ClientGameLogic logic) { + public MainSettings(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java index 1e3a148b..13bd9b85 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class MovePiece extends ClientState { - protected MovePiece(ClientState parent, ClientGameLogic logic) { + public MovePiece(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java index d065eaaf..8075ae90 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class NetworkDialog extends ClientState { - protected NetworkDialog(ClientState parent, ClientGameLogic logic) { + public NetworkDialog(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java index 55c15632..42375b01 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class NoPiece extends ClientState { - protected NoPiece(ClientState parent, ClientGameLogic logic) { + public NoPiece(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java index 3bf5f241..4278445f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class PlayPowerCard extends ClientState { - protected PlayPowerCard(ClientState parent, ClientGameLogic logic) { + public PlayPowerCard(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java index 57532c1e..f962aa68 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class Podium extends ClientState { - protected Podium(ClientState parent, ClientGameLogic logic) { + public Podium(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java index 62fb0d73..42ea2741 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java @@ -3,8 +3,12 @@ public class PowerCard extends ClientState { private final PowerCardStateMachine powerCardStateMachine; - protected PowerCard(ClientState parent, ClientGameLogic logic) { + public PowerCard(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.powerCardStateMachine = new PowerCardStateMachine(parent, logic); } + + public PowerCardStateMachine getPowerCardStateMachine() { + return powerCardStateMachine; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java index 901d9d33..037417bc 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class PowerCardStateMachine extends ClientStateMachine { - protected PowerCardStateMachine(ClientState parent, ClientGameLogic logic) { + public PowerCardStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java index 6d5593de..4af7c7ad 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class RollDice extends ClientState { - protected RollDice(ClientState parent, ClientGameLogic logic) { + public RollDice(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java index a0b90bd6..f1a27dce 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class RollRankingDice extends ClientState { - protected RollRankingDice(ClientState parent, ClientGameLogic logic) { + public RollRankingDice(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java index 686b66bc..790e91b2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class SelectPiece extends ClientState { - protected SelectPiece(ClientState parent, ClientGameLogic logic) { + public SelectPiece(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java index f274ac0e..a30942ab 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java @@ -3,8 +3,12 @@ public class Settings extends ClientState { private final SettingsStateMachine settingsStateMachine; - protected Settings(ClientState parent, ClientGameLogic logic) { + public Settings(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.settingsStateMachine = new SettingsStateMachine(parent, logic); } + + public SettingsStateMachine getSettingsStateMachine() { + return settingsStateMachine; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java index 2ff5f8d4..0abb565e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class SettingsStateMachine extends ClientStateMachine { - protected SettingsStateMachine(ClientState parent, ClientGameLogic logic) { + public SettingsStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java index 411ca30a..a3f205ba 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class Shield extends ClientState { - protected Shield(ClientState parent, ClientGameLogic logic) { + public Shield(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java index a93fd2d1..293fc2b3 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class Spectator extends ClientState { - protected Spectator(ClientState parent, ClientGameLogic logic) { + public Spectator(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java index cc08d402..ee529941 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class StartDialog extends ClientState { - protected StartDialog(ClientState parent, ClientGameLogic logic) { + public StartDialog(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java index 7f6af3ea..7e52fd56 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class StartPiece extends ClientState { - protected StartPiece(ClientState parent, ClientGameLogic logic) { + public StartPiece(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java index 90b8a985..8eecb5ce 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class Statistics extends ClientState { - protected Statistics(ClientState parent, ClientGameLogic logic) { + public Statistics(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java index 932a668e..da3ef3c5 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class Swap extends ClientState { - protected Swap(ClientState parent, ClientGameLogic logic) { + public Swap(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java index f1eb1e02..3bdef5e6 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java @@ -3,8 +3,12 @@ public class Turn extends ClientState { private final TurnStateMachine turnStateMachine; - protected Turn(ClientState parent, ClientGameLogic logic) { + public Turn(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.turnStateMachine = new TurnStateMachine(parent, logic); } + + public TurnStateMachine getTurnStateMachine() { + return turnStateMachine; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java index 4fac2958..60501cd8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class TurnStateMachine extends ClientStateMachine { - protected TurnStateMachine(ClientState parent, ClientGameLogic logic) { + public TurnStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java index 4bce32e4..0b397e1a 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class VideoSettings extends ClientState { - protected VideoSettings(ClientState parent, ClientGameLogic logic) { + public VideoSettings(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java index cbe8776a..b9db2175 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class WaitRanking extends ClientState { - protected WaitRanking(ClientState parent, ClientGameLogic logic) { + public WaitRanking(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java index 64838163..14a32cdf 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class Waiting extends ClientState { - protected Waiting(ClientState parent, ClientGameLogic logic) { + public Waiting(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java index 7932cb31..7b12a023 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java @@ -1,7 +1,7 @@ package pp.mdga.client; public class WaitingPiece extends ClientState { - protected WaitingPiece(ClientState parent, ClientGameLogic logic) { + public WaitingPiece(ClientState parent, ClientGameLogic logic) { super(parent, logic); } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/Notification.java b/Projekte/mdga/model/src/main/java/pp.mdga/notification/Notification.java index 3f8be5da..3302d8a3 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/Notification.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/notification/Notification.java @@ -1,4 +1,8 @@ package pp.mdga.notification; public abstract class Notification { + + public void accept(){ + + } } From 040b8830ab6105ce426ff08a01dac1d17d2d7572 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sun, 24 Nov 2024 22:03:19 +0100 Subject: [PATCH 21/44] added getter for dialogstatemachine in dialogs --- Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java index f4140223..02a63715 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java @@ -7,4 +7,8 @@ public Dialogs(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.dialogsStateMachine = new DialogsStateMachine(parent, logic); } + + public DialogsStateMachine getDialogsStateMachine() { + return dialogsStateMachine; + } } From 599b3e8f472746f4cc78c9511449d674b31d73e5 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sun, 24 Nov 2024 22:18:48 +0100 Subject: [PATCH 22/44] corrected refactoring mistake, ich which RankingResponce was renamed to RankingResponse --- .../src/main/java/pp.mdga/server/DetermineStartPlayer.java | 2 +- .../mdga/model/src/main/java/pp.mdga/server/GameState.java | 4 ++-- .../mdga/model/src/main/java/pp.mdga/server/ServerState.java | 4 ++-- .../src/main/java/pp.mdga/server/ServerStateMachine.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java index 89020007..3fb1ff9a 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java @@ -26,7 +26,7 @@ public void receivedRequestDice(RequestDice msg, int from) { @Override public void update() { if (Boolean.TRUE.equals(logic.getGame().allRanked())) { - broadcastUpdate(new RankingResponce()); + broadcastUpdate(new RankingResponse()); if (logic.getGame().getOrder().isEmpty()) { // todo: save the players with the same value? broadcastUpdate(new RankingRollAgain()); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java index dab977c8..79069220 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java @@ -3,7 +3,7 @@ import pp.mdga.message.client.*; import pp.mdga.message.server.PauseGame; import pp.mdga.message.server.PossibleCard; -import pp.mdga.message.server.RankingResponce; +import pp.mdga.message.server.RankingResponse; public class GameState extends ServerState { private final GameStateMachine gameStateMachine = new GameStateMachine(this, logic); @@ -54,7 +54,7 @@ public void sentPossibleCard(PossibleCard msg, int from) { } @Override - public void sentRankingResponse(RankingResponce msg, int from) { + public void sentRankingResponse(RankingResponse msg, int from) { gameStateMachine.sentRankingResponse(msg, from); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java index 90c08897..29bf2edd 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java @@ -8,7 +8,7 @@ import pp.mdga.message.client.*; import pp.mdga.message.server.EndOfTurn; import pp.mdga.message.server.PossibleCard; -import pp.mdga.message.server.RankingResponce; +import pp.mdga.message.server.RankingResponse; import pp.mdga.message.server.ServerMessage; import java.lang.System.Logger; @@ -152,7 +152,7 @@ public void sentPossibleCard(PossibleCard msg, int from) { /* do nothing */ } * * @param msg the RankingResponce message */ - public void sentRankingResponse(RankingResponce msg, int from) { /* do nothing */ } + public void sentRankingResponse(RankingResponse msg, int from) { /* do nothing */ } /** * This method transitions to a new state. diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java index 7c30384e..2554deaf 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java @@ -3,7 +3,7 @@ import pp.mdga.message.client.*; import pp.mdga.message.server.EndOfTurn; import pp.mdga.message.server.PossibleCard; -import pp.mdga.message.server.RankingResponce; +import pp.mdga.message.server.RankingResponse; /** * Abstract class representing a state machine for the server. @@ -209,7 +209,7 @@ public void sentPossibleCard(PossibleCard msg, int from) { * @param msg the RankingResponse message */ @Override - public void sentRankingResponse(RankingResponce msg, int from) { + public void sentRankingResponse(RankingResponse msg, int from) { state.sentRankingResponse(msg, from); } From ed4788328122060fa68c4b0d81955d06536c3790 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sun, 24 Nov 2024 22:20:04 +0100 Subject: [PATCH 23/44] refactored ceremony message --- .../message/server/{Ceremony.java => CeremonyMessage.java} | 4 ++-- .../main/java/pp.mdga/message/server/ServerInterpreter.java | 2 +- Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) rename Projekte/mdga/model/src/main/java/pp.mdga/message/server/{Ceremony.java => CeremonyMessage.java} (91%) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java similarity index 91% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java rename to Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java index 3bff739c..10197038 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java @@ -6,11 +6,11 @@ * A message sent by the server to indicate the beginning of the ceremony. */ @Serializable -public class Ceremony extends ServerMessage { +public class CeremonyMessage extends ServerMessage { /** * Constructs a new Ceremony instance. */ - public Ceremony() { + public CeremonyMessage() { super(); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java index e9dde28a..c83abefd 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java @@ -31,7 +31,7 @@ public interface ServerInterpreter { * * @param msg the Ceremony message received */ - void received(Ceremony msg); + void received(CeremonyMessage msg); /** * Handles a Dice message received from the server. diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java index 4be9f928..4202226f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java @@ -1,10 +1,8 @@ package pp.mdga.server; -import pp.mdga.client.Spectator; import pp.mdga.game.Player; import pp.mdga.message.server.ActivePlayer; -import pp.mdga.message.server.Ceremony; -import pp.mdga.message.server.EndOfTurn; +import pp.mdga.message.server.CeremonyMessage; public class Turn extends ServerState { private final TurnStateMachine turnStateMachine = new TurnStateMachine(this, logic); @@ -25,7 +23,7 @@ public void exit() { // } if (logic.getGame().getPlayers().size() == 1) { - broadcastUpdate(new Ceremony()); + broadcastUpdate(new CeremonyMessage()); this.getParent().getParent().exit(); } else { // todo: next player From 1821a222e9bf958267cd8aaf693fbb39e4622555 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 22:24:39 +0100 Subject: [PATCH 24/44] minor changes --- .../client/clientState/ClientStateTest.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 96fd2f57..2e943d98 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -67,7 +67,7 @@ public class ClientStateTest { private ActivePlayer activePlayer; private AnyPiece anyPiece; private Briefing briefing; - private Ceremony ceremonyMessage; + private CeremonyMessage ceremonyMessage; private Dice dice; private DiceAgain diceAgain; private DiceNow diceNow; @@ -82,7 +82,7 @@ public class ClientStateTest { private PlayCard playCard; private PossibleCard possibleCard; private PossiblePiece possiblePiece; - private RankingResponce rankingResponce; + private RankingResponse rankingResponce; private RankingRollAgain rankingRollAgain; private ReconnectBriefing reconnectBriefing; private ResumeGame resumeGame; @@ -100,7 +100,7 @@ public void setUp() { activePlayer = new ActivePlayer(); anyPiece = new AnyPiece(); briefing = new Briefing(); - ceremonyMessage = new Ceremony(); + ceremonyMessage = new CeremonyMessage(); dice = new Dice(); diceAgain = new DiceAgain(); diceNow = new DiceNow(); @@ -115,7 +115,7 @@ public void setUp() { playCard = new PlayCard(); possibleCard = new PossibleCard(); possiblePiece = new PossiblePiece(); - rankingResponce = new RankingResponce(); + rankingResponce = new RankingResponse(); rankingRollAgain = new RankingRollAgain(); reconnectBriefing = new ReconnectBriefing(); resumeGame = new ResumeGame(); @@ -137,13 +137,13 @@ public void setUp() { //initialize the stateMachines ceremonyStateMachine =ceremony.getCeremonyStateMachine(); - choosePieceStateMachine = choosePiece.getChoosePieceMachine(); - determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerMachine(); + choosePieceStateMachine = choosePiece.getChoosePieceStateMachine(); + determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerStateMachine(); dialogsStateMachine = dialogs.getDialogsStateMachine(); gameStateMachine = gameState.getGameStateMachine(); - powerCardStateMachine = powerCard.getPowerCardMachine(); + powerCardStateMachine = powerCard.getPowerCardStateMachine(); settingsStateMachine = settings.getSettingsStateMachine(); - turnStateMachine = turn.getTurnMachine(); + turnStateMachine = turn.getTurnStateMachine(); //initialize the states @@ -213,14 +213,14 @@ public void testDialogsToGame() { assertTrue(clientAutomaton.getState() instanceof GameState); //tests if the new State of the GameStateMachine is in DetermineStartPlayer - GameState gameState1 = clientAutomaton.getState(); + GameState gameState1 = (GameState) clientAutomaton.getState(); GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); //tests if the new State of DetermineStartPlayer is RollRankingDice DetermineStartPlayer determineStartPlayer1=(DetermineStartPlayer) gameStateMachine1.getState(); DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); - assertTrue(DetermineStartPlayerStateMachine.getState() instanceof RollRankingDice); + assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); } /** @@ -547,12 +547,12 @@ public void testLobbyToRollRankingDice() { //tests if the clientStateMachine is in the DetermineStartPlayer GameState gameState1 = (GameState) clientAutomaton.getState(); - GameStateMachine gameStateMachine1 = gameState1.getgameSatateMachine(); + GameStateMachine gameStateMachine1 = gameState1.getGameSatateMachine(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); //tests if the clientStateMachine is in the RollRankingDice DetermineStartPlayer determineStartPlayer1 = (DetermineStartPlayer) gameStateMachine1.getState(); - DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = gameStateMachine1.getDetermineStartPlayerMachine(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); } @@ -617,7 +617,7 @@ public void testWaitToTurn() { //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(wait); + gameStateMachine1.gotoState(waiting); assertTrue(gameStateMachine1.getState() instanceof Turn); //the client receives the message ActivePlayer From 7c5720cb9d6d0c7b34d44b90976ac1b67d43ae42 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 24 Nov 2024 23:06:30 +0100 Subject: [PATCH 25/44] fixed sonarlint errors and deleted map playerConnectionID --- .../src/main/java/pp.mdga/game/Game.java | 71 +++++-------------- 1 file changed, 16 insertions(+), 55 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java index 427ea384..01a178cb 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java @@ -12,16 +12,15 @@ public class Game { private int diceModifier = 1; private int diceEyes; - private Map players = new HashMap(); + private Map players = new EnumMap<>(Color.class); private Statistic gameStatistics; - private ArrayList drawPile; - private ArrayList discardPile = new ArrayList<>(); + private List drawPile; + private List discardPile = new ArrayList<>(); private Board board; private Color activeColor; - private LinkedList order; - private Map playerConnectionID; + private List order; - private ArrayList observers = new ArrayList<>(); + private final ArrayList observers = new ArrayList<>(); private Player startPlayer; private Boolean gameHasStarted = false; private Boolean playerHasDisconnected = false; @@ -127,7 +126,7 @@ public void setGameStatistics(Statistic gameStatistics) { * * @return the draw pile */ - public ArrayList getDrawPile() { + public List getDrawPile() { return drawPile; } @@ -136,7 +135,7 @@ public ArrayList getDrawPile() { * * @param drawPile the new draw pile */ - public void setDrawPile(ArrayList drawPile) { + public void setDrawPile(List drawPile) { this.drawPile = drawPile; } @@ -145,7 +144,7 @@ public void setDrawPile(ArrayList drawPile) { * * @return the discard pile */ - public ArrayList getDiscardPile() { + public List getDiscardPile() { return discardPile; } @@ -154,7 +153,7 @@ public ArrayList getDiscardPile() { * * @param discardPile the new discard pile */ - public void setDiscardPile(ArrayList discardPile) { + public void setDiscardPile(List discardPile) { this.discardPile = discardPile; } @@ -199,7 +198,7 @@ public void setActiveColor(Color activeColor) { * * @return the order of the players */ - public LinkedList getOrder() { + public List getOrder() { return order; } @@ -208,48 +207,10 @@ public LinkedList getOrder() { * * @param order the new order of the players */ - public void setOrder(LinkedList order) { + public void setOrder(List order) { this.order = order; } - /** - * This method returns the player connection ID. - * - * @return the player connection ID - */ - public Map getPlayerConnectionID() { - return playerConnectionID; - } - - /** - * This method sets the player connection ID. - * - * @param playerConnectionID the new player connection ID - */ - public void setPlayerConnectionID(Map playerConnectionID) { - this.playerConnectionID = playerConnectionID; - } - - /** - * This method sets the player connection ID. - * - * @param color the color of the player - * @param connectionID the new connection ID - */ - public void setPlayerConnectionID(Color color, int connectionID) { - playerConnectionID.put(color, connectionID); - } - - /** - * This method returns the player connection ID. - * - * @param color the color of the player - * @return the player connection ID - */ - public int getPlayerConnectionID(Color color) { - return playerConnectionID.get(color); - } - /** * This method adds a player to the game. * @@ -321,7 +282,7 @@ public Boolean playerHasDisconnected() { */ public void setGameIsInterrupted(Boolean gameIsInterrupted) { this.gameIsInterrupted = gameIsInterrupted; - if (!gameIsInterrupted) notifyObservers(); + if (Boolean.FALSE.equals(gameIsInterrupted)) notifyObservers(); } /** @@ -349,7 +310,7 @@ public Boolean getMovablePieces() { */ public void setMovablePieces(Boolean movablePieces) { this.movablePieces = movablePieces; - if (!movablePieces) notifyObservers(); + if (Boolean.FALSE.equals(movablePieces)) notifyObservers(); } /** @@ -359,7 +320,7 @@ public void setMovablePieces(Boolean movablePieces) { */ public void setPlayerHasDisconnected(Boolean playerHasDisconnected) { this.playerHasDisconnected = playerHasDisconnected; - if (playerHasDisconnected) notifyObservers(); + if (Boolean.TRUE.equals(playerHasDisconnected)) notifyObservers(); } /** @@ -378,7 +339,7 @@ public Boolean allRanked() { */ public void setAllRanked(Boolean allRanked) { this.allRanked = allRanked; - if (allRanked) notifyObservers(); + if (Boolean.TRUE.equals(allRanked)) notifyObservers(); } /** @@ -415,7 +376,7 @@ public Boolean allReady() { */ public void setAllReady(Boolean allReady) { this.allReady = allReady; - if (allReady) notifyObservers(); + if (Boolean.TRUE.equals(allReady)) notifyObservers(); } /** From cc800a8dd76a2780d559d0de5cc8ca9571f1f2c6 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Sun, 24 Nov 2024 23:55:48 +0100 Subject: [PATCH 26/44] added default constructor for serialization purposes --- .../pp.mdga/message/client/DeselectTSK.java | 7 +++++++ .../pp.mdga/message/client/RequestMove.java | 9 +++++++++ .../message/client/RequestPlayCard.java | 10 +++++++++- .../pp.mdga/message/client/SelectCard.java | 7 +++++++ .../pp.mdga/message/client/SelectTSK.java | 19 ++++++++++++++++++- .../message/client/SelectedPieces.java | 9 +++++++++ .../pp.mdga/message/server/ActivePlayer.java | 8 +++++++- .../java/pp.mdga/message/server/Dice.java | 8 ++++++++ .../message/server/LobbyPlayerJoin.java | 7 +++++++ .../message/server/LobbyPlayerLeave.java | 8 ++++++++ .../pp.mdga/message/server/MoveMessage.java | 7 +++++++ .../java/pp.mdga/message/server/PlayCard.java | 8 ++++++++ .../message/server/ReconnectBriefing.java | 7 +++++++ .../pp.mdga/message/server/StartPiece.java | 8 ++++++++ .../pp.mdga/message/server/UpdateReady.java | 9 +++++++++ .../pp.mdga/message/server/UpdateTSK.java | 8 ++++++++ 16 files changed, 136 insertions(+), 3 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java index 77e85c03..5f2d4e26 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java @@ -23,6 +23,13 @@ public DeselectTSK(Color color) { this.color = color; } + /** + * Default constructor for serialization purposes. + */ + private DeselectTSK() { + color = null; + } + /** * Returns the color associated with the TSK to be deselected. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java index a2b14f23..80ccd63e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java @@ -14,14 +14,23 @@ public class RequestMove extends ClientMessage { /** * Constructor for RequestMove + * * @param pieceIdentifier the piece identifier */ public RequestMove(String pieceIdentifier) { this.pieceIdentifier = pieceIdentifier; } + /** + * Default constructor for serialization purposes. + */ + private RequestMove() { + pieceIdentifier = null; + } + /** * Getter for the piece identifier + * * @return the piece identifier */ public String getPieceIdentifier() { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java index 17c25f61..d2149837 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java @@ -21,7 +21,7 @@ public class RequestPlayCard extends ClientMessage { /** * Constructs a new RequestPlayCard instance. * - * @param card the bonus card to be played + * @param card the bonus card to be played * @param pieceIdentifier the identifier of the piece */ public RequestPlayCard(BonusCard card, String pieceIdentifier) { @@ -29,6 +29,14 @@ public RequestPlayCard(BonusCard card, String pieceIdentifier) { this.card = card; } + /** + * Default constructor for serialization purposes. + */ + private RequestPlayCard() { + card = null; + pieceIdentifier = null; + } + /** * Gets the bonus card associated with this request. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java index a50d1fe6..2d806a82 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java @@ -22,6 +22,13 @@ public SelectCard(BonusCard card) { this.card = card; } + /** + * Default constructor for serialization purposes. + */ + private SelectCard() { + card = null; + } + /** * Gets the bonus card associated with this selection. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java index 6b870434..0bb1d071 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java @@ -3,15 +3,32 @@ import com.jme3.network.serializing.Serializable; import pp.mdga.game.Color; +/** + * A message sent by a client to select a TSK. + */ @Serializable public class SelectTSK extends ClientMessage { - + /** + * The color associated with the TSK to be selected. + */ private final Color color; + /** + * Constructs a new SelectTSK message with the specified color. + * + * @param color the color associated with the TSK to be selected + */ public SelectTSK(Color color) { this.color = color; } + /** + * Default constructor for serialization purposes. + */ + private SelectTSK() { + color = null; + } + public Color getColor() { return color; } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java index 2e4f6a8d..d98b21bf 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java @@ -14,14 +14,23 @@ public class SelectedPieces extends ClientMessage { /** * Constructor for SelectedPieces + * * @param pieceIdentifier the piece identifier */ public SelectedPieces(String pieceIdentifier) { this.pieceIdentifier = pieceIdentifier; } + /** + * Default constructor for serialization purposes. + */ + private SelectedPieces() { + pieceIdentifier = null; + } + /** * Getter for the piece identifier + * * @return the piece identifier */ public String getPieceIdentifier() { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java index 6127acff..551cd305 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java @@ -8,7 +8,6 @@ */ @Serializable public class ActivePlayer extends ServerMessage { - /** * The color of the active player. */ @@ -24,6 +23,13 @@ public ActivePlayer(Color color) { this.color = color; } + /** + * Default constructor for serialization purposes. + */ + private ActivePlayer() { + color = null; + } + /** * Getter for the color of the active player * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java index 255a81b5..6b4bc1ee 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java @@ -31,6 +31,14 @@ public Dice(int diceEye, List moveablePieces) { this.moveablePieces = moveablePieces; } + /** + * Default constructor for serialization purposes. + */ + private Dice() { + diceEye = 0; + moveablePieces = null; + } + /** * Constructor for inactivePlayer * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java index 1eb189a0..9472a150 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java @@ -23,6 +23,13 @@ public LobbyPlayerJoin(String name) { this.name = name; } + /** + * Default constructor for serialization purposes. + */ + private LobbyPlayerJoin() { + name = null; + } + /** * Returns the name of the player joining the lobby. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java index 267a368f..f68b7054 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java @@ -30,6 +30,14 @@ public LobbyPlayerLeave(String name, Color color) { this.color = color; } + /** + * Default constructor for serialization purposes. + */ + private LobbyPlayerLeave() { + name = null; + color = null; + } + /** * Returns the name of the player leaving the lobby. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java index d3df9f6c..27dbe370 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java @@ -22,6 +22,13 @@ public MoveMessage(String identifier) { this.pieceIdentifier = identifier; } + /** + * Default constructor for serialization purposes. + */ + private MoveMessage() { + pieceIdentifier = null; + } + /** * Returns the identifier of the piece that should be moved. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java index 4d027172..7d088143 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java @@ -30,6 +30,14 @@ public PlayCard(BonusCard card, String pieceIdentifier) { this.pieceIdentifier = pieceIdentifier; } + /** + * Default constructor for serialization purposes. + */ + private PlayCard() { + card = null; + pieceIdentifier = null; + } + /** * Returns the card that should be played. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java index 08f93d52..5a72f341 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java @@ -21,6 +21,13 @@ public ReconnectBriefing(Game game) { this.game = game; } + /** + * Default constructor for serialization purposes. + */ + private ReconnectBriefing() { + this(null); + } + /** * Returns the game. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java index 37baf781..eb9c5508 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java @@ -22,6 +22,14 @@ public StartPiece(String pieceIdentifier) { this.pieceIdentifier = pieceIdentifier; } + /** + * Default constructor for serialization purposes. + */ + private StartPiece() { + super(); + this.pieceIdentifier = ""; + } + /** * Gets the identifier for the piece. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java index cd728468..6e815c95 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java @@ -30,6 +30,15 @@ public UpdateReady(Color color, boolean ready) { this.ready = ready; } + /** + * Default constructor for serialization purposes. + */ + private UpdateReady() { + super(); + this.color = null; + this.ready = false; + } + /** * Gets the color associated with the update. * diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java index f8caa21f..017dd29b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java @@ -25,10 +25,18 @@ public class UpdateTSK extends ServerMessage { * @param color the color associated with the update */ public UpdateTSK(String name, Color color) { + super(); this.name = name; this.color = color; } + /** + * Default constructor for serialization purposes. + */ + private UpdateTSK() { + this("", null); + } + /** * Gets the name associated with the update. * From f7bd9a0f389603c6abdb5503752cf4ab9abc59cb Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 00:20:47 +0100 Subject: [PATCH 27/44] edited some tests in ServerStateTest --- .../client/clientState/ClientStateTest.java | 64 +++- .../server/serverState/ServerStateTest.java | 338 ++++++++++++------ 2 files changed, 274 insertions(+), 128 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 2e943d98..c5ad8c70 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -5,10 +5,13 @@ import pp.mdga.client.*; import pp.mdga.client.Ceremony; import pp.mdga.client.StartPiece; +import pp.mdga.game.BonusCard; +import pp.mdga.game.Color; import pp.mdga.game.Game; +import pp.mdga.message.client.ClientMessage; import pp.mdga.message.server.*; - +import java.util.ArrayList; import static org.junit.Assert.assertTrue; @@ -79,59 +82,88 @@ public class ClientStateTest { private MoveMessage moveMessage; private NoTurn noTurn; private PauseGame pauseGame; - private PlayCard playCard; private PossibleCard possibleCard; private PossiblePiece possiblePiece; private RankingResponse rankingResponce; private RankingRollAgain rankingRollAgain; private ReconnectBriefing reconnectBriefing; private ResumeGame resumeGame; + private ServerStartGame startGame; private StartPiece startPieceMessage; private UpdateReady updateReady; private UpdateTSK updateTSK; private WaitPiece waitPiece; + private PlayCard playCardSwap; + private PlayCard playCardShield; + private PlayCard playCardTurbo; + + private int from; + private String name; + private Color color; + private BonusCard swapCard; + private BonusCard shieldCard; + private BonusCard turboCard; + + private Game game; + @Before public void setUp() { - // This method will be executed before each test. - // Initialize common objects or setup required state for Client State transitions. + //initialize the game + game = new Game(); + + //initialize the playerID + from=1234; + name="Daniel"; + color=Color.ARMY; + swapCard = BonusCard.SWAP; + shieldCard = BonusCard.SHIELD; + turboCard = BonusCard.TURBO; //initialize the messages from the server - activePlayer = new ActivePlayer(); + activePlayer = new ActivePlayer(color); anyPiece = new AnyPiece(); briefing = new Briefing(); ceremonyMessage = new CeremonyMessage(); - dice = new Dice(); + dice = new Dice(6,new ArrayList<>()); diceAgain = new DiceAgain(); diceNow = new DiceNow(); endOfTurn = new EndOfTurn(); lobbyAccept = new LobbyAccept(); lobbyDeny = new LobbyDeny(); - lobbyPlayerJoin = new LobbyPlayerJoin(); - lobbyPlayerLeave = new LobbyPlayerLeave(); + lobbyPlayerJoin = new LobbyPlayerJoin(name); + lobbyPlayerLeave = new LobbyPlayerLeave(name,color); moveMessage = new MoveMessage(); noTurn = new NoTurn(); pauseGame = new PauseGame(); - playCard = new PlayCard(); + playCardSwap = new PlayCard(swapCard); + playCardShield = new PlayCard(shieldCard); + playCardTurbo = new PlayCard(turboCard); possibleCard = new PossibleCard(); possiblePiece = new PossiblePiece(); rankingResponce = new RankingResponse(); rankingRollAgain = new RankingRollAgain(); - reconnectBriefing = new ReconnectBriefing(); + reconnectBriefing = new ReconnectBriefing(game); resumeGame = new ResumeGame(); + startGame = new ServerStartGame(); startPieceMessage = new StartPiece(); updateReady = new UpdateReady(); updateTSK = new UpdateTSK(); waitPiece = new WaitPiece(); //initialize the clientGameLogic - clientGameLogic = new ClientGameLogic(); + clientGameLogic = new ClientGameLogic(game, new ClientSender() { + @Override + public void send(ClientMessage msg) { + + } + }); clientAutomaton = (ClientAutomaton) clientGameLogic.getState(); //initialize the settings - mainSettings = new MainSettings(); - videoSettings = new VideoSettings(); - audioSettings = new AudioSettings(); + mainSettings = new MainSettings(settingsStateMachine,clientGameLogic); + videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic); + audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic); settings = new Settings(); @@ -535,7 +567,7 @@ public void testLobbyToRollRankingDice() { //sends the clientStatemachine in Lobby assertTrue(clientAutomaton.getState() instanceof Dialogs); Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); - DialogsStateMachine dialogsStateMachine1 = lobby.getDialogsStatemachine(); + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); dialogsStateMachine1.gotoState(lobby); assertTrue(dialogsStateMachine1.getState() instanceof Lobby); @@ -547,7 +579,7 @@ public void testLobbyToRollRankingDice() { //tests if the clientStateMachine is in the DetermineStartPlayer GameState gameState1 = (GameState) clientAutomaton.getState(); - GameStateMachine gameStateMachine1 = gameState1.getGameSatateMachine(); + GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); //tests if the clientStateMachine is in the RollRankingDice diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 601ce827..a4c22254 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -51,7 +51,6 @@ import pp.mdga.server.TurnStateMachine; import pp.mdga.server.WaitingPiece; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -79,7 +78,9 @@ public class ServerStateTest { private SelectedPieces selectedPieces; private SelectTSK selectTSK; private ClientMessage[] clientMessages; + private int from; + private int fromHost; private GameStateMachine gameStateMachine; private TurnStateMachine turnStateMachine; @@ -152,74 +153,69 @@ public void send(int id, ServerMessage msg) { selectedPieces, selectTSK }; - from=1234; + from = 1234; + fromHost = 2345; choosePieceStateMachine = choosePiece.getChoosePieceMachine(); rollDiceMachine = rollDice.getRollDicemachine(); turnStateMachine = turn.getTurnStatemachine(); - serverAutomaton = new ServerAutomaton(logic); + serverAutomaton = logic.getServerAutomaton(); gameStateMachine = gameState.getGameStatemachine(); - thirdRoll = new ThirdRoll(rollDiceMachine,logic); - secondRoll = new SecondRoll(rollDiceMachine,logic); - firstRoll = new FirstRoll(rollDiceMachine,logic); + thirdRoll = new ThirdRoll(rollDiceMachine, logic); + secondRoll = new SecondRoll(rollDiceMachine, logic); + firstRoll = new FirstRoll(rollDiceMachine, logic); - noPiece = new NoPiece(choosePieceStateMachine,logic); - noTurn = new NoTurn(choosePieceStateMachine,logic); - waitingPiece = new WaitingPiece(choosePieceStateMachine,logic); - startPiece = new StartPiece(choosePieceStateMachine,logic); - selectPiece = new SelectPiece(choosePieceStateMachine,logic); + noPiece = new NoPiece(choosePieceStateMachine, logic); + noTurn = new NoTurn(choosePieceStateMachine, logic); + waitingPiece = new WaitingPiece(choosePieceStateMachine, logic); + startPiece = new StartPiece(choosePieceStateMachine, logic); + selectPiece = new SelectPiece(choosePieceStateMachine, logic); - powerCard = new PowerCard(turnStateMachine,logic); - playPowerCard = new PlayPowerCard(turnStateMachine,logic); - rollDice = new RollDice(turnStateMachine,logic); - choosePiece = new ChoosePiece(turnStateMachine,logic); - movePiece = new MovePiece(turnStateMachine,logic); + powerCard = new PowerCard(turnStateMachine, logic); + playPowerCard = new PlayPowerCard(turnStateMachine, logic); + rollDice = new RollDice(turnStateMachine, logic); + choosePiece = new ChoosePiece(turnStateMachine, logic); + movePiece = new MovePiece(turnStateMachine, logic); - determineStartPlayer = new DetermineStartPlayer(gameStateMachine,logic); - turn = new Turn(gameStateMachine,logic); - animation = new Animation(gameStateMachine,logic); + determineStartPlayer = new DetermineStartPlayer(gameStateMachine, logic); + turn = new Turn(gameStateMachine, logic); + animation = new Animation(gameStateMachine, logic); - lobby = new Lobby(serverAutomaton,logic); - gameState = new GameState(serverAutomaton,logic); - ceremony = new Ceremony(serverAutomaton,logic); - interrupt = new Interrupt(serverAutomaton,logic,gameState); + lobby = new Lobby(serverAutomaton, logic); + gameState = new GameState(serverAutomaton, logic); + ceremony = new Ceremony(serverAutomaton, logic); + interrupt = new Interrupt(serverAutomaton, logic, gameState); } @Test public void testInitialStateServerState() { - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof Lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); } @Test public void testLobbyToDetermineStartPlayer() { - //tests if Server is in State Lobby - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof Lobby); - Lobby lobby = (Lobby) automaton.getState(); - //tests, when not all players are ready and the hosts send clientStartGame, that the Server stays in Lobby - //TODO set one player not ready - lobby.receivedStartGame(clientStartGame, from); - assertTrue(automaton.getState() instanceof Lobby); - //tests, when all players are ready and the hosts send clientStartGame, that the Server changes to DSP - //TODO set all player Ready - lobby.receivedStartGame(clientStartGame, from); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof DetermineStartPlayer); + //sends the server in the lobby-state + serverAutomaton.gotoState(lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); + + //sends the startGame message from the Host to the server + logic.received(clientStartGame, from); + + //tests if the server iss in DSP-state + assertTrue(serverAutomaton.getState() instanceof GameState); + GameState gameState1 = (GameState) serverAutomaton.getState();//Todo erzeuge state + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); } @Test public void testStayInLobby() { - //tests if Server is in State Lobby - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof Lobby); + //sends the server in the lobby-state + serverAutomaton.gotoState(lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); - //lobby gets all possible messages - Lobby lobby = (Lobby) automaton.getState(); - - //logic gets all messages + //TODO logic gets all messages logic.received(animationEnd, from); logic.received(clientStartGame, from); logic.received(deselectTSK, from); @@ -238,135 +234,209 @@ public void testStayInLobby() { logic.received(selectTSK, from); //tests if Server is still in Lobby - assertTrue(automaton.getState() instanceof Lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); } @Test public void testServerGameSubStatesToInterrupt() { - // TODO: Implement test logic for transition from Server Game Sub-States to Interrupt + //sends the server in the gameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); //TODO könnte auch auf gleichheit prüfen + + //TODO create interrupt + + //tests if the server is in the Interrupt-state + assertTrue(serverAutomaton.getState() instanceof Interrupt); } + /** + * tests the state-change from Game to Ceremony if the Game is finished + */ @Test public void testServerGameToCeremony() { - // TODO: Implement test logic for transition from Server Game to Ceremony - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof Lobby); - Lobby lobby = (Lobby) automaton.getState(); - //Todo set all players ready - logic.received(clientStartGame, from); - assertTrue(automaton.getState() instanceof GameState); + //sends the server in the gameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + //Todo game is finished - assertTrue(automaton.getState() instanceof Ceremony); + + //tests if the server is in the Ceremony-state + assertTrue(serverAutomaton.getState() instanceof Ceremony); } @Test public void testInterruptToGameContinue() { - //sends the server into the interrupt - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - automaton.gotoState(interrupt); - assertTrue(automaton.getState() instanceof Interrupt); + //sends the server in the Interrupt-State + serverAutomaton.gotoState(interrupt); + assertTrue(serverAutomaton.getState() instanceof Interrupt); + //sends the continue-message to the server logic.received(forceContinueGame, from); + //tests if new Stet is in GameState - assertTrue(automaton.getState() instanceof GameState); + assertTrue(serverAutomaton.getState() instanceof GameState); } @Test public void testInterruptToGameReconnect() { - // TODO: Implement test logic for transition from Interrupt to Game Reconnect + //sends the server in the Interrupt-State + serverAutomaton.gotoState(interrupt); + assertTrue(serverAutomaton.getState() instanceof Interrupt); + + //todo implement the timer + + //tests if new Stet is in GameState + assertTrue(serverAutomaton.getState() instanceof GameState); } @Test public void testInterruptToGameTimer() { - // TODO: Implement test logic for transition from Interrupt to Game Timer + //sends the server in the Interrupt-State + serverAutomaton.gotoState(interrupt); + assertTrue(serverAutomaton.getState() instanceof Interrupt); + + //Todo implement the timer + + //tests if new Stet is in GameState + assertTrue(serverAutomaton.getState() instanceof GameState); } @Test public void testCeremonyToServerStateEndState() { // TODO: Implement test logic for transition from Ceremony to Server State End State + // TODO how???? } @Test public void testDetermineStartPlayerToDetermineStartPlayer1() { - // Implement test logic for Determine Start Player to Determine Start Player (Variant 1) - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof GameStateMachine); - GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayer); assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); - logic.received(requestDice, from); - - assertTrue(automaton.getState() instanceof DetermineStartPlayer); + //TODO sends messages to the server + //tests if the server is still in DSP-state + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); } @Test public void testDetermineStartPlayerToDetermineStartPlayer2() { - // Implement test logic for Determine Start Player to Determine Start Player (Variant 2) - // sends the server in determineStartPlayer - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof GameStateMachine); - GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayer); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + + //TODO sends messages 2 RequestDiceMessage, die gleich geränkt werden to the server + + //tests if the server is still in DSP-state + assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); - //Todo: input same dices for both players - logic.received(requestDice, from); - logic.received(requestDice, 1235); - assertTrue(automaton.getState() instanceof DetermineStartPlayer); } @Test public void testDetermineStartPlayerToAnimation() { - // Implement test logic for Determine Start Player to Determine Start Player (Variant 2) - // sends the server in determineStartPlayer - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof GameStateMachine); - GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayer); assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); - //Todo: input different dices for both players - logic.received(requestDice, from); - logic.received(requestDice, 1235); - assertTrue(automaton.getState() instanceof Animation); + + //TODO sends messages 2 RequestDiceMessage, die ungleich geränkt werden, sodass der server weitergeht + + //tests if the Server is in animationState + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Animation); } @Test public void testAnimationToPowerCard() { - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof GameStateMachine); - GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); - assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); - //Todo: input different dices for both players - logic.received(requestDice, from); - logic.received(requestDice, 1235); - assertTrue(automaton.getState() instanceof Animation); - logic.received(animationEnd, from); + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Animation + gameStateMachine.gotoState(animation); assertTrue(gameStateMachine.getState() instanceof Animation); - logic.received(animationEnd, 1235); + + //receives one animation endMessage and tests if the server is still in the Animation-state + logic.received(animationEnd, fromHost); + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Animation); + + //receives another animation endMessage + logic.received(animationEnd, from); + + //tests if the server is in the PowerCard-state + assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine.getState() instanceof Turn); - TurnStateMachine turnStateMachine = (TurnStateMachine) automaton.getState(); + Turn turn1 = (Turn) gameStateMachine.getState(); + TurnStateMachine turnStateMachine = (TurnStateMachine) turn1.getTurnStateMachine(); assertTrue(turnStateMachine.getState() instanceof PowerCard); } @Test public void testTurnToAnimation() { - // TODO: Implement test logic for transition from Turn to Animation + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //todo set the turn finished and there are still two players left + + //tests if the server is in the AnimationState + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Animation); } @Test public void testTurnToGameEndState() { - // TODO: Implement test logic for transition from Turn to Game End State + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //todo set the turn finished and there is only one players left + + //tests if the server is in the end-state of game, Ceremony + assertTrue(serverAutomaton.getState() instanceof Ceremony); } @Test public void testStayInPowerCard() { - // TODO: Implement test logic for staying in Power Card state + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //Todo: receive messages which dont lead to a state change + + //tests if the server is in PowerCard + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); } /** @@ -375,7 +445,24 @@ public void testStayInPowerCard() { */ @Test public void testPowerCardToPlayPowerCard() { - // UC-ServerState-17 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //todo + + //tests if the server is in PlayPowerCard + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } /** @@ -384,7 +471,34 @@ public void testPowerCardToPlayPowerCard() { */ @Test public void testPlayPowerCardToRollDice() { - // UC-ServerState-18 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(playPowerCard); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + + //receive first AnimationEndMessage from the host + logic.received(animationEnd, fromHost); + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + + //receive second AnimationEndMessage + logic.received(animationEnd, from); + + //tests if the server is in RollDice and in FirstRoll + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + RollDice rollDice = (RollDice) turnStateMachine.getState(); + RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine(); + assertTrue(rollDiceMachine1.getState() instanceof FirstRoll); } /** From aa88dff56607e3b995f98b24e77b329e2201da7b Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 00:36:59 +0100 Subject: [PATCH 28/44] added tests in the serverStateTest added the testmethods for rolldice and movepiece --- .../server/serverState/ServerStateTest.java | 124 ++++++++++++++++-- 1 file changed, 116 insertions(+), 8 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index a4c22254..edf40cd1 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -44,7 +44,6 @@ import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerSender; import pp.mdga.server.NoTurn; -import pp.mdga.server.ServerState; import pp.mdga.server.StartPiece; import pp.mdga.server.ThirdRoll; import pp.mdga.server.Turn; @@ -507,7 +506,23 @@ public void testPlayPowerCardToRollDice() { */ @Test public void testChoosePieceToMovePiece() { - // UC-ServerState-19 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //Todo ??? + + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); } /** @@ -515,8 +530,22 @@ public void testChoosePieceToMovePiece() { * UC-ServerState-20 */ @Test - public void testMovePiecetoTurnEndState() { - // UC-ServerState-20 + public void testMovePieceToTurnEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in MovePiece + turnStateMachine.gotoState(movePiece); + assertTrue(turnStateMachine.getState() instanceof MovePiece); + + //Todo no 6 was rolled, so the server looks, if there are 2 or less player are still in the game + //TODO + } /** @@ -525,7 +554,26 @@ public void testMovePiecetoTurnEndState() { */ @Test public void testMovePieceToFirstRoll() { - // UC-ServerState-21 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in MovePiece + turnStateMachine.gotoState(movePiece); + assertTrue(turnStateMachine.getState() instanceof MovePiece); + + //Todo the player rolled a 6 and the player is not finished + + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + RollDice rollDice = (RollDice) turnStateMachine.getState(); + RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine(); + assertTrue(rollDiceMachine1.getState() instanceof FirstRoll); } /** @@ -534,7 +582,23 @@ public void testMovePieceToFirstRoll() { */ @Test public void testFirstRollToRollDiceEndState() { - // UC-ServerState-22 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in FirstRoll + rollDiceMachine.gotoState(firstRoll); + assertTrue(rollDiceMachine.getState() instanceof FirstRoll); + + //TODO 2 Möglichkeiten } /** @@ -543,7 +607,29 @@ public void testFirstRollToRollDiceEndState() { */ @Test public void testFirstRollToSecondRoll() { - // UC-ServerState-23 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in FirstRoll + rollDiceMachine.gotoState(firstRoll); + assertTrue(rollDiceMachine.getState() instanceof FirstRoll); + + //Todo player has no figures to move and had no 6 + + //tests if the server is in the SecondRoll + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + assertTrue(rollDiceMachine.getState() instanceof SecondRoll); } /** @@ -561,7 +647,29 @@ public void testSecondRollToRollDiceEndState() { */ @Test public void testSecondRollToThirdRoll() { - // UC-ServerState-25 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in FirstRoll + rollDiceMachine.gotoState(firstRoll); + assertTrue(rollDiceMachine.getState() instanceof FirstRoll); + + //Todo player has no figures to move and had no 6 + + //tests if the server is in the ThirdRoll + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); } /** From 928304fb4bb9c15a3284d0eefd16749c6cf4ef06 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 01:24:11 +0100 Subject: [PATCH 29/44] corrected testmethods in clientStateTest --- .../client/clientState/ClientStateTest.java | 477 ++++++++---------- 1 file changed, 199 insertions(+), 278 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index c5ad8c70..25fe769a 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -261,6 +261,7 @@ public void testDialogsToGame() { @Test public void testDialogsToClientStateEndState() { //Todo Implementation goes here + //TODO how????????? } /** @@ -270,8 +271,6 @@ public void testDialogsToClientStateEndState() { public void testClientGameToCeremony() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); //sends the Ceremony-Message to the client @@ -317,10 +316,8 @@ public void testGameToDialogs() { */ @Test public void testStayInInterrupt() { - //sends the ClientAutomaton in GameState + //sends the ClientAutomaton in Interrupt clientAutomaton.gotoState(interrupt); - - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); //Todo send all messages except the continue-message @@ -333,10 +330,8 @@ public void testStayInInterrupt() { */ @Test public void testClientInterruptToGame() { - //sends the ClientAutomaton in GameState + //sends the ClientAutomaton in Interrupt clientAutomaton.gotoState(interrupt); - - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); //Todo sends the continue-message @@ -350,9 +345,8 @@ public void testClientInterruptToGame() { */ @Test public void testInterruptToDialogs() { - //sends the ClientAutomaton in GameState + //sends the ClientAutomaton in Interrupt clientAutomaton.gotoState(interrupt); - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); //Todo send the server-closed message and the leave option @@ -373,9 +367,8 @@ public void testCeremonyToDialogs() { assertTrue(clientAutomaton.getState() instanceof Ceremony); //sends the ceremony machine in the statistics - CeremonyStateMachine ceremonyStateMachine1 = ceremony.getCeremonyStateMachine(); - ceremonyStateMachine1.gotoState(statistics); - assertTrue(ceremonyStateMachine1.getState() instanceof Statistics); + ceremonyStateMachine.gotoState(statistics); + assertTrue(ceremonyStateMachine.getState() instanceof Statistics); //Todo simulate the button next @@ -395,14 +388,13 @@ public void testStartDialogToNetworkDialog1() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in StartDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(startDialog); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + dialogsStateMachine.gotoState(startDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); //todo simulate pushBtn as client or host assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); } /** @@ -415,14 +407,13 @@ public void testStartDialogToNetworkDialog2() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in StartDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(startDialog); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + dialogsStateMachine.gotoState(startDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); //todo simulate pushBtn as client or host assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); } /** @@ -444,14 +435,13 @@ public void testNetworkDialogToStartDialog() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in NetworkDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(networkDialog); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo simulate pushBtn assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); } /** @@ -464,14 +454,13 @@ public void testNetworkDialogToNetworkDialog1() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in NetworkDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(networkDialog); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo test receiving all messages and making input assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); } /** @@ -484,19 +473,18 @@ public void testNetworkDialogToNetworkDialog2() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in NetworkDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(networkDialog); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo simulate try connect to server ith wrong variables assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo simulate try connect to server with send: join-lobby and receive lobby-refuse-message assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); } /** @@ -509,14 +497,13 @@ public void testNetworkDialogToLobby() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in NetworkDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(networkDialog); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo simulate connect to server with send lobby request assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); } /** @@ -529,14 +516,13 @@ public void testLobbyToStartDialog() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in Lobby - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(lobby); - assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); //todo simulate leave the lobby assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); } /** @@ -549,14 +535,13 @@ public void testStayInLobby() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in Lobby - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(lobby); - assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); //todo send all messages that dont indicate a change-state assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); } /** @@ -564,12 +549,13 @@ public void testStayInLobby() { */ @Test public void testLobbyToRollRankingDice() { - //sends the clientStatemachine in Lobby + //sends the clientStatemachine in Dialogs + clientAutomaton.gotoState(dialogs); assertTrue(clientAutomaton.getState() instanceof Dialogs); - Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(lobby); - assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + + //sends the clientStatemachine in Lobby + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); //sends the message to start the game clientGameLogic.receive();//TODO message @@ -593,7 +579,7 @@ public void testLobbyToRollRankingDice() { */ @Test public void testDetermineStartPlayerToWait() { - // Implementation goes here + // Todo Implementation goes here } /** @@ -601,40 +587,36 @@ public void testDetermineStartPlayerToWait() { */ @Test public void testWaitToAnimation() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); //sends the client in WaitState - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(waiting); - assertTrue(gameStateMachine1.getState() instanceof Waiting); + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); //tests if a piece is moved,that the client goes into Animation clientGameLogic.receive(moveMessage); //Todo ??? richtige message assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Animation); + assertTrue(gameStateMachine.getState() instanceof Animation); //sends the client in WaitState - gameStateMachine1.gotoState(waiting); - assertTrue(gameStateMachine1.getState() instanceof Waiting); + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); //tests if a powerCard is played,that the client goes into Animation clientGameLogic.receive(playCard); //Todo ??? richtige message assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Animation); + assertTrue(gameStateMachine.getState() instanceof Animation); //sends the client in WaitState - gameStateMachine1.gotoState(waiting); - assertTrue(gameStateMachine1.getState() instanceof Waiting); + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); //tests if a die is rolled,that the client goes into Animation clientGameLogic.receive(dice); //Todo ??? richtige message assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Animation); + assertTrue(gameStateMachine.getState() instanceof Animation); } /** @@ -642,15 +624,13 @@ public void testWaitToAnimation() { */ @Test public void testWaitToTurn() { - //TODo //sends client in gameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); - //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(waiting); - assertTrue(gameStateMachine1.getState() instanceof Turn); + //sends the gameStateMachine in the Waiting + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); //the client receives the message ActivePlayer clientGameLogic.receive(activePlayer); @@ -659,7 +639,7 @@ public void testWaitToTurn() { assertTrue(clientAutomaton.getState() instanceof GameState); //tests if Client is in Turn - assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //tests if Client is in PowerCard TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); @@ -731,28 +711,24 @@ public void testPowerCardSubStatesToRollDice() { */ @Test public void testStayInPlayPowerCard() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(playPowerCard); - assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + turnStateMachine.gotoState(playPowerCard); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); //Todo send messages to test to stay in playPowerCard //tests if the client is in PlayPowerCard assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); - + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } /** @@ -760,28 +736,25 @@ public void testStayInPlayPowerCard() { */ @Test public void testPlayPowerCardToRollDice() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(playPowerCard); - assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + turnStateMachine.gotoState(playPowerCard); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); //Todo send messages to test the transition in rollDice //Todo test other messages, that there is no state change //tests if the client is in RollDice assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof RollDice); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); } /** @@ -868,26 +841,23 @@ public void testChoosePowerCardToRollDice() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + powerCardStateMachine.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCard); //todo send the messages, to force a state change to rollDice //tests if the turnStateMachine is in RollDice assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof RollDice); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); } /** @@ -895,33 +865,29 @@ public void testChoosePowerCardToRollDice() { */ @Test public void testChoosePowerCardToSwap() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + powerCardStateMachine.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCard); //todo send the messages, to force a state change to swap //tests if the client is in Swap assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof Swap); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof Swap); } /** @@ -929,33 +895,29 @@ public void testChoosePowerCardToSwap() { */ @Test public void testChoosePowerCardToShield() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + powerCardStateMachine.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCard); //todo send the messages, to force a state change to shield //tests if the client is in Shield assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof Shield); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof Shield); } /** @@ -963,33 +925,29 @@ public void testChoosePowerCardToShield() { */ @Test public void testStayInShield() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in Shield - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(shield); - assertTrue(powerCardStateMachine1.getState() instanceof Shield); + powerCardStateMachine.gotoState(shield); + assertTrue(powerCardStateMachine.getState() instanceof Shield); //todo send the messages, which dont force a statechange //tests if the client is in PlayPowerCard assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof PlayPowerCard); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof PlayPowerCard); } /** @@ -997,20 +955,17 @@ public void testStayInShield() { */ @Test public void testShieldToPowerCardEndState() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in Shield PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); @@ -1021,8 +976,8 @@ public void testShieldToPowerCardEndState() { //tests if the client is in PlayPowerCard assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } /** @@ -1030,32 +985,28 @@ public void testShieldToPowerCardEndState() { */ @Test public void testSwapToPowerCardEndState() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in Swap - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(swap); - assertTrue(powerCardStateMachine1.getState() instanceof Swap); + powerCardStateMachine.gotoState(swap); + assertTrue(powerCardStateMachine.getState() instanceof Swap); //todo send the message to force the statechange //tests if the client is in PlayPowerCard assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } /** @@ -1063,24 +1014,21 @@ public void testSwapToPowerCardEndState() { */ @Test public void testNoPieceInWaitingPiece() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + turnStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); //Todo test other messages, that there is no state change @@ -1088,9 +1036,9 @@ public void testNoPieceInWaitingPiece() { clientGameLogic.receive(waitPiece); assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); } /** @@ -1098,24 +1046,21 @@ public void testNoPieceInWaitingPiece() { */ @Test public void testNoPieceInSelectedPiece() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); //Todo test other messages, that there is no state change @@ -1123,9 +1068,9 @@ public void testNoPieceInSelectedPiece() { clientGameLogic.receive(selectPiece); assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); } /** @@ -1133,24 +1078,21 @@ public void testNoPieceInSelectedPiece() { */ @Test public void testNoPieceInStartPiece() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); //Todo test other messages, that there is no state change @@ -1158,9 +1100,9 @@ public void testNoPieceInStartPiece() { clientGameLogic.receive(startPiece); assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); } /** @@ -1168,24 +1110,21 @@ public void testNoPieceInStartPiece() { */ @Test public void testNoPieceInWait() { - //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); //Todo test other messages, that there is no state change @@ -1193,8 +1132,8 @@ public void testNoPieceInWait() { clientGameLogic.receive(noTurn); assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof Waiting); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof Waiting); } /** @@ -1207,26 +1146,23 @@ public void testStayInWaitingPiece() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(waitingPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); } /** @@ -1239,25 +1175,22 @@ public void testWaitingPieceInChoosePieceEndState() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(waitingPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); //Todo send the message to the clientGameLogic to force a state change assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof MovePiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); } /** @@ -1270,26 +1203,23 @@ public void testStayInSelectedPiece() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); - //sends the choosePieceStatemachine in SelectPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(selectPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + //sends the choosePieceStatemachine in SelectPiece; + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); //Todo send all server messages which dont force a state change here assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); } /** @@ -1302,25 +1232,22 @@ public void testSelectedPieceInChoosePieceEndState() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in SelectPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(selectPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); //Todo send the message which force a state change assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof MovePiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); } /** @@ -1333,26 +1260,23 @@ public void testStayInStartPiece() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(startPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); //todo send all messages which dont force a state change assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); } /** @@ -1365,25 +1289,22 @@ public void testStartPieceToChoosePieceEndState() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(startPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); //Todo send the message which force a state change assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof MovePiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); } /** From 2cfa328c4cd5313fb05361fff4fb77d0698442dc Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 01:50:02 +0100 Subject: [PATCH 30/44] added some more testmethods --- .../client/clientState/ClientStateTest.java | 2 - .../server/serverState/ServerStateTest.java | 389 +++++++++++++++--- 2 files changed, 321 insertions(+), 70 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 25fe769a..13833527 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -20,8 +20,6 @@ */ public class ClientStateTest { - - //sets the variables for the states private Animation animation; private AudioSettings audioSettings; diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index edf40cd1..15b1c7b1 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -3,61 +3,18 @@ import org.junit.Before; import org.junit.Test; import pp.mdga.game.Game; -import pp.mdga.message.client.AnimationEnd; -import pp.mdga.message.client.ClientMessage; -import pp.mdga.message.client.ClientStartGame; -import pp.mdga.message.client.DeselectTSK; -import pp.mdga.message.client.ForceContinueGame; -import pp.mdga.message.client.ForceStartGame; -import pp.mdga.message.client.JoinServer; -import pp.mdga.message.client.LeaveGame; -import pp.mdga.message.client.LobbyNotReady; -import pp.mdga.message.client.LobbyReady; -import pp.mdga.message.client.NoPowerCard; -import pp.mdga.message.client.RequestBriefing; -import pp.mdga.message.client.RequestDice; -import pp.mdga.message.client.RequestMove; -import pp.mdga.message.client.RequestPlayCard; -import pp.mdga.message.client.SelectCard; -import pp.mdga.message.client.SelectTSK; -import pp.mdga.message.client.SelectedPieces; +import pp.mdga.message.client.*; import pp.mdga.message.server.ServerMessage; -import pp.mdga.server.Animation; -import pp.mdga.server.Ceremony; -import pp.mdga.server.ChoosePiece; -import pp.mdga.server.ChoosePieceStateMachine; -import pp.mdga.server.DetermineStartPlayer; -import pp.mdga.server.FirstRoll; -import pp.mdga.server.GameState; -import pp.mdga.server.GameStateMachine; -import pp.mdga.server.Interrupt; -import pp.mdga.server.Lobby; -import pp.mdga.server.MovePiece; -import pp.mdga.server.NoPiece; -import pp.mdga.server.PlayPowerCard; -import pp.mdga.server.PowerCard; -import pp.mdga.server.RollDice; -import pp.mdga.server.RollDiceMachine; -import pp.mdga.server.SecondRoll; -import pp.mdga.server.SelectPiece; -import pp.mdga.server.ServerAutomaton; -import pp.mdga.server.ServerGameLogic; -import pp.mdga.server.ServerSender; -import pp.mdga.server.NoTurn; -import pp.mdga.server.StartPiece; -import pp.mdga.server.ThirdRoll; -import pp.mdga.server.Turn; -import pp.mdga.server.TurnStateMachine; -import pp.mdga.server.WaitingPiece; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import pp.mdga.message.server.WaitPiece; +import pp.mdga.server.*; +import static org.junit.Assert.*; +/** + * TODO + */ public class ServerStateTest { + //Todo private ServerGameLogic logic; private AnimationEnd animationEnd; private ClientStartGame clientStartGame; @@ -78,9 +35,11 @@ public class ServerStateTest { private SelectTSK selectTSK; private ClientMessage[] clientMessages; + //Todo private int from; private int fromHost; + //Todo private GameStateMachine gameStateMachine; private TurnStateMachine turnStateMachine; private RollDiceMachine rollDiceMachine; @@ -109,6 +68,9 @@ public class ServerStateTest { private Turn turn; private WaitingPiece waitingPiece; + /** + * TODO + */ @Before public void setUp() { @@ -599,6 +561,14 @@ public void testFirstRollToRollDiceEndState() { assertTrue(rollDiceMachine.getState() instanceof FirstRoll); //TODO 2 Möglichkeiten + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); } /** @@ -638,7 +608,31 @@ public void testFirstRollToSecondRoll() { */ @Test public void testSecondRollToRollDiceEndState() { - // UC-ServerState-24 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in SecondRoll + rollDiceMachine.gotoState(secondRoll); + assertTrue(rollDiceMachine.getState() instanceof SecondRoll); + + //Todo + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); } /** @@ -659,9 +653,9 @@ public void testSecondRollToThirdRoll() { turnStateMachine.gotoState(rollDice); assertTrue(turnStateMachine.getState() instanceof RollDice); - //sends the RollDiceMachine in FirstRoll - rollDiceMachine.gotoState(firstRoll); - assertTrue(rollDiceMachine.getState() instanceof FirstRoll); + //sends the RollDiceMachine in SecondRoll + rollDiceMachine.gotoState(secondRoll); + assertTrue(rollDiceMachine.getState() instanceof SecondRoll); //Todo player has no figures to move and had no 6 @@ -678,7 +672,31 @@ public void testSecondRollToThirdRoll() { */ @Test public void testThirdRollToRollDiceEndState() { - // UC-ServerState-26 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in ThirdRoll + rollDiceMachine.gotoState(thirdRoll); + assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); + + //Todo + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); } /** @@ -687,7 +705,23 @@ public void testThirdRollToRollDiceEndState() { */ @Test public void testThirdRollToTurnEndState() { - // UC-ServerState-27 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in ThirdRoll + rollDiceMachine.gotoState(thirdRoll); + assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); + + //Todo } /** @@ -696,7 +730,30 @@ public void testThirdRollToTurnEndState() { */ @Test public void testNoPieceToWaitingPiece() { - // UC-ServerState-28 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //TODO + + //tests if the server is in WaitingPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + } /** @@ -705,7 +762,29 @@ public void testNoPieceToWaitingPiece() { */ @Test public void testNoPieceToNoTurn() { - // UC-ServerState-29 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //TODO + + //tests if the server is in NoTurn + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoTurn); } /** @@ -714,7 +793,23 @@ public void testNoPieceToNoTurn() { */ @Test public void testNoTurnToTurnEndState() { - // UC-ServerState-30 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoTurn + choosePieceStateMachine.gotoState(noTurn); + assertTrue(choosePieceStateMachine.getState() instanceof NoTurn); + + //TODO } /** @@ -723,7 +818,29 @@ public void testNoTurnToTurnEndState() { */ @Test public void testStayInWaitingPiece() { - // UC-ServerState-31 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in WaitingPiece + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + + //TODO + + //tests if the server is in WaitingPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); } /** @@ -732,7 +849,23 @@ public void testStayInWaitingPiece() { */ @Test public void testWaitingPieceToMovePiece() { - // UC-ServerState-32 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in WaitingPiece + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + + //TODO } /** @@ -741,7 +874,29 @@ public void testWaitingPieceToMovePiece() { */ @Test public void testNoPieceToSelectPiece() { - // UC-ServerState-33 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //TODO + + //tests if the server is in SelectPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); } /** @@ -750,7 +905,29 @@ public void testNoPieceToSelectPiece() { */ @Test public void testNoPieceToStartPiece() { - // UC-ServerState-34 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //TODO + + //tests if the server is in StartPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); } /** @@ -759,7 +936,29 @@ public void testNoPieceToStartPiece() { */ @Test public void testStayInSelectPiece() { - // UC-ServerState-35 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in SelectPiece + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + + //TODO + + //tests if the server is in SelectPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); } /** @@ -768,7 +967,23 @@ public void testStayInSelectPiece() { */ @Test public void testSelectPieceToMovePiece() { - // UC-ServerState-36 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in SelectPiece + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + + //TODO } /** @@ -777,7 +992,29 @@ public void testSelectPieceToMovePiece() { */ @Test public void testStayInStartPiece() { - // UC-ServerState-37 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + + //TODO + + //tests if the server is in StartPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); } /** @@ -786,6 +1023,22 @@ public void testStayInStartPiece() { */ @Test public void testStartPieceToMovePiece() { - // UC-ServerState-38 + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + + //TODO } } From ce528457a5b9e8feb4f401771b1e1a6a303c3a50 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 02:30:43 +0100 Subject: [PATCH 31/44] added javadocs --- .../client/clientState/ClientStateTest.java | 2 +- .../server/serverState/ServerStateTest.java | 52 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 13833527..7d45305e 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertTrue; /** - * this test-class tests the testcases T232-T239 TODO + * this test-class tests the testcases T170-T239 */ public class ClientStateTest { diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 15b1c7b1..5d11bbce 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.*; /** - * TODO + * this test-class tests the Testcases T132-T169 */ public class ServerStateTest { @@ -149,11 +149,18 @@ public void send(int id, ServerMessage msg) { interrupt = new Interrupt(serverAutomaton, logic, gameState); } + /** + * this test-method tests, that the server, when initialized, is in the Lobby-state + */ @Test public void testInitialStateServerState() { assertTrue(serverAutomaton.getState() instanceof Lobby); } + /** + * this method tests that the server, if all players are ready and the startGameMessage is issued, + * changes into the DetermineStartPlayer-state + */ @Test public void testLobbyToDetermineStartPlayer() { //sends the server in the lobby-state @@ -170,6 +177,9 @@ public void testLobbyToDetermineStartPlayer() { assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); } + /** + * this method tests, that the server stays in the Lobby + */ @Test public void testStayInLobby() { //sends the server in the lobby-state @@ -198,6 +208,9 @@ public void testStayInLobby() { assertTrue(serverAutomaton.getState() instanceof Lobby); } + /** + * this method tests, that the server can go into the interrupt-state + */ @Test public void testServerGameSubStatesToInterrupt() { //sends the server in the gameState @@ -225,6 +238,9 @@ public void testServerGameToCeremony() { assertTrue(serverAutomaton.getState() instanceof Ceremony); } + /** + * this method tests that the server goes back to the Game, when the ForceStartGame-message is issued + */ @Test public void testInterruptToGameContinue() { //sends the server in the Interrupt-State @@ -238,6 +254,9 @@ public void testInterruptToGameContinue() { assertTrue(serverAutomaton.getState() instanceof GameState); } + /** + * this method tests, that the server goes back to the game, if the missing client has reconnected + */ @Test public void testInterruptToGameReconnect() { //sends the server in the Interrupt-State @@ -250,6 +269,9 @@ public void testInterruptToGameReconnect() { assertTrue(serverAutomaton.getState() instanceof GameState); } + /** + * this method tests, that th e server continues with the game, if there is no time left on the timer + */ @Test public void testInterruptToGameTimer() { //sends the server in the Interrupt-State @@ -262,12 +284,18 @@ public void testInterruptToGameTimer() { assertTrue(serverAutomaton.getState() instanceof GameState); } + /** + * this method tests, that the server closes, if the ceremony has ended + */ @Test public void testCeremonyToServerStateEndState() { // TODO: Implement test logic for transition from Ceremony to Server State End State // TODO how???? } + /** + * this method tests that the server stays in DetermineStartPlayer, when issued messages + */ @Test public void testDetermineStartPlayerToDetermineStartPlayer1() { //sends the server in Game-State @@ -285,6 +313,9 @@ public void testDetermineStartPlayerToDetermineStartPlayer1() { assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); } + /** + * this method tests that the server stays in DetermineStartPlayer, when all players are ranked and two of the highest are even + */ @Test public void testDetermineStartPlayerToDetermineStartPlayer2() { //sends the server in Game-State @@ -302,6 +333,9 @@ public void testDetermineStartPlayerToDetermineStartPlayer2() { assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); } + /** + * this method tests that the server goes into Animation-state, if there is an order + */ @Test public void testDetermineStartPlayerToAnimation() { //sends the server in Game-State @@ -319,6 +353,10 @@ public void testDetermineStartPlayerToAnimation() { assertTrue(gameStateMachine.getState() instanceof Animation); } + /** + * tests that the server goes from the animation-state into PowerCardState, if the animation in the client has ended + * and all players have issued a animationEndMessage + */ @Test public void testAnimationToPowerCard() { //sends the server in Game-State @@ -345,6 +383,10 @@ public void testAnimationToPowerCard() { assertTrue(turnStateMachine.getState() instanceof PowerCard); } + /** + * this method tests that the server changes it's state from the turn-state to the animation-state, if there are at + * least two player left + */ @Test public void testTurnToAnimation() { //sends the server in Game-State @@ -362,6 +404,10 @@ public void testTurnToAnimation() { assertTrue(gameStateMachine.getState() instanceof Animation); } + /** + * this method tests that the server changes it's state from the turn-state to the ceremony-state, + * if there is only one player left + */ @Test public void testTurnToGameEndState() { //sends the server in Game-State @@ -378,6 +424,10 @@ public void testTurnToGameEndState() { assertTrue(serverAutomaton.getState() instanceof Ceremony); } + /** + * this method tests that the server don't change it's state whe issued with messages, + * which don't implicate a statechange + */ @Test public void testStayInPowerCard() { //sends the server in Game-State From 15d1c36dad25d917a5e2996773ee3d3350c9d47f Mon Sep 17 00:00:00 2001 From: Hanno Fleischer Date: Mon, 25 Nov 2024 11:19:17 +0100 Subject: [PATCH 32/44] added an ArrayList of Player in game and added the received methods in clientgamelogic --- .../java/pp.mdga/client/ClientGameLogic.java | 165 +++++++++++++++++- .../src/main/java/pp.mdga/game/Game.java | 13 ++ .../src/main/java/pp.mdga/game/Player.java | 19 ++ 3 files changed, 196 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java index dcad3574..afb8d98f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java @@ -2,8 +2,36 @@ import pp.mdga.game.Game; import pp.mdga.message.client.ClientMessage; +import pp.mdga.message.server.ActivePlayer; +import pp.mdga.message.server.AnyPiece; +import pp.mdga.message.server.Briefing; +import pp.mdga.message.server.CeremonyMessage; +import pp.mdga.message.server.Dice; +import pp.mdga.message.server.DiceAgain; +import pp.mdga.message.server.DiceNow; +import pp.mdga.message.server.EndOfTurn; +import pp.mdga.message.server.LobbyAccept; +import pp.mdga.message.server.LobbyDeny; +import pp.mdga.message.server.LobbyPlayerJoin; +import pp.mdga.message.server.LobbyPlayerLeave; +import pp.mdga.message.server.MoveMessage; +import pp.mdga.message.server.NoTurn; +import pp.mdga.message.server.PauseGame; +import pp.mdga.message.server.PlayCard; +import pp.mdga.message.server.PossibleCard; +import pp.mdga.message.server.PossiblePiece; +import pp.mdga.message.server.RankingResponse; +import pp.mdga.message.server.RankingRollAgain; +import pp.mdga.message.server.ReconnectBriefing; +import pp.mdga.message.server.ResumeGame; +import pp.mdga.message.server.ServerInterpreter; +import pp.mdga.message.server.ServerStartGame; +import pp.mdga.message.server.StartPiece; +import pp.mdga.message.server.UpdateReady; +import pp.mdga.message.server.UpdateTSK; +import pp.mdga.message.server.WaitPiece; -public class ClientGameLogic { +public class ClientGameLogic implements ServerInterpreter { static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName()); private Game game; @@ -32,4 +60,139 @@ public Game getGame(){ public ClientState getState(){ return state; } + + @Override + public void received(ActivePlayer msg) { + + } + + @Override + public void received(AnyPiece msg) { + + } + + @Override + public void received(Briefing msg) { + + } + + @Override + public void received(CeremonyMessage msg) { + + } + + @Override + public void received(Dice msg) { + + } + + @Override + public void received(DiceAgain msg) { + + } + + @Override + public void received(DiceNow msg) { + + } + + @Override + public void received(EndOfTurn msg) { + + } + + @Override + public void received(LobbyAccept msg) { + + } + + @Override + public void received(LobbyDeny msg) { + + } + + @Override + public void received(LobbyPlayerJoin msg) { + + } + + @Override + public void received(LobbyPlayerLeave msg) { + + } + + @Override + public void received(MoveMessage msg) { + + } + + @Override + public void received(NoTurn msg) { + + } + + @Override + public void received(PauseGame msg) { + + } + + @Override + public void received(PlayCard msg) { + + } + + @Override + public void received(PossibleCard msg) { + + } + + @Override + public void received(PossiblePiece msg) { + + } + + @Override + public void received(RankingResponse msg) { + + } + + @Override + public void received(RankingRollAgain msg) { + + } + + @Override + public void received(ReconnectBriefing msg) { + + } + + @Override + public void received(ResumeGame msg) { + + } + + @Override + public void received(ServerStartGame msg) { + + } + + @Override + public void received(StartPiece msg) { + + } + + @Override + public void received(UpdateReady msg) { + + } + + @Override + public void received(UpdateTSK msg) { + + } + + @Override + public void received(WaitPiece msg) { + + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java index 01a178cb..2c67c651 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java @@ -19,6 +19,7 @@ public class Game { private Board board; private Color activeColor; private List order; + private final ArrayList playerList = new ArrayList<>(4); private final ArrayList observers = new ArrayList<>(); private Player startPlayer; @@ -400,4 +401,16 @@ public Piece getPieceThroughIdentifier(String identifier) { int index = Integer.parseInt(parts[1]); return board.getPlayerData().get(color).getPieces()[index]; } + + public ArrayList getPlayerList() { + return playerList; + } + + public void addPlayerToList(Player player) { + playerList.add(player); + } + + public void removePlayerFromList(Player player) { + playerList.remove(player); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java index e9e16645..c7b6246e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java @@ -11,6 +11,7 @@ public class Player { private Statistic playerStatistic; private ArrayList handCards; private final int id; + private Color color; /** * This constructor constructs a new Player object @@ -88,4 +89,22 @@ public BonusCard removeHandCard(BonusCard card) { public int getId() { return id; } + + /** + * This method returns the color of the player + * + * @return the color of the player + */ + public Color getColor() { + return color; + } + + /** + * This method sets the color of the player + * + * @param color the new color of the player + */ + public void setColor(Color color) { + this.color = color; + } } From 47055126484e19f88aa78eba5f27a945a0c10467 Mon Sep 17 00:00:00 2001 From: Hanno Fleischer Date: Mon, 25 Nov 2024 12:52:22 +0100 Subject: [PATCH 33/44] added getter for ArrayList Player in Game and created a flag for ready status in Player --- .../src/main/java/pp.mdga/game/Game.java | 11 ++++++- .../src/main/java/pp.mdga/game/Player.java | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java index 2c67c651..580e37ff 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java @@ -364,7 +364,7 @@ public void setStartPlayer(Player startPlayer) { /** * This method returns the all ready state. * - * @return the all ready state + * @return the already state */ public Boolean allReady() { return allReady; @@ -413,4 +413,13 @@ public void addPlayerToList(Player player) { public void removePlayerFromList(Player player) { playerList.remove(player); } + + public Player getPlayerFromList(String name) { + for (Player player : playerList) { + if (player.getName().equals(name)) { + return player; + } + } + return null; + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java index c7b6246e..7371cf7b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java @@ -12,6 +12,7 @@ public class Player { private ArrayList handCards; private final int id; private Color color; + private boolean isReady; /** * This constructor constructs a new Player object @@ -22,6 +23,18 @@ public Player(int id) { handCards = new ArrayList<>(); } + /** + * This constructor constructs a new Player object + * + * @param name the name of the player + */ + public Player(String name) { + this.name = name; + playerStatistic = new Statistic(); + handCards = new ArrayList<>(); + id = 0; + } + /** * This method returns the give name of the Player * @@ -107,4 +120,22 @@ public Color getColor() { public void setColor(Color color) { this.color = color; } + + /** + * This method returns if the player is ready + * + * @return true if the player is ready, false otherwise + */ + public boolean isReady() { + return isReady; + } + + /** + * This method sets the player to ready + * + * @param ready true if the player is ready, false otherwise + */ + public void setReady(boolean ready) { + isReady = ready; + } } From d15242f816fbbf48c83ccfc2d4378332b4427f8e Mon Sep 17 00:00:00 2001 From: Hanno Fleischer Date: Mon, 25 Nov 2024 13:42:00 +0100 Subject: [PATCH 34/44] added static methods to construct a PlayCard message for each card type --- .../java/pp.mdga/message/server/PlayCard.java | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java index 7d088143..743bcbe8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java @@ -18,26 +18,60 @@ public class PlayCard extends ServerMessage { */ private final String pieceIdentifier; + private final String pieceIdentifierEnemy; + /** * Constructs a new PlayCard message. * * @param card the card that should be played * @param pieceIdentifier the identifier of the piece that should be moved */ - public PlayCard(BonusCard card, String pieceIdentifier) { + public PlayCard(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) { super(); this.card = card; this.pieceIdentifier = pieceIdentifier; + this.pieceIdentifierEnemy = pieceIdentifierEnemy; } /** * Default constructor for serialization purposes. */ private PlayCard() { + this.pieceIdentifierEnemy = null; card = null; pieceIdentifier = null; } + /** + * Creates a new PlayCard message for the given card and piece identifier. + * + * @param pieceIdentifier the identifier of the piece of the player that should be affected + * @param pieceIdentifierEnemy the identifier of the enemy piece that should be affected + * @return a new PlayCard message + */ + public static PlayCard swap(String pieceIdentifier, String pieceIdentifierEnemy) { + return new PlayCard(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy); + } + + /** + * Creates a new PlayCard message for the given card and piece identifier. + * + * @return a new PlayCard message + */ + public static PlayCard turbo() { + return new PlayCard(BonusCard.TURBO, null, null); + } + + /** + * Creates a new PlayCard message for the given card and piece identifier. + * + * @param pieceIdentifier the identifier of the piece of the player that should be affected + * @return a new PlayCard message + */ + public static PlayCard shield(String pieceIdentifier) { + return new PlayCard(BonusCard.SHIELD, pieceIdentifier, null); + } + /** * Returns the card that should be played. * @@ -56,6 +90,15 @@ public String getPieceIdentifier() { return pieceIdentifier; } + /** + * Returns the identifier of the enemy piece that should be moved. + * + * @return the identifier of the enemy piece that should be moved + */ + public String getPieceIdentifierEnemy() { + return pieceIdentifierEnemy; + } + /** * Accepts a visitor to process this message. * From 3be037d5903c7c26f49fc4077d8a59a29a8888f4 Mon Sep 17 00:00:00 2001 From: Hanno Fleischer Date: Mon, 25 Nov 2024 15:07:43 +0100 Subject: [PATCH 35/44] added two lists in PossiblePiece in order to differentiate between own and enemy pieces --- .../pp.mdga/message/server/PossiblePiece.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java index 4755b9c8..27ddaf22 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java @@ -2,6 +2,7 @@ import com.jme3.network.serializing.Serializable; +import java.sql.PseudoColumnUsage; import java.util.ArrayList; import java.util.List; @@ -29,6 +30,32 @@ public PossiblePiece() { possibleEnemyPieces = new ArrayList<>(); } + /** + * Swap the possible pieces + * + * @param possibleOwnPieces the list of possible own pieces + * @param possibleEnemyPieces the list of possible enemy pieces + * @return the swapped possible pieces + */ + public static PossiblePiece swapPossiblePieces(ArrayList possibleOwnPieces, ArrayList possibleEnemyPieces) { + PossiblePiece possiblePiece = new PossiblePiece(); + possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces); + possiblePiece.possibleEnemyPieces.addAll(possibleEnemyPieces); + return possiblePiece; + } + + /** + * Get the possible pieces for the shield + * + * @param possibleOwnPieces the list of possible own pieces + * @return the possible pieces for the shield + */ + public static PossiblePiece shieldPossiblePieces(ArrayList possibleOwnPieces){ + PossiblePiece possiblePiece = new PossiblePiece(); + possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces); + return possiblePiece; + } + /** * Add a piece to the list of possible pieces * @@ -50,10 +77,17 @@ public void addEnemyPossiblePiece(String piece) { /** Getter for the list of possible pieces * @return the list of possible pieces */ - public List getPossiblePieces() { + public List getOwnPossiblePieces() { return possibleOwnPieces; } + /** Getter for the list of possible enemy pieces + * @return the list of possible enemy pieces + */ + public List getEnemyPossiblePieces() { + return possibleEnemyPieces; + } + /** * Accepts a visitor to process this message. * From 31b449662f364e778d4f796130955cd1526d7dd3 Mon Sep 17 00:00:00 2001 From: Hanno Fleischer Date: Mon, 25 Nov 2024 15:09:24 +0100 Subject: [PATCH 36/44] added two Pieces in RequestPlayCard in order to differentiate between own and enemy pieces --- .../message/client/RequestPlayCard.java | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java index d2149837..8c21b0b0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java @@ -16,17 +16,20 @@ public class RequestPlayCard extends ClientMessage { /** * The identifier of the piece. */ - private final String pieceIdentifier; + private final String ownPieceIdentifier; + + private final String enemyPieceIdentifier; /** * Constructs a new RequestPlayCard instance. * * @param card the bonus card to be played - * @param pieceIdentifier the identifier of the piece + * @param ownPieceIdentifier the identifier of the piece */ - public RequestPlayCard(BonusCard card, String pieceIdentifier) { - this.pieceIdentifier = pieceIdentifier; + public RequestPlayCard(BonusCard card, String ownPieceIdentifier, String enemyPieceIdentifier) { + this.ownPieceIdentifier = ownPieceIdentifier; this.card = card; + this.enemyPieceIdentifier = enemyPieceIdentifier; } /** @@ -34,7 +37,23 @@ public RequestPlayCard(BonusCard card, String pieceIdentifier) { */ private RequestPlayCard() { card = null; - pieceIdentifier = null; + ownPieceIdentifier = null; + enemyPieceIdentifier = null; + } + + /** + * Creates a new RequestPlayCard instance for a given bonus card. + * + * @param ownPieceIdentifier the identifier of the piece + * @param enemyPieceIdentifier the identifier of the enemy piece + * @return a new RequestPlayCard instance + */ + public static RequestPlayCard requestPlaySwap(String ownPieceIdentifier, String enemyPieceIdentifier){ + return new RequestPlayCard(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier); + } + + public static RequestPlayCard requestPlayShield(String ownPieceIdentifier){ + return new RequestPlayCard(BonusCard.SHIELD, ownPieceIdentifier, null); } /** @@ -51,8 +70,17 @@ public BonusCard getCard() { * * @return the piece identifier */ - public String getPieceIdentifier() { - return pieceIdentifier; + public String getOwnPieceIdentifier() { + return ownPieceIdentifier; + } + + /** + * Gets the enemy piece identifier associated with this request. + * + * @return the enemy piece identifier + */ + public String getEnemyPieceIdentifier() { + return enemyPieceIdentifier; } /** From 52d9fff4935422f43433b3eab4577ad9169c9f15 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Mon, 25 Nov 2024 15:43:29 +0100 Subject: [PATCH 37/44] deleted server state automaton --- .../java/pp.mdga/client/ClientGameLogic.java | 28 -- .../src/main/java/pp.mdga/game/Game.java | 2 - .../pp.mdga/message/server/ActivePlayer.java | 71 ---- .../java/pp.mdga/message/server/AnyPiece.java | 73 ---- .../java/pp.mdga/message/server/Briefing.java | 46 --- .../message/server/CeremonyMessage.java | 46 --- .../java/pp.mdga/message/server/Dice.java | 110 ------ .../pp.mdga/message/server/DiceAgain.java | 46 --- .../java/pp.mdga/message/server/DiceNow.java | 46 --- .../pp.mdga/message/server/EndOfTurn.java | 46 --- .../pp.mdga/message/server/LobbyAccept.java | 46 --- .../pp.mdga/message/server/LobbyDeny.java | 46 --- .../message/server/LobbyPlayerJoin.java | 71 ---- .../message/server/LobbyPlayerLeave.java | 88 ----- .../pp.mdga/message/server/MoveMessage.java | 70 ---- .../java/pp.mdga/message/server/NoTurn.java | 46 --- .../pp.mdga/message/server/PauseGame.java | 46 --- .../java/pp.mdga/message/server/PlayCard.java | 131 ------- .../pp.mdga/message/server/PossibleCard.java | 74 ---- .../pp.mdga/message/server/PossiblePiece.java | 120 ------- .../message/server/RankingResponse.java | 46 --- .../message/server/RankingRollAgain.java | 46 --- .../message/server/ReconnectBriefing.java | 69 ---- .../pp.mdga/message/server/ResumeGame.java | 46 --- .../message/server/ServerInterpreter.java | 196 ----------- .../pp.mdga/message/server/ServerMessage.java | 31 -- .../message/server/ServerStartGame.java | 46 --- .../pp.mdga/message/server/StartPiece.java | 71 ---- .../pp.mdga/message/server/UpdateReady.java | 89 ----- .../pp.mdga/message/server/UpdateTSK.java | 87 ----- .../pp.mdga/message/server/WaitPiece.java | 46 --- .../main/java/pp.mdga/server/Animation.java | 16 - .../main/java/pp.mdga/server/Ceremony.java | 7 - .../main/java/pp.mdga/server/ChoosePiece.java | 9 - .../server/ChoosePieceStateMachine.java | 12 - .../pp.mdga/server/DetermineStartPlayer.java | 45 --- .../main/java/pp.mdga/server/FirstRoll.java | 28 -- .../main/java/pp.mdga/server/GameState.java | 69 ---- .../java/pp.mdga/server/GameStateMachine.java | 26 -- .../main/java/pp.mdga/server/Interrupt.java | 22 -- .../src/main/java/pp.mdga/server/Lobby.java | 94 ----- .../main/java/pp.mdga/server/MovePiece.java | 7 - .../src/main/java/pp.mdga/server/NoPiece.java | 55 --- .../src/main/java/pp.mdga/server/NoTurn.java | 14 - .../main/java/pp.mdga/server/Observer.java | 5 - .../java/pp.mdga/server/PlayPowerCard.java | 7 - .../main/java/pp.mdga/server/PowerCard.java | 54 --- .../main/java/pp.mdga/server/RollDice.java | 9 - .../java/pp.mdga/server/RollDiceMachine.java | 12 - .../main/java/pp.mdga/server/SecondRoll.java | 25 -- .../main/java/pp.mdga/server/SelectPiece.java | 22 -- .../java/pp.mdga/server/ServerAutomaton.java | 27 -- .../java/pp.mdga/server/ServerGameLogic.java | 145 -------- .../java/pp.mdga/server/ServerSender.java | 7 - .../main/java/pp.mdga/server/ServerState.java | 324 ------------------ .../pp.mdga/server/ServerStateMachine.java | 234 ------------- .../main/java/pp.mdga/server/StartPiece.java | 21 -- .../main/java/pp.mdga/server/ThirdRoll.java | 25 -- .../src/main/java/pp.mdga/server/Turn.java | 34 -- .../java/pp.mdga/server/TurnStateMachine.java | 12 - .../java/pp.mdga/server/WaitingPiece.java | 23 -- 61 files changed, 3415 deletions(-) delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePieceStateMachine.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/GameStateMachine.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Observer.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/PlayPowerCard.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/RollDiceMachine.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ServerAutomaton.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/TurnStateMachine.java delete mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java index afb8d98f..e1d1b407 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java @@ -2,34 +2,6 @@ import pp.mdga.game.Game; import pp.mdga.message.client.ClientMessage; -import pp.mdga.message.server.ActivePlayer; -import pp.mdga.message.server.AnyPiece; -import pp.mdga.message.server.Briefing; -import pp.mdga.message.server.CeremonyMessage; -import pp.mdga.message.server.Dice; -import pp.mdga.message.server.DiceAgain; -import pp.mdga.message.server.DiceNow; -import pp.mdga.message.server.EndOfTurn; -import pp.mdga.message.server.LobbyAccept; -import pp.mdga.message.server.LobbyDeny; -import pp.mdga.message.server.LobbyPlayerJoin; -import pp.mdga.message.server.LobbyPlayerLeave; -import pp.mdga.message.server.MoveMessage; -import pp.mdga.message.server.NoTurn; -import pp.mdga.message.server.PauseGame; -import pp.mdga.message.server.PlayCard; -import pp.mdga.message.server.PossibleCard; -import pp.mdga.message.server.PossiblePiece; -import pp.mdga.message.server.RankingResponse; -import pp.mdga.message.server.RankingRollAgain; -import pp.mdga.message.server.ReconnectBriefing; -import pp.mdga.message.server.ResumeGame; -import pp.mdga.message.server.ServerInterpreter; -import pp.mdga.message.server.ServerStartGame; -import pp.mdga.message.server.StartPiece; -import pp.mdga.message.server.UpdateReady; -import pp.mdga.message.server.UpdateTSK; -import pp.mdga.message.server.WaitPiece; public class ClientGameLogic implements ServerInterpreter { static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName()); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java index 580e37ff..87669c71 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java @@ -2,8 +2,6 @@ import java.util.*; -import pp.mdga.server.Observer; - /** * The Game class represents the game state of the Ludo game. * It contains all the information needed to play the game. diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java deleted file mode 100644 index 551cd305..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java +++ /dev/null @@ -1,71 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; -import pp.mdga.game.Color; - -/** - * A message sent by the server to inform the clients about the active player. - */ -@Serializable -public class ActivePlayer extends ServerMessage { - /** - * The color of the active player. - */ - private final Color color; - - /** - * Constructor for ActivePlayer - * - * @param color the color of the active player - */ - public ActivePlayer(Color color) { - super(); - this.color = color; - } - - /** - * Default constructor for serialization purposes. - */ - private ActivePlayer() { - color = null; - } - - /** - * Getter for the color of the active player - * - * @return the color of the active player - */ - public Color getColor() { - return color; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return "ActivePlayer{color=" + color + '}'; - } - - /** - * Returns the key for the informational text associated with this message. - * - * @return the key for the informational text - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java deleted file mode 100644 index eaf69c6d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java +++ /dev/null @@ -1,73 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -import java.util.ArrayList; -import java.util.List; - -/** - * A message sent by the server to the active player containing a list of pieces that the player can move any piece of the list on the board. - */ -@Serializable -public class AnyPiece extends ServerMessage { - /** - * The list of pieces - */ - private final ArrayList piece; - - /** - * Constructor for AnyPiece - */ - public AnyPiece() { - super(); - piece = new ArrayList<>(); - } - - /** - * Add a piece to the list of pieces - * - * @param piece the piece to add - */ - public void addPiece(String piece) { - this.piece.add(piece); - } - - /** - * Getter for the list of pieces - * - * @return the list of pieces - */ - public List getPiece() { - return piece; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return "AnyPiece{piece=" + piece + '}'; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java deleted file mode 100644 index 86942872..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to the reconnected player to provide a briefing about the current game state. - */ -@Serializable -public class Briefing extends ServerMessage { - /** - * Constructs a new Briefing instance. - */ - public Briefing() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java deleted file mode 100644 index 10197038..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to indicate the beginning of the ceremony. - */ -@Serializable -public class CeremonyMessage extends ServerMessage { - /** - * Constructs a new Ceremony instance. - */ - public CeremonyMessage() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java deleted file mode 100644 index 6b4bc1ee..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java +++ /dev/null @@ -1,110 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -import java.util.List; - -/** - * A message sent by the server to the client to inform about the dice roll. - */ -@Serializable -public class Dice extends ServerMessage { - /** - * The eye of the dice - */ - private final int diceEye; - - /** - * The pieces that can be moved - */ - private final List moveablePieces; - - /** - * Constructor for Dice - * - * @param diceEye the eye of the dice - * @param moveablePieces the pieces that can be moved - */ - public Dice(int diceEye, List moveablePieces) { - super(); - this.diceEye = diceEye; - this.moveablePieces = moveablePieces; - } - - /** - * Default constructor for serialization purposes. - */ - private Dice() { - diceEye = 0; - moveablePieces = null; - } - - /** - * Constructor for inactivePlayer - * - * @param diceEye the eye of the dice - * @return a new Dice object - */ - public static Dice inactivePlayer(int diceEye) { - return new Dice(diceEye, null); - } - - /** - * Constructor for activePlayer - * - * @param diceEye the eye of the dice - * @param moveablePieces the pieces that can be moved - * @return a new Dice object - */ - public static Dice activePlayer(int diceEye, List moveablePieces) { - return new Dice(diceEye, moveablePieces); - } - - /** - * Getter for the eye of the dice - * - * @return the eye of the dice - */ - public int getDiceEye() { - return diceEye; - } - - /** - * Getter for the pieces that can be moved - * - * @return the pieces that can be moved - */ - public List getMoveablePieces() { - return moveablePieces; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java deleted file mode 100644 index c3402946..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to the active player to indicate that they can roll the dice again. - */ -@Serializable -public class DiceAgain extends ServerMessage { - /** - * Constructs a new DiceAgain instance. - */ - public DiceAgain() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java deleted file mode 100644 index b72f22a7..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to the active player to enable the dice now button. - */ -@Serializable -public class DiceNow extends ServerMessage { - /** - * Constructs a new DiceNow instance. - */ - public DiceNow() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java deleted file mode 100644 index d9ac9cb0..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to indicate the end of the turn of the active player. - */ -@Serializable -public class EndOfTurn extends ServerMessage { - /** - * Constructs a new EndOfTurn instance. - */ - public EndOfTurn() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java deleted file mode 100644 index d252148d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to indicate that the client has been accepted into the lobby. - */ -@Serializable -public class LobbyAccept extends ServerMessage { - /** - * Constructs a new LobbyAccept instance. - */ - public LobbyAccept() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java deleted file mode 100644 index 0717f814..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to deny a client's request to join the lobby. - */ -@Serializable -public class LobbyDeny extends ServerMessage { - /** - * Constructs a new LobbyDeny instance. - */ - public LobbyDeny() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java deleted file mode 100644 index 9472a150..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java +++ /dev/null @@ -1,71 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent from the server to the client indicating that a player has joined the lobby. - */ -@Serializable -public class LobbyPlayerJoin extends ServerMessage { - - /** - * The name of the player joining the lobby. - */ - private final String name; - - /** - * Constructs a new LobbyPlayerJoin instance with the specified player name. - * - * @param name the name of the player joining the lobby - */ - public LobbyPlayerJoin(String name) { - super(); - this.name = name; - } - - /** - * Default constructor for serialization purposes. - */ - private LobbyPlayerJoin() { - name = null; - } - - /** - * Returns the name of the player joining the lobby. - * - * @return the name of the player joining the lobby - */ - public String getName() { - return name; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java deleted file mode 100644 index f68b7054..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java +++ /dev/null @@ -1,88 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; -import pp.mdga.game.Color; - -/** - * A message sent by the server to indicate that a player has left the lobby. - */ -@Serializable -public class LobbyPlayerLeave extends ServerMessage { - /** - * The name of the player leaving the lobby. - */ - private final String name; - - /** - * The color associated with the player leaving the lobby. - */ - private final Color color; - - /** - * Constructs a new LobbyPlayerLeave instance with the specified player name and color. - * - * @param name the name of the player leaving the lobby - * @param color the color associated with the player leaving the lobby - */ - public LobbyPlayerLeave(String name, Color color) { - super(); - this.name = name; - this.color = color; - } - - /** - * Default constructor for serialization purposes. - */ - private LobbyPlayerLeave() { - name = null; - color = null; - } - - /** - * Returns the name of the player leaving the lobby. - * - * @return the name of the player leaving the lobby - */ - public String getName() { - return name; - } - - /** - * Returns the color associated with the player leaving the lobby. - * - * @return the color associated with the player leaving the lobby - */ - public Color getColor() { - return color; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java deleted file mode 100644 index 27dbe370..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java +++ /dev/null @@ -1,70 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to the client to move a piece on the board. - */ -@Serializable -public class MoveMessage extends ServerMessage { - /** - * The identifier of the piece that should be moved. - */ - private final String pieceIdentifier; - - /** - * Constructs a new MoveMessage instance. - * - * @param identifier the identifier of the piece that should be moved - */ - public MoveMessage(String identifier) { - super(); - this.pieceIdentifier = identifier; - } - - /** - * Default constructor for serialization purposes. - */ - private MoveMessage() { - pieceIdentifier = null; - } - - /** - * Returns the identifier of the piece that should be moved. - * - * @return the identifier of the piece that should be moved - */ - public String getIdentifier() { - return pieceIdentifier; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java deleted file mode 100644 index 8a412de4..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to the active player to indicate that he has no valid moves. - */ -@Serializable -public class NoTurn extends ServerMessage { - /** - * Constructs a new NoTurn instance. - */ - public NoTurn() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java deleted file mode 100644 index 19c95651..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to indicate that the game is paused. - */ -@Serializable -public class PauseGame extends ServerMessage { - /** - * Constructs a new PauseGame instance. - */ - public PauseGame() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java deleted file mode 100644 index 743bcbe8..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java +++ /dev/null @@ -1,131 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; -import pp.mdga.game.BonusCard; - -/** - * A message sent by the server to the active player to play a card. - */ -@Serializable -public class PlayCard extends ServerMessage { - /** - * The card that should be played. - */ - private final BonusCard card; - - /** - * The identifier of the piece that should be moved. - */ - private final String pieceIdentifier; - - private final String pieceIdentifierEnemy; - - /** - * Constructs a new PlayCard message. - * - * @param card the card that should be played - * @param pieceIdentifier the identifier of the piece that should be moved - */ - public PlayCard(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) { - super(); - this.card = card; - this.pieceIdentifier = pieceIdentifier; - this.pieceIdentifierEnemy = pieceIdentifierEnemy; - } - - /** - * Default constructor for serialization purposes. - */ - private PlayCard() { - this.pieceIdentifierEnemy = null; - card = null; - pieceIdentifier = null; - } - - /** - * Creates a new PlayCard message for the given card and piece identifier. - * - * @param pieceIdentifier the identifier of the piece of the player that should be affected - * @param pieceIdentifierEnemy the identifier of the enemy piece that should be affected - * @return a new PlayCard message - */ - public static PlayCard swap(String pieceIdentifier, String pieceIdentifierEnemy) { - return new PlayCard(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy); - } - - /** - * Creates a new PlayCard message for the given card and piece identifier. - * - * @return a new PlayCard message - */ - public static PlayCard turbo() { - return new PlayCard(BonusCard.TURBO, null, null); - } - - /** - * Creates a new PlayCard message for the given card and piece identifier. - * - * @param pieceIdentifier the identifier of the piece of the player that should be affected - * @return a new PlayCard message - */ - public static PlayCard shield(String pieceIdentifier) { - return new PlayCard(BonusCard.SHIELD, pieceIdentifier, null); - } - - /** - * Returns the card that should be played. - * - * @return the card that should be played - */ - public BonusCard getCard() { - return card; - } - - /** - * Returns the identifier of the piece that should be moved. - * - * @return the identifier of the piece that should be moved - */ - public String getPieceIdentifier() { - return pieceIdentifier; - } - - /** - * Returns the identifier of the enemy piece that should be moved. - * - * @return the identifier of the enemy piece that should be moved - */ - public String getPieceIdentifierEnemy() { - return pieceIdentifierEnemy; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java deleted file mode 100644 index 35df9bef..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java +++ /dev/null @@ -1,74 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; -import pp.mdga.game.BonusCard; - -import java.util.ArrayList; -import java.util.List; - -/** - * A message sent by the server to the client to indicate the possible cards that can be chosen. - */ -@Serializable -public class PossibleCard extends ServerMessage { - /** - * The list of possible cards. - */ - private final List possibleCards; - - /** - * Constructor for a PossibleCard instance. - */ - public PossibleCard() { - super(); - possibleCards = new ArrayList<>(); - } - - /** - * Add a possible card to the list of possible cards - * - * @param card the possible card to add - */ - public void addPossibleCard(BonusCard card) { - this.possibleCards.add(card); - } - - /** - * Getter for the list of possible cards - * - * @return the list of possible cards - */ - public List getPossibleCards() { - return possibleCards; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java deleted file mode 100644 index 27ddaf22..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java +++ /dev/null @@ -1,120 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -import java.sql.PseudoColumnUsage; -import java.util.ArrayList; -import java.util.List; - -/** - * A message sent by the server to the active player to give all possible pieces to choose from. - */ -@Serializable -public class PossiblePiece extends ServerMessage { - /** - * The list of possible own pieces - */ - private final List possibleOwnPieces; - - /** - * The list of possible enemy pieces - */ - private final List possibleEnemyPieces; - - /** - * Constructor for PossiblePiece - */ - public PossiblePiece() { - super(); - possibleOwnPieces = new ArrayList<>(); - possibleEnemyPieces = new ArrayList<>(); - } - - /** - * Swap the possible pieces - * - * @param possibleOwnPieces the list of possible own pieces - * @param possibleEnemyPieces the list of possible enemy pieces - * @return the swapped possible pieces - */ - public static PossiblePiece swapPossiblePieces(ArrayList possibleOwnPieces, ArrayList possibleEnemyPieces) { - PossiblePiece possiblePiece = new PossiblePiece(); - possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces); - possiblePiece.possibleEnemyPieces.addAll(possibleEnemyPieces); - return possiblePiece; - } - - /** - * Get the possible pieces for the shield - * - * @param possibleOwnPieces the list of possible own pieces - * @return the possible pieces for the shield - */ - public static PossiblePiece shieldPossiblePieces(ArrayList possibleOwnPieces){ - PossiblePiece possiblePiece = new PossiblePiece(); - possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces); - return possiblePiece; - } - - /** - * Add a piece to the list of possible pieces - * - * @param piece the piece to add - */ - public void addOwnPossiblePiece(String piece) { - this.possibleOwnPieces.add(piece); - } - - /** - * Add a piece to the list of possible enemy pieces - * - * @param piece the piece to add - */ - public void addEnemyPossiblePiece(String piece) { - this.possibleEnemyPieces.add(piece); - } - - /** Getter for the list of possible pieces - * @return the list of possible pieces - */ - public List getOwnPossiblePieces() { - return possibleOwnPieces; - } - - /** Getter for the list of possible enemy pieces - * @return the list of possible enemy pieces - */ - public List getEnemyPossiblePieces() { - return possibleEnemyPieces; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java deleted file mode 100644 index 9b5eda2f..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to all client to inform them about the current ranking. (only in DetermineStartPlayer) - */ -@Serializable -public class RankingResponse extends ServerMessage { - /** - * Constructs a new RankingResponse instance. - */ - public RankingResponse() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java deleted file mode 100644 index eaf06392..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to the clients to indicate that the ranking shall be rolled again. (only in DetermineStartPlayer) - */ -@Serializable -public class RankingRollAgain extends ServerMessage { - /** - * Constructs a new RankingRollAgain instance. - */ - public RankingRollAgain() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java deleted file mode 100644 index 5a72f341..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java +++ /dev/null @@ -1,69 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; -import pp.mdga.game.Game; - -/** - * A message sent by the server to a client that has reconnected to the game. (give the last saved model) - */ -@Serializable -public class ReconnectBriefing extends ServerMessage { - /** - * The game. - */ - private final Game game; - - /** - * Constructs a new ReconnectBriefing message. - */ - public ReconnectBriefing(Game game) { - super(); - this.game = game; - } - - /** - * Default constructor for serialization purposes. - */ - private ReconnectBriefing() { - this(null); - } - - /** - * Returns the game. - * - * @return the game - */ - public Game getGame() { - return game; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java deleted file mode 100644 index 1ebfd673..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to resume the game. - */ -@Serializable -public class ResumeGame extends ServerMessage { - /** - * Constructs a new ResumeGame instance. - */ - public ResumeGame() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java deleted file mode 100644 index c83abefd..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java +++ /dev/null @@ -1,196 +0,0 @@ -package pp.mdga.message.server; - -/** - * An interface for processing server messages. - * Implementations of this interface can be used to handle different types of server messages. - */ -public interface ServerInterpreter { - /** - * Handles an ActivePlayer message received from the server. - * - * @param msg the ActivePlayer message received - */ - void received(ActivePlayer msg); - - /** - * Handles an AnyPiece message received from the server. - * - * @param msg the AnyPiece message received - */ - void received(AnyPiece msg); - - /** - * Handles a Briefing message received from the server. - * - * @param msg the Briefing message received - */ - void received(Briefing msg); - - /** - * Handles a Ceremony message received from the server. - * - * @param msg the Ceremony message received - */ - void received(CeremonyMessage msg); - - /** - * Handles a Dice message received from the server. - * - * @param msg the Dice message received - */ - void received(Dice msg); - - /** - * Handles a DiceAgain message received from the server. - * - * @param msg the DiceAgain message received - */ - void received(DiceAgain msg); - - /** - * Handles a DiceNow message received from the server. - * - * @param msg the DiceNow message received - */ - void received(DiceNow msg); - - /** - * Handles an EndOfGame message received from the server. - * - * @param msg the EndOfGame message received - */ - void received(EndOfTurn msg); - - /** - * Handles a GameOver message received from the server. - * - * @param msg the GameOver message received - */ - void received(LobbyAccept msg); - - /** - * Handles a LobbyDeny message received from the server. - * - * @param msg the LobbyDeny message received - */ - void received(LobbyDeny msg); - - /** - * Handles a LobbyPlayerJoin message received from the server. - * - * @param msg the LobbyPlayerJoin message received - */ - void received(LobbyPlayerJoin msg); - - /** - * Handles a LobbyPlayerLeave message received from the server. - * - * @param msg the LobbyPlayerLeave message received - */ - void received(LobbyPlayerLeave msg); - - /** - * Handles a MoveMessage message received from the server. - * - * @param msg the MoveMessage message received - */ - void received(MoveMessage msg); - - /** - * Handles a NoTurn message received from the server. - * - * @param msg the NoTurn message received - */ - void received(NoTurn msg); - - /** - * Handles a PauseGame message received from the server. - * - * @param msg the PauseGame message received - */ - void received(PauseGame msg); - - /** - * Handles a PlayCard message received from the server. - * - * @param msg the PlayCard message received - */ - void received(PlayCard msg); - - /** - * Handles a PossibleCard message received from the server. - * - * @param msg the PossibleCard message received - */ - void received(PossibleCard msg); - - /** - * Handles a PossiblePiece message received from the server. - * - * @param msg the PossiblePiece message received - */ - void received(PossiblePiece msg); - - /** - * Handles a RankingResponce message received from the server. - * - * @param msg the RankingResponce message received - */ - void received(RankingResponse msg); - - /** - * Handles a RankingRollAgain message received from the server. - * - * @param msg the RankingRollAgain message received - */ - void received(RankingRollAgain msg); - - /** - * Handles a ReconnectBriefing message received from the server. - * - * @param msg the ReconnectBriefing message received - */ - void received(ReconnectBriefing msg); - - /** - * Handles a ResumeGame message received from the server. - * - * @param msg the ResumeGame message received - */ - void received(ResumeGame msg); - - /** - * Handles a ServerStartGame message received from the server. - * - * @param msg the ServerStartGame message received - */ - void received(ServerStartGame msg); - - /** - * Handles a StartPiece message received from the server. - * - * @param msg the StartPiece message received - */ - void received(StartPiece msg); - - /** - * Handles a UpdateReady message received from the server. - * - * @param msg the UpdateReady message received - */ - void received(UpdateReady msg); - - /** - * Handles a UpdateTSK message received from the server. - * - * @param msg the UpdateTSK message received - */ - void received(UpdateTSK msg); - - /** - * Handles a WaitPiece message received from the server. - * - * @param msg the WaitPiece message received - */ - void received(WaitPiece msg); -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java deleted file mode 100644 index bc1d6b7d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java +++ /dev/null @@ -1,31 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.AbstractMessage; - -/** - * An abstract base class for server messages used in network transfer. - * It extends the AbstractMessage class provided by the jme3-network library. - */ -public abstract class ServerMessage extends AbstractMessage { - /** - * Constructs a new ServerMessage instance. - */ - protected ServerMessage() { - super(true); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - public abstract void accept(ServerInterpreter interpreter); - - /** - * Gets the bundle key of the informational text to be shown at the client. - * This key is used to retrieve the appropriate localized text for display. - * - * @return the bundle key of the informational text - */ - public abstract String getInfoTextKey(); -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java deleted file mode 100644 index d6ec553d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message indicating that the game shall start. - */ -@Serializable -public class ServerStartGame extends ServerMessage { - /** - * Constructs a new ServerStartGame instance. - */ - public ServerStartGame() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java deleted file mode 100644 index eb9c5508..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java +++ /dev/null @@ -1,71 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to the active player that he has to move a start piece. - */ -@Serializable -public class StartPiece extends ServerMessage { - /** - * The identifier for the piece. - */ - private final String pieceIdentifier; - - /** - * Constructs a new StartPiece instance with the specified piece identifier. - * - * @param pieceIdentifier the identifier for the piece - */ - public StartPiece(String pieceIdentifier) { - super(); - this.pieceIdentifier = pieceIdentifier; - } - - /** - * Default constructor for serialization purposes. - */ - private StartPiece() { - super(); - this.pieceIdentifier = ""; - } - - /** - * Gets the identifier for the piece. - * - * @return the piece identifier - */ - public String getPieceIdentifier() { - return pieceIdentifier; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java deleted file mode 100644 index 6e815c95..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java +++ /dev/null @@ -1,89 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; -import pp.mdga.game.Color; - -/** - * A message sent by the server to every client to update the readiness status of a player. - */ -@Serializable -public class UpdateReady extends ServerMessage { - /** - * The color associated with the update. - */ - private final Color color; - - /** - * Indicates whether the player is ready. - */ - private final boolean ready; - - /** - * Constructs a new UpdateReady instance with the specified color and readiness status. - * - * @param color the color associated with the update - * @param ready the readiness status - */ - public UpdateReady(Color color, boolean ready) { - super(); - this.color = color; - this.ready = ready; - } - - /** - * Default constructor for serialization purposes. - */ - private UpdateReady() { - super(); - this.color = null; - this.ready = false; - } - - /** - * Gets the color associated with the update. - * - * @return the color - */ - public Color getColor() { - return color; - } - - /** - * Checks if the player is ready. - * - * @return true if the player is ready, false otherwise - */ - public boolean isReady() { - return ready; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java deleted file mode 100644 index 017dd29b..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java +++ /dev/null @@ -1,87 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; -import pp.mdga.game.Color; - -/** - * A message sent by the server to every client to update the TSK. - */ -@Serializable -public class UpdateTSK extends ServerMessage { - /** - * The name associated with the update. - */ - private final String name; - - /** - * The color associated with the update. - */ - private final Color color; - - /** - * Constructs a new UpdateTSK instance with the specified name and color. - * - * @param name the name associated with the update - * @param color the color associated with the update - */ - public UpdateTSK(String name, Color color) { - super(); - this.name = name; - this.color = color; - } - - /** - * Default constructor for serialization purposes. - */ - private UpdateTSK() { - this("", null); - } - - /** - * Gets the name associated with the update. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the color associated with the update. - * - * @return the color - */ - public Color getColor() { - return color; - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java deleted file mode 100644 index 5e32338a..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java +++ /dev/null @@ -1,46 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.serializing.Serializable; - -/** - * A message sent by the server to the active player to choose a piece from the waiting area. - */ -@Serializable -public class WaitPiece extends ServerMessage { - /** - * Constructs a new WaitPiece instance. - */ - public WaitPiece() { - super(); - } - - /** - * Accepts a visitor to process this message. - * - * @param interpreter the visitor to process this message - */ - @Override - public void accept(ServerInterpreter interpreter) { - interpreter.received(this); - } - - /** - * Returns a string representation of this message. - * - * @return a string representation of this message - */ - @Override - public String toString() { - return ""; - } - - /** - * Returns the key for the info text of this message. - * - * @return the key for the info text of this message - */ - @Override - public String getInfoTextKey() { - return ""; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java deleted file mode 100644 index 74d95b65..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Animation.java +++ /dev/null @@ -1,16 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.client.AnimationEnd; -import pp.mdga.message.server.DiceNow; - -public class Animation extends ServerState { - public Animation(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void receivedAnimationEnd(AnimationEnd msg, int from) { - logic.send(logic.getGame().getStartPlayer(), new DiceNow()); - parent.gotoState(new Turn(parent, logic)); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java deleted file mode 100644 index 667aa927..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.server; - -public class Ceremony extends ServerState { - public Ceremony(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java deleted file mode 100644 index b9e6f4be..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java +++ /dev/null @@ -1,9 +0,0 @@ -package pp.mdga.server; - -public class ChoosePiece extends ServerState { - private final ChoosePieceStateMachine choosePieceStateMachine = new ChoosePieceStateMachine(this, logic); - - public ChoosePiece(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePieceStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePieceStateMachine.java deleted file mode 100644 index 2558e028..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePieceStateMachine.java +++ /dev/null @@ -1,12 +0,0 @@ -package pp.mdga.server; - -public class ChoosePieceStateMachine extends ServerStateMachine{ - public ChoosePieceStateMachine(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public NoPiece initialState() { - return new NoPiece(this, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java deleted file mode 100644 index 3fb1ff9a..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java +++ /dev/null @@ -1,45 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Player; -import pp.mdga.message.client.RequestDice; -import pp.mdga.message.server.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public class DetermineStartPlayer extends ServerState { - private final List player = new ArrayList<>(); - - public DetermineStartPlayer(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - logic.getGame().addObserver(this); - } - - @Override - public void receivedRequestDice(RequestDice msg, int from) { - final Random random = new Random(); - final int dice = random.nextInt(6) + 1; - broadcastUpdate(new Dice(dice, new ArrayList<>())); - } - - @Override - public void update() { - if (Boolean.TRUE.equals(logic.getGame().allRanked())) { - broadcastUpdate(new RankingResponse()); - if (logic.getGame().getOrder().isEmpty()) { - // todo: save the players with the same value? - broadcastUpdate(new RankingRollAgain()); - broadcastUpdate(new EndOfTurn()); - } else { - // todo: set start player - Player startPlayer = new Player(1); - logic.getGame().setStartPlayer(startPlayer); - logic.send(startPlayer, new DiceNow()); - broadcastUpdate(new EndOfTurn()); - parent.gotoState(new Animation(parent, logic)); - logic.getGame().removeObserver(this); - } - } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java deleted file mode 100644 index 3c687bf7..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java +++ /dev/null @@ -1,28 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.client.RequestDice; - -public class FirstRoll extends ServerState { - public FirstRoll(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void receivedRequestDice(RequestDice msg, int from) { - // todo: implement player.hasMovablePieces() -// if (player.hasMovablePieces()) { -// // todo: goto ChoosePiece -// } else { -// // todo: implement roll -// if (roll == 6) { -// // todo: send to everyone? or one player? -// logic.send(new Player(1), new Dice()); -// // todo: goto ChoosePiece -// } else { -// // todo: send to everyone? or one player? -// logic.send(new Player(1), new DiceAgain()); -// parent.gotoState(new SecondRoll(parent, logic)); -// } -// } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java deleted file mode 100644 index 79069220..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameState.java +++ /dev/null @@ -1,69 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.client.*; -import pp.mdga.message.server.PauseGame; -import pp.mdga.message.server.PossibleCard; -import pp.mdga.message.server.RankingResponse; - -public class GameState extends ServerState { - private final GameStateMachine gameStateMachine = new GameStateMachine(this, logic); - - public GameState(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - logic.getGame().addObserver(this); - } - - @Override - public void entry() { - gameStateMachine.entry(); - } - - @Override - public void exit() { - parent.gotoState(new Ceremony(parent, logic)); - } - - @Override - public void receivedAnimationEnd(AnimationEnd msg, int from) { - gameStateMachine.receivedAnimationEnd(msg, from); - } - - @Override - public void receivedNoPowerCard(NoPowerCard msg, int from) { - gameStateMachine.receivedNoPowerCard(msg, from); - } - - @Override - public void receivedSelectCard(SelectCard msg, int from) { - gameStateMachine.receivedSelectCard(msg, from); - } - - @Override - public void receivedRequestDice(RequestDice msg, int from) { - gameStateMachine.receivedRequestDice(msg, from); - } - - @Override - public void receivedSelectedPieces(SelectedPieces msg, int from) { - gameStateMachine.receivedSelectedPieces(msg, from); - } - - @Override - public void sentPossibleCard(PossibleCard msg, int from) { - gameStateMachine.sentPossibleCard(msg, from); - } - - @Override - public void sentRankingResponse(RankingResponse msg, int from) { - gameStateMachine.sentRankingResponse(msg, from); - } - - @Override - public void update() { - if (Boolean.TRUE.equals(logic.getGame().playerHasDisconnected())) { - broadcastUpdate(new PauseGame()); - parent.gotoState(new Interrupt(parent, logic, this)); - logic.getGame().removeObserver(this); - } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/GameStateMachine.java deleted file mode 100644 index 2e14808b..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/GameStateMachine.java +++ /dev/null @@ -1,26 +0,0 @@ -package pp.mdga.server; - -/** - * The GameStateMachine class represents the state machine for the game state. - */ -public class GameStateMachine extends ServerStateMachine { - /** - * Constructs a new GameStateMachine with the specified parent state and game logic. - * - * @param parent the parent state - * @param logic the server game logic - */ - public GameStateMachine(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - /** - * Returns the initial state of the state machine, which is DetermineStartPlayer. - * - * @return the initial state - */ - @Override - public DetermineStartPlayer initialState() { - return new DetermineStartPlayer(this, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java deleted file mode 100644 index ca59ca86..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java +++ /dev/null @@ -1,22 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.server.ResumeGame; - -public class Interrupt extends ServerState { - private final GameState lastState; - - public Interrupt(ServerState parent, ServerGameLogic logic, GameState lastState) { - super(parent, logic); - this.lastState = lastState; - logic.getGame().addObserver(this); - } - - @Override - public void update() { - if (Boolean.FALSE.equals(logic.getGame().gameIsInterrupted())) { - broadcastUpdate(new ResumeGame()); - parent.gotoState(lastState); - logic.getGame().removeObserver(this); - } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java deleted file mode 100644 index 86da598f..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java +++ /dev/null @@ -1,94 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Color; -import pp.mdga.game.Player; -import pp.mdga.message.client.*; -import pp.mdga.message.server.ServerMessage; -import pp.mdga.message.server.ServerStartGame; -import pp.mdga.message.server.UpdateReady; -import pp.mdga.message.server.UpdateTSK; - -/** - * Represents the lobby state of the server. - */ -public class Lobby extends ServerState { - /** - * Constructs a new Lobby state. - * - * @param parent the parent state - * @param logic the server game logic - */ - public Lobby(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - /** - * Handles the DeselectTSK message. - * - * @param msg the DeselectTSK message - */ - @Override - public void receivedDeselectTSK(DeselectTSK msg, int from) { - broadcastUpdate(new UpdateTSK(logic.getPlayerById(from).getName(), msg.getColor())); - } - - /** - * Handles the LobbyNotReady message. - * - * @param msg the LobbyNotReady message - */ - @Override - public void receivedNotReady(LobbyNotReady msg, int from) { - broadcastUpdate(new UpdateReady(getPlayerColor(from), false)); - } - - /** - * Handles the LobbyReady message. - * - * @param msg the LobbyReady message - */ - @Override - public void receivedReady(LobbyReady msg, int from) { - broadcastUpdate(new UpdateReady(getPlayerColor(from), true)); - } - - /** - * Helper method to get the color associated with a player ID. - * - * @param playerId The ID of the player. - * @return The Color associated with the player, or null if not found. - */ - private Color getPlayerColor(int playerId) { - Player player = logic.getPlayerById(playerId); - - for (var entry : logic.getGame().getPlayers().entrySet()) { - if (entry.getValue().equals(player)) { - return entry.getKey(); - } - } - return null; - } - - /** - * Handles the SelectTSK message. - * - * @param msg the SelectTSK message - */ - @Override - public void receivedSelectTSK(SelectTSK msg, int from) { - broadcastUpdate(new UpdateTSK(logic.getPlayerById(from).getName(), msg.getColor())); - } - - /** - * Handles the ClientStartGame message. - * - * @param msg the ClientStartGame message - */ - @Override - public void receivedStartGame(ClientStartGame msg, int from) { - if (Boolean.TRUE.equals(logic.getGame().allReady())) { - broadcastUpdate(new ServerStartGame()); - parent.gotoState(new GameState(parent, logic)); - } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java deleted file mode 100644 index 38d40399..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.server; - -public class MovePiece extends ServerState { - public MovePiece(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java deleted file mode 100644 index 6326bfb1..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java +++ /dev/null @@ -1,55 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Player; -import pp.mdga.message.server.WaitPiece; - -public class NoPiece extends ServerState { - public NoPiece(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - entry(); - } - - @Override - public void entry() { -// if (hasTurbo() || turbo == 0) { -// if (roll == 6 && -// logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces() && -// logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { -// parent.gotoState(new WaitingPiece(parent, logic)); -// } else { -// parent.gotoState(new NoTurn(parent, logic)); -// } -// } else { -// validateHasPieces(); -// } - } - - private void validateHasPieces() { -// if (logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces()) { -// if (logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { -// if (roll == 6) { -// logic.send(new Player(1), new WaitPiece()); -// } else { -// validateMove(); -// } -// } else { -// if (logic.getGame().getBoard().getNodes().getStartNode(Color).getPiece().canMove()) { -// logic.send(new Player(1), new WaitPiece()); -// parent.gotoState(new StartPiece(parent, logic)); -// } else { -// validateMove(); -// } -// } -// } else { -// validateMove(); -// } - } - - private void validateMove() { -// if (player.canMove()) { -// parent.gotoState(new NoTurn(parent, logic)); -// } else { -// logic.send(new Player(1), new SelectPiece()); -// } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java deleted file mode 100644 index 388f50bf..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java +++ /dev/null @@ -1,14 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.server.EndOfTurn; - -public class NoTurn extends ServerState { - public NoTurn(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void sentEndOfTurn(EndOfTurn msg, int from) { - // todo: goto end of turn - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Observer.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Observer.java deleted file mode 100644 index a95ad2ad..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Observer.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.server; - -public interface Observer { - void update(); -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/PlayPowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/PlayPowerCard.java deleted file mode 100644 index cc7cf7b0..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/PlayPowerCard.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.server; - -public class PlayPowerCard extends ServerState { - public PlayPowerCard(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java deleted file mode 100644 index a66f0104..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java +++ /dev/null @@ -1,54 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Player; -import pp.mdga.message.client.NoPowerCard; -import pp.mdga.message.client.SelectCard; -import pp.mdga.message.client.SelectedPieces; -import pp.mdga.message.server.DiceNow; -import pp.mdga.message.server.PossibleCard; - -public class PowerCard extends ServerState { - public PowerCard(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - logic.getGame().addObserver(this); - } - - @Override - public void receivedNoPowerCard(NoPowerCard msg, int from) { - // todo: send to everyone? or one player? - // todo: right msg? - logic.send(new Player(1), new DiceNow()); - parent.gotoState(new RollDice(parent, logic)); - } - - @Override - public void receivedSelectCard(SelectCard msg, int from) { - // todo: send to everyone? or one player? - logic.send(new Player(1), new PossibleCard()); - } - - @Override - public void receivedSelectedPieces(SelectedPieces msg, int from) { -// if (verifySelectedPieces()) { -// // todo: send to everyone? or one player? -// // todo: msg PowerCardAnimation? -// logic.send(new Player(1), new PowerCardAnimation()); -// parent.gotoState(new PlayPowerCard(parent, logic)); -// } - } - - @Override - public void sentPossibleCard(PossibleCard msg, int from) { - // todo: implement - } - - @Override - public void update() { - if (!super.getMoveablePieces(logic.getGame().getActiveColor()).isEmpty()) { - // todo: send to everyone? or one player? - // todo: right msg? - logic.send(new Player(1), new DiceNow()); - parent.gotoState(new RollDice(parent, logic)); - } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java deleted file mode 100644 index acb43509..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java +++ /dev/null @@ -1,9 +0,0 @@ -package pp.mdga.server; - -public class RollDice extends ServerState { - private final RollDiceMachine rollDiceMachine = new RollDiceMachine(this, logic); - - public RollDice(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDiceMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDiceMachine.java deleted file mode 100644 index bc788947..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDiceMachine.java +++ /dev/null @@ -1,12 +0,0 @@ -package pp.mdga.server; - -public class RollDiceMachine extends ServerStateMachine { - public RollDiceMachine(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public FirstRoll initialState() { - return new FirstRoll(this, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java deleted file mode 100644 index d149236b..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java +++ /dev/null @@ -1,25 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Player; -import pp.mdga.message.client.RequestDice; -import pp.mdga.message.server.Dice; -import pp.mdga.message.server.DiceAgain; - -public class SecondRoll extends ServerState { - public SecondRoll(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void receivedRequestDice(RequestDice msg, int from) { -// if (roll == 6) { -// // todo: send to everyone? or one player? -// logic.send(new Player(1), new Dice()); -// // todo: goto ChoosePiece -// } else { -// // todo: send to everyone? or one player? -// logic.send(new Player(1), new DiceAgain()); -// parent.gotoState(new ThirdRoll(parent, logic)); -// } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java deleted file mode 100644 index 9cd71e6a..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java +++ /dev/null @@ -1,22 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Piece; -import pp.mdga.game.Player; -import pp.mdga.message.client.RequestMove; -import pp.mdga.message.server.StartPiece; - -public class SelectPiece extends ServerState { - public SelectPiece(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void receivedRequestMove(RequestMove msg, int from) { -// if (verifyPiece(p)) { -// logic.send(new Player(1), new Animation()); -// // todo: goto state -// } else { -// logic.send(new Player(1), new StartPiece()); -// } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerAutomaton.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerAutomaton.java deleted file mode 100644 index 14061e81..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerAutomaton.java +++ /dev/null @@ -1,27 +0,0 @@ -package pp.mdga.server; - -/** - * The ServerAutomaton class represents the top-level state machine for the server. - * It initializes the state machine and sets the initial state to Lobby. - */ -public class ServerAutomaton extends ServerStateMachine { - /** - * Constructs a new ServerAutomaton with the specified game logic. - * - * @param logic the server game logic - */ - public ServerAutomaton(ServerGameLogic logic) { - super(null, logic); - entry(); - } - - /** - * Returns the initial state of the state machine, which is Lobby. - * - * @return the initial state - */ - @Override - public Lobby initialState() { - return new Lobby(this, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java deleted file mode 100644 index 64761cf6..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java +++ /dev/null @@ -1,145 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Game; -import pp.mdga.game.Player; -import pp.mdga.message.client.*; -import pp.mdga.message.server.ServerMessage; - -import java.lang.System.Logger; - -public class ServerGameLogic implements ClientInterpreter { - static final Logger LOGGER = System.getLogger(ServerGameLogic.class.getName()); - - private final Game game; - private final ServerSender serverSender; - private ServerState state; - - public ServerGameLogic(Game game, ServerSender serverSender) { - this.game = game; - this.serverSender = serverSender; - state = new ServerAutomaton(this); - } - - - @Override - public void received(AnimationEnd animationEnd, int from) { - - } - - @Override - public void received(DeselectTSK deselectTSK, int from) { - - } - - @Override - public void received(ForceStartGame forceStartGame, int from) { - - } - - @Override - public void received(JoinServer joinServer, int from) { - - } - - @Override - public void received(LeaveGame leaveGame, int from) { - - } - - @Override - public void received(LobbyNotReady lobbyNotReady, int from) { - - } - - @Override - public void received(LobbyReady lobbyReady, int from) { - - } - - @Override - public void received(RequestBriefing requestBriefing, int from) { - - } - - @Override - public void received(RequestDice requestDice, int from) { - - } - - @Override - public void received(RequestMove requestMove, int from) { - - } - - @Override - public void received(RequestPlayCard requestPlayCard, int from) { - - } - - @Override - public void received(SelectCard selectCard, int from) { - - } - - @Override - public void received(SelectTSK selectTSK, int from) { - - } - - @Override - public void received(ForceContinueGame forceContinueGame, int from) { - - } - - @Override - public void received(ClientStartGame clientStartGame, int from) { - - } - - @Override - public void received(NoPowerCard noPowerCard, int from) { - - } - - @Override - public void received(SelectedPieces selectedPieces, int from) { - - } - - /** - * Sends a message to the specified player. - * - * @param player the player to send the message to - * @param msg the message to send - */ - public void send(Player player, ServerMessage msg) { - LOGGER.log(Logger.Level.INFO, "sending to {0}: {1}", player, msg); //NON-NLS - serverSender.send(player.getId(), msg); - } - - public ServerSender getServerSender() { - return serverSender; - } - - public Game getGame() { - return game; - } - - /** - * Returns the player representing the client with the specified connection ID. - * - * @param id the ID of the client - * @return the player associated with the client ID, or null if not found - */ - public Player getPlayerById(int id) { - for (var entry : game.getPlayers().entrySet()) - if (entry.getValue().getId() == id) - return entry.getValue(); - LOGGER.log(Logger.Level.ERROR, "no player found with connection {0}", id); //NON-NLS - return null; - } - - public ServerState getState() { - return state; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java deleted file mode 100644 index 0efc8f5d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.server.ServerMessage; - -public interface ServerSender { - void send(int id, ServerMessage msg); -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java deleted file mode 100644 index 29bf2edd..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java +++ /dev/null @@ -1,324 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Color; -import pp.mdga.game.Node; -import pp.mdga.game.Piece; -import pp.mdga.game.PieceState; -import pp.mdga.game.PlayerData; -import pp.mdga.message.client.*; -import pp.mdga.message.server.EndOfTurn; -import pp.mdga.message.server.PossibleCard; -import pp.mdga.message.server.RankingResponse; -import pp.mdga.message.server.ServerMessage; - -import java.lang.System.Logger; -import java.util.ArrayList; -import java.util.List; - -/** - * Abstract class representing a state in the server's state machine. - * Implements the Observer pattern to observe changes in the game state. - */ -public abstract class ServerState implements Observer { - /** - * Logger for logging messages within the application. - */ - protected static final Logger LOGGER = System.getLogger(ServerState.class.getName()); - - /** - * The parent state of the current state. - */ - protected ServerState parent; - - /** - * The game logic associated with the server state. - */ - protected ServerGameLogic logic; - - /** - * Constructs a new ServerState with the specified parent state and game logic. - * - * @param parent the parent state of the current state - * @param logic the game logic associated with the server state - */ - protected ServerState(ServerState parent, ServerGameLogic logic) { - this.parent = parent; - this.logic = logic; - } - - /** - * This method is called when the state is entered. - */ - public void entry() { /* do nothing */ } - - /** - * This method is called when the state is exited. - */ - public void exit() { /* do nothing */ } - - /** - * This method is called when an animation ends. - * - * @param msg the animation end message - */ - public void receivedAnimationEnd(AnimationEnd msg, int from) { /* do nothing */ } - - /** - * This method is called when a TSK is deselected. - * - * @param msg the deselect TSK message - */ - public void receivedDeselectTSK(DeselectTSK msg, int from) { /* do nothing */ } - - /** - * This method is called when a NoPowerCard message is received. - * - * @param msg the NoPowerCard message - */ - public void receivedNoPowerCard(NoPowerCard msg, int from) { /* do nothing */ } - - /** - * This method is called when a LobbyNotReady message is received. - * - * @param msg the LobbyNotReady message - */ - public void receivedNotReady(LobbyNotReady msg, int from) { /* do nothing */ } - - /** - * This method is called when a LobbyReady message is received. - * - * @param msg the LobbyReady message - */ - public void receivedReady(LobbyReady msg, int from) { /* do nothing */ } - - /** - * This method is called when a RequestDice message is received. - * - * @param msg the RequestDice message - */ - public void receivedRequestDice(RequestDice msg, int from) { /* do nothing */ } - - /** - * This method is called when a RequestMove message is received. - * - * @param msg the RequestMove message - */ - public void receivedRequestMove(RequestMove msg, int from) { /* do nothing */ } - - /** - * This method is called when a SelectCard message is received. - * - * @param msg the SelectCard message - */ - public void receivedSelectCard(SelectCard msg, int from) { /* do nothing */ } - - /** - * This method is called when a SelectTSK message is received. - * - * @param msg the SelectTSK message - */ - public void receivedSelectTSK(SelectTSK msg, int from) { /* do nothing */ } - - /** - * This method is called when a SelectedPieces message is received. - * - * @param msg the SelectedPieces message - */ - public void receivedSelectedPieces(SelectedPieces msg, int from) { /* do nothing */ } - - /** - * This method is called when a StartGame message is received. - * - * @param msg the StartGame message - */ - public void receivedStartGame(ClientStartGame msg, int from) { /* do nothing */ } - - /** - * This method is called when an EndOfTurn message is sent. - * - * @param msg the EndOfTurn message - */ - public void sentEndOfTurn(EndOfTurn msg, int from) { /* do nothing */ } - - /** - * This method is called when a PossibleCard message is sent. - * - * @param msg the PossibleCard message - */ - public void sentPossibleCard(PossibleCard msg, int from) { /* do nothing */ } - - /** - * This method is called when a RankingResponce message is sent. - * - * @param msg the RankingResponce message - */ - public void sentRankingResponse(RankingResponse msg, int from) { /* do nothing */ } - - /** - * This method transitions to a new state. - * - * @param state the new state to transition to - * @throws IllegalStateException if called outside a state machine - */ - public void gotoState(ServerState state) { - throw new IllegalStateException("not in a statemachine"); - } - - /** - * Returns the parent state of the current state. - * - * @return the parent state - */ - public ServerState getParent() { - return parent; - } - - /** - * This method is called when the observed object is changed. - * It is part of the Observer pattern implementation. - */ - public void update() { /* do nothing */ } - - /** - * This method is used to calculate the steps a piece can move - * - * @return the steps a piece can move - */ - private int calculateSteps() { - return logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier(); - } - - /** - * This method is used to test if u can move a piece - * - * @param piece the piece to be moved - * @return true if the piece can be moved, false otherwise - */ - protected boolean tryMove(Piece piece) { - int steps = calculateSteps(); - if (piece.getState() == PieceState.HOME) { - return tryHomeMove(piece, steps); - } else { - int homeMoves = getHomeMoves(piece, steps); - if (homeMoves > 0) { - return tryHomeMove(piece, homeMoves); - } else { - return tryInfieldMove(piece, steps); - } - } - } - - /** - * This method is used to determine if a piece would move into the home area. - * - * @param piece the piece to be moved - * @param steps the steps the piece would move - * @return the number of steps the piece would move into the home area - */ - protected int getHomeMoves(Piece piece, int steps) { - int figureIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); - Color col = piece.getColor(); - int startIndex = logic.getGame().getBoard().getPlayerData().get(col).getStartNodeIndex(); - int moveIndex = startIndex + steps; - if (moveIndex > logic.getGame().getBoard().getInfield().length) { - moveIndex %= logic.getGame().getBoard().getInfield().length; - if (moveIndex >= startIndex) { - return moveIndex - startIndex + 1; - } - } else if (figureIndex < startIndex && moveIndex >= startIndex) { - return moveIndex - startIndex + 1; - } - return 0; - } - - /** - * This method is used to determine if a piece can move in the infield - * - * @param piece the piece to be moved - * @param steps the steps the piece would move - * @return true if the piece can move in the infield, false otherwise - */ - protected boolean tryInfieldMove(Piece piece, int steps) { - int figureIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); - int moveIndex = (figureIndex + steps) % logic.getGame().getBoard().getInfield().length; - Piece occupant = logic.getGame().getBoard().getInfield()[moveIndex].getOccupant(); - if (occupant != null) { - return occupant.getColor() != piece.getColor(); - } - return true; - } - - /** - * This method is used to determine if a piece can move inside the home area - * - * @param piece the piece to be moved - * @param steps the steps the piece would move - * @return true if the piece can move into the home area, false otherwise - */ - protected boolean tryHomeMove(Piece piece, int steps) { - Color col = piece.getColor(); - PlayerData playerData = logic.getGame().getBoard().getPlayerData().get(col); - Node[] homeNodes = playerData.getHomeNodes(); - int index; - - if (playerData.homeIncludes(piece)) { - index = playerData.getIndexInHome(piece); - } else { - index = 0; - } - - if (index + steps >= homeNodes.length) { - return false; - } else { - for (int i = index; i <= index + steps; i++) { - if (homeNodes[i].getOccupant() != null) { - return false; - } - } - return true; - } - } - - /** - * This method is used to get the pieces that can be moved - * - * @param color the color of the pieces - * @return the pieces that can be moved - */ - protected List getMoveablePieces(Color color) { - ArrayList moveablePieces = new ArrayList<>(); - ArrayList pieces = new ArrayList<>(); - for (Piece piece : logic.getGame().getBoard().getPlayerData().get(color).getPieces()) { - if (piece.getState() == PieceState.ACTIVE || piece.getState() == PieceState.HOME) { - pieces.add(piece); - } - } - for (Piece piece : pieces) { - if (tryMove(piece)) { - moveablePieces.add(piece); - } - } - return moveablePieces; - } - - /** - * Broadcasts an update message to all players. - * - * @param updateMessage the update message to be sent - */ - protected void broadcastUpdate(ServerMessage updateMessage) { - for (var entry : logic.getGame().getPlayers().entrySet()) { - logic.send(entry.getValue(), updateMessage); - } - } - - /** - * Returns a string representation of the object. - * - * @return the simple name of the class - */ - @Override - public String toString() { - return getClass().getSimpleName(); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java deleted file mode 100644 index 2554deaf..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerStateMachine.java +++ /dev/null @@ -1,234 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.client.*; -import pp.mdga.message.server.EndOfTurn; -import pp.mdga.message.server.PossibleCard; -import pp.mdga.message.server.RankingResponse; - -/** - * Abstract class representing a state machine for the server. - * It manages the transitions between different states and delegates - * the handling of messages to the current state. - */ -public abstract class ServerStateMachine extends ServerState { - /** - * The current state of the state machine. - */ - private ServerState state; - - /** - * Constructs a new instance of ServerStateMachine. - * - * @param parent the parent state - * @param logic the server game logic - */ - protected ServerStateMachine(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - /** - * Creates the initial state of a state machine. - */ - public abstract ServerState initialState(); - - /** - * Transitions to a new state. - * - * @param newState the new state to transition to - */ - @Override - public void gotoState(ServerState newState) { - LOGGER.log(System.Logger.Level.DEBUG, "{0}: {1} --> {2}", this, state, newState); - enter(newState); - } - - /** - * This method is called when the state is entered. - */ - @Override - public void entry() { - final ServerState newState = initialState(); - LOGGER.log(System.Logger.Level.DEBUG, "{0}: initial state={1}", this, newState); - enter(newState); - } - - /** - * Enters a new state. - * - * @param newState the new state to enter - * @throws IllegalArgumentException if the new state does not belong to this state machine - */ - private void enter(ServerState newState) { - if (newState.parent != this) - throw new IllegalArgumentException("Wrong state: " + newState + " belongs to " + newState.parent + " instead of " + this); - state = newState; - state.entry(); - } - - /** - * This method is called when the state is exited. - */ - @Override - public void exit() { - state.exit(); - } - - /** - * This method is called when an animation ends. - * - * @param msg the animation end message - */ - @Override - public void receivedAnimationEnd(AnimationEnd msg, int from) { - state.receivedAnimationEnd(msg, from); - } - - /** - * This method is called when a TSK is deselected. - * - * @param msg the deselect TSK message - */ - @Override - public void receivedDeselectTSK(DeselectTSK msg, int from) { - state.receivedDeselectTSK(msg, from); - } - - /** - * This method is called when a NoPowerCard message is received. - * - * @param msg the NoPowerCard message - */ - @Override - public void receivedNoPowerCard(NoPowerCard msg, int from) { - state.receivedNoPowerCard(msg, from); - } - - /** - * This method is called when a LobbyNotReady message is received. - * - * @param msg the LobbyNotReady message - */ - @Override - public void receivedNotReady(LobbyNotReady msg, int from) { - state.receivedNotReady(msg, from); - } - - /** - * This method is called when a LobbyReady message is received. - * - * @param msg the LobbyReady message - */ - @Override - public void receivedReady(LobbyReady msg, int from) { - state.receivedReady(msg, from); - } - - /** - * This method is called when a RequestDice message is received. - * - * @param msg the RequestDice message - */ - @Override - public void receivedRequestDice(RequestDice msg, int from) { - state.receivedRequestDice(msg, from); - } - - /** - * This method is called when a RequestMove message is received. - * - * @param msg the RequestMove message - */ - @Override - public void receivedRequestMove(RequestMove msg, int from) { - state.receivedRequestMove(msg, from); - } - - /** - * This method is called when a SelectCard message is received. - * - * @param msg the SelectCard message - */ - @Override - public void receivedSelectCard(SelectCard msg, int from) { - state.receivedSelectCard(msg, from); - } - - /** - * This method is called when a SelectTSK message is received. - * - * @param msg the SelectTSK message - */ - @Override - public void receivedSelectTSK(SelectTSK msg, int from) { - state.receivedSelectTSK(msg, from); - } - - /** - * This method is called when a SelectedPieces message is received. - * - * @param msg the SelectedPieces message - */ - @Override - public void receivedSelectedPieces(SelectedPieces msg, int from) { - state.receivedSelectedPieces(msg, from); - } - - /** - * This method is called when a StartGame message is received. - * - * @param msg the StartGame message - */ - @Override - public void receivedStartGame(ClientStartGame msg, int from) { - state.receivedStartGame(msg, from); - } - - /** - * This method is called when an EndOfTurn message is sent. - * - * @param msg the EndOfTurn message - */ - @Override - public void sentEndOfTurn(EndOfTurn msg, int from) { - state.sentEndOfTurn(msg, from); - } - - /** - * This method is called when a PossibleCard message is sent. - * - * @param msg the PossibleCard message - */ - @Override - public void sentPossibleCard(PossibleCard msg, int from) { - state.sentPossibleCard(msg, from); - } - - /** - * This method is called when a RankingResponse message is sent. - * - * @param msg the RankingResponse message - */ - @Override - public void sentRankingResponse(RankingResponse msg, int from) { - state.sentRankingResponse(msg, from); - } - - /** - * Returns a string representation of the object, including the current state. - * - * @return the string representation of the object - */ - @Override - public String toString() { - return super.toString() + "(in " + state + ")"; - } - - /** - * Returns the current state. - * - * @return the current state - */ - public ServerState getState() { - return state; - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java deleted file mode 100644 index f18641a2..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java +++ /dev/null @@ -1,21 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Piece; -import pp.mdga.game.Player; -import pp.mdga.message.client.RequestMove; - -public class StartPiece extends ServerState { - public StartPiece(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void receivedRequestMove(RequestMove msg, int from) { -// if (verifyPiece(p)) { -// logic.send(new Player(1), new Animation()); -// // todo: goto state -// } else { -// logic.send(new Player(1), new pp.mdga.message.server.StartPiece()); -// } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java deleted file mode 100644 index ebe9fd77..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java +++ /dev/null @@ -1,25 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Player; -import pp.mdga.message.client.RequestDice; -import pp.mdga.message.server.Dice; -import pp.mdga.message.server.DiceAgain; - -public class ThirdRoll extends ServerState { - public ThirdRoll(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void receivedRequestDice(RequestDice msg, int from) { -// if (roll == 6) { -// // todo: send to everyone? or one player? -// logic.send(new Player(1), new Dice()); -// // todo: goto ChoosePiece -// } else { -// // todo: send to everyone? or one player? -// logic.send(new Player(1), new DiceAgain()); -// // todo: goto End from Turn -// } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java deleted file mode 100644 index 4202226f..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java +++ /dev/null @@ -1,34 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Player; -import pp.mdga.message.server.ActivePlayer; -import pp.mdga.message.server.CeremonyMessage; - -public class Turn extends ServerState { - private final TurnStateMachine turnStateMachine = new TurnStateMachine(this, logic); - - public Turn(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - // todo: when TurnStateMachine is in the end state, and then? - @Override - public void exit() { - Player player = logic.getGame().getStartPlayer(); - -// if (player.isFinished()) { -// logic.send(player, new Spectator()); -// } else { -// logic.send(player, new EndOfTurn()); -// } - - if (logic.getGame().getPlayers().size() == 1) { - broadcastUpdate(new CeremonyMessage()); - this.getParent().getParent().exit(); - } else { - // todo: next player - broadcastUpdate(new ActivePlayer(null)); - parent.gotoState(new Animation(parent, logic)); - } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/TurnStateMachine.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/TurnStateMachine.java deleted file mode 100644 index a5974332..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/TurnStateMachine.java +++ /dev/null @@ -1,12 +0,0 @@ -package pp.mdga.server; - -public class TurnStateMachine extends ServerStateMachine { - public TurnStateMachine(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public PowerCard initialState() { - return new PowerCard(this, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java deleted file mode 100644 index a284a451..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java +++ /dev/null @@ -1,23 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Piece; -import pp.mdga.game.Player; -import pp.mdga.message.client.RequestDice; -import pp.mdga.message.client.RequestMove; -import pp.mdga.message.server.StartPiece; - -public class WaitingPiece extends ServerState { - public WaitingPiece(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void receivedRequestMove(RequestMove msg, int from) { -// if (verifyPiece(p)) { -// logic.send(new Player(1), new Animation()); -// // todo: goto state -// } else { -// logic.send(new Player(1), new StartPiece()); -// } - } -} From 9759b6871b1c4a7419aeb93305ed081fcbf77723 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Mon, 25 Nov 2024 16:14:15 +0100 Subject: [PATCH 38/44] reverted server messages --- .../pp.mdga/message/server/ActivePlayer.java | 71 +++++++ .../java/pp.mdga/message/server/AnyPiece.java | 73 +++++++ .../java/pp.mdga/message/server/Briefing.java | 46 ++++ .../message/server/CeremonyMessage.java | 46 ++++ .../java/pp.mdga/message/server/Dice.java | 110 ++++++++++ .../pp.mdga/message/server/DiceAgain.java | 46 ++++ .../java/pp.mdga/message/server/DiceNow.java | 46 ++++ .../pp.mdga/message/server/EndOfTurn.java | 46 ++++ .../pp.mdga/message/server/LobbyAccept.java | 46 ++++ .../pp.mdga/message/server/LobbyDeny.java | 46 ++++ .../message/server/LobbyPlayerJoin.java | 71 +++++++ .../message/server/LobbyPlayerLeave.java | 88 ++++++++ .../pp.mdga/message/server/MoveMessage.java | 70 +++++++ .../java/pp.mdga/message/server/NoTurn.java | 46 ++++ .../pp.mdga/message/server/PauseGame.java | 46 ++++ .../java/pp.mdga/message/server/PlayCard.java | 131 ++++++++++++ .../pp.mdga/message/server/PossibleCard.java | 74 +++++++ .../pp.mdga/message/server/PossiblePiece.java | 119 +++++++++++ .../message/server/RankingResponse.java | 46 ++++ .../message/server/RankingRollAgain.java | 46 ++++ .../message/server/ReconnectBriefing.java | 69 ++++++ .../pp.mdga/message/server/ResumeGame.java | 46 ++++ .../message/server/ServerInterpreter.java | 196 ++++++++++++++++++ .../pp.mdga/message/server/ServerMessage.java | 31 +++ .../message/server/ServerStartGame.java | 46 ++++ .../pp.mdga/message/server/StartPiece.java | 71 +++++++ .../pp.mdga/message/server/UpdateReady.java | 89 ++++++++ .../pp.mdga/message/server/UpdateTSK.java | 87 ++++++++ .../pp.mdga/message/server/WaitPiece.java | 46 ++++ 29 files changed, 1994 insertions(+) create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java new file mode 100644 index 00000000..551cd305 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java @@ -0,0 +1,71 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; +import pp.mdga.game.Color; + +/** + * A message sent by the server to inform the clients about the active player. + */ +@Serializable +public class ActivePlayer extends ServerMessage { + /** + * The color of the active player. + */ + private final Color color; + + /** + * Constructor for ActivePlayer + * + * @param color the color of the active player + */ + public ActivePlayer(Color color) { + super(); + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private ActivePlayer() { + color = null; + } + + /** + * Getter for the color of the active player + * + * @return the color of the active player + */ + public Color getColor() { + return color; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "ActivePlayer{color=" + color + '}'; + } + + /** + * Returns the key for the informational text associated with this message. + * + * @return the key for the informational text + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java new file mode 100644 index 00000000..eaf69c6d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java @@ -0,0 +1,73 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +import java.util.ArrayList; +import java.util.List; + +/** + * A message sent by the server to the active player containing a list of pieces that the player can move any piece of the list on the board. + */ +@Serializable +public class AnyPiece extends ServerMessage { + /** + * The list of pieces + */ + private final ArrayList piece; + + /** + * Constructor for AnyPiece + */ + public AnyPiece() { + super(); + piece = new ArrayList<>(); + } + + /** + * Add a piece to the list of pieces + * + * @param piece the piece to add + */ + public void addPiece(String piece) { + this.piece.add(piece); + } + + /** + * Getter for the list of pieces + * + * @return the list of pieces + */ + public List getPiece() { + return piece; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "AnyPiece{piece=" + piece + '}'; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java new file mode 100644 index 00000000..86942872 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the reconnected player to provide a briefing about the current game state. + */ +@Serializable +public class Briefing extends ServerMessage { + /** + * Constructs a new Briefing instance. + */ + public Briefing() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java new file mode 100644 index 00000000..10197038 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to indicate the beginning of the ceremony. + */ +@Serializable +public class CeremonyMessage extends ServerMessage { + /** + * Constructs a new Ceremony instance. + */ + public CeremonyMessage() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java new file mode 100644 index 00000000..6b4bc1ee --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java @@ -0,0 +1,110 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +import java.util.List; + +/** + * A message sent by the server to the client to inform about the dice roll. + */ +@Serializable +public class Dice extends ServerMessage { + /** + * The eye of the dice + */ + private final int diceEye; + + /** + * The pieces that can be moved + */ + private final List moveablePieces; + + /** + * Constructor for Dice + * + * @param diceEye the eye of the dice + * @param moveablePieces the pieces that can be moved + */ + public Dice(int diceEye, List moveablePieces) { + super(); + this.diceEye = diceEye; + this.moveablePieces = moveablePieces; + } + + /** + * Default constructor for serialization purposes. + */ + private Dice() { + diceEye = 0; + moveablePieces = null; + } + + /** + * Constructor for inactivePlayer + * + * @param diceEye the eye of the dice + * @return a new Dice object + */ + public static Dice inactivePlayer(int diceEye) { + return new Dice(diceEye, null); + } + + /** + * Constructor for activePlayer + * + * @param diceEye the eye of the dice + * @param moveablePieces the pieces that can be moved + * @return a new Dice object + */ + public static Dice activePlayer(int diceEye, List moveablePieces) { + return new Dice(diceEye, moveablePieces); + } + + /** + * Getter for the eye of the dice + * + * @return the eye of the dice + */ + public int getDiceEye() { + return diceEye; + } + + /** + * Getter for the pieces that can be moved + * + * @return the pieces that can be moved + */ + public List getMoveablePieces() { + return moveablePieces; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java new file mode 100644 index 00000000..c3402946 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the active player to indicate that they can roll the dice again. + */ +@Serializable +public class DiceAgain extends ServerMessage { + /** + * Constructs a new DiceAgain instance. + */ + public DiceAgain() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java new file mode 100644 index 00000000..b72f22a7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the active player to enable the dice now button. + */ +@Serializable +public class DiceNow extends ServerMessage { + /** + * Constructs a new DiceNow instance. + */ + public DiceNow() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java new file mode 100644 index 00000000..d9ac9cb0 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to indicate the end of the turn of the active player. + */ +@Serializable +public class EndOfTurn extends ServerMessage { + /** + * Constructs a new EndOfTurn instance. + */ + public EndOfTurn() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java new file mode 100644 index 00000000..d252148d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to indicate that the client has been accepted into the lobby. + */ +@Serializable +public class LobbyAccept extends ServerMessage { + /** + * Constructs a new LobbyAccept instance. + */ + public LobbyAccept() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java new file mode 100644 index 00000000..0717f814 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to deny a client's request to join the lobby. + */ +@Serializable +public class LobbyDeny extends ServerMessage { + /** + * Constructs a new LobbyDeny instance. + */ + public LobbyDeny() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java new file mode 100644 index 00000000..9472a150 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java @@ -0,0 +1,71 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent from the server to the client indicating that a player has joined the lobby. + */ +@Serializable +public class LobbyPlayerJoin extends ServerMessage { + + /** + * The name of the player joining the lobby. + */ + private final String name; + + /** + * Constructs a new LobbyPlayerJoin instance with the specified player name. + * + * @param name the name of the player joining the lobby + */ + public LobbyPlayerJoin(String name) { + super(); + this.name = name; + } + + /** + * Default constructor for serialization purposes. + */ + private LobbyPlayerJoin() { + name = null; + } + + /** + * Returns the name of the player joining the lobby. + * + * @return the name of the player joining the lobby + */ + public String getName() { + return name; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java new file mode 100644 index 00000000..f68b7054 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java @@ -0,0 +1,88 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; +import pp.mdga.game.Color; + +/** + * A message sent by the server to indicate that a player has left the lobby. + */ +@Serializable +public class LobbyPlayerLeave extends ServerMessage { + /** + * The name of the player leaving the lobby. + */ + private final String name; + + /** + * The color associated with the player leaving the lobby. + */ + private final Color color; + + /** + * Constructs a new LobbyPlayerLeave instance with the specified player name and color. + * + * @param name the name of the player leaving the lobby + * @param color the color associated with the player leaving the lobby + */ + public LobbyPlayerLeave(String name, Color color) { + super(); + this.name = name; + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private LobbyPlayerLeave() { + name = null; + color = null; + } + + /** + * Returns the name of the player leaving the lobby. + * + * @return the name of the player leaving the lobby + */ + public String getName() { + return name; + } + + /** + * Returns the color associated with the player leaving the lobby. + * + * @return the color associated with the player leaving the lobby + */ + public Color getColor() { + return color; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java new file mode 100644 index 00000000..27dbe370 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java @@ -0,0 +1,70 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the client to move a piece on the board. + */ +@Serializable +public class MoveMessage extends ServerMessage { + /** + * The identifier of the piece that should be moved. + */ + private final String pieceIdentifier; + + /** + * Constructs a new MoveMessage instance. + * + * @param identifier the identifier of the piece that should be moved + */ + public MoveMessage(String identifier) { + super(); + this.pieceIdentifier = identifier; + } + + /** + * Default constructor for serialization purposes. + */ + private MoveMessage() { + pieceIdentifier = null; + } + + /** + * Returns the identifier of the piece that should be moved. + * + * @return the identifier of the piece that should be moved + */ + public String getIdentifier() { + return pieceIdentifier; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java new file mode 100644 index 00000000..8a412de4 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the active player to indicate that he has no valid moves. + */ +@Serializable +public class NoTurn extends ServerMessage { + /** + * Constructs a new NoTurn instance. + */ + public NoTurn() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java new file mode 100644 index 00000000..19c95651 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to indicate that the game is paused. + */ +@Serializable +public class PauseGame extends ServerMessage { + /** + * Constructs a new PauseGame instance. + */ + public PauseGame() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java new file mode 100644 index 00000000..743bcbe8 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java @@ -0,0 +1,131 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; +import pp.mdga.game.BonusCard; + +/** + * A message sent by the server to the active player to play a card. + */ +@Serializable +public class PlayCard extends ServerMessage { + /** + * The card that should be played. + */ + private final BonusCard card; + + /** + * The identifier of the piece that should be moved. + */ + private final String pieceIdentifier; + + private final String pieceIdentifierEnemy; + + /** + * Constructs a new PlayCard message. + * + * @param card the card that should be played + * @param pieceIdentifier the identifier of the piece that should be moved + */ + public PlayCard(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) { + super(); + this.card = card; + this.pieceIdentifier = pieceIdentifier; + this.pieceIdentifierEnemy = pieceIdentifierEnemy; + } + + /** + * Default constructor for serialization purposes. + */ + private PlayCard() { + this.pieceIdentifierEnemy = null; + card = null; + pieceIdentifier = null; + } + + /** + * Creates a new PlayCard message for the given card and piece identifier. + * + * @param pieceIdentifier the identifier of the piece of the player that should be affected + * @param pieceIdentifierEnemy the identifier of the enemy piece that should be affected + * @return a new PlayCard message + */ + public static PlayCard swap(String pieceIdentifier, String pieceIdentifierEnemy) { + return new PlayCard(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy); + } + + /** + * Creates a new PlayCard message for the given card and piece identifier. + * + * @return a new PlayCard message + */ + public static PlayCard turbo() { + return new PlayCard(BonusCard.TURBO, null, null); + } + + /** + * Creates a new PlayCard message for the given card and piece identifier. + * + * @param pieceIdentifier the identifier of the piece of the player that should be affected + * @return a new PlayCard message + */ + public static PlayCard shield(String pieceIdentifier) { + return new PlayCard(BonusCard.SHIELD, pieceIdentifier, null); + } + + /** + * Returns the card that should be played. + * + * @return the card that should be played + */ + public BonusCard getCard() { + return card; + } + + /** + * Returns the identifier of the piece that should be moved. + * + * @return the identifier of the piece that should be moved + */ + public String getPieceIdentifier() { + return pieceIdentifier; + } + + /** + * Returns the identifier of the enemy piece that should be moved. + * + * @return the identifier of the enemy piece that should be moved + */ + public String getPieceIdentifierEnemy() { + return pieceIdentifierEnemy; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java new file mode 100644 index 00000000..35df9bef --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java @@ -0,0 +1,74 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; +import pp.mdga.game.BonusCard; + +import java.util.ArrayList; +import java.util.List; + +/** + * A message sent by the server to the client to indicate the possible cards that can be chosen. + */ +@Serializable +public class PossibleCard extends ServerMessage { + /** + * The list of possible cards. + */ + private final List possibleCards; + + /** + * Constructor for a PossibleCard instance. + */ + public PossibleCard() { + super(); + possibleCards = new ArrayList<>(); + } + + /** + * Add a possible card to the list of possible cards + * + * @param card the possible card to add + */ + public void addPossibleCard(BonusCard card) { + this.possibleCards.add(card); + } + + /** + * Getter for the list of possible cards + * + * @return the list of possible cards + */ + public List getPossibleCards() { + return possibleCards; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java new file mode 100644 index 00000000..04bc73fa --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java @@ -0,0 +1,119 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +import java.util.ArrayList; +import java.util.List; + +/** + * A message sent by the server to the active player to give all possible pieces to choose from. + */ +@Serializable +public class PossiblePiece extends ServerMessage { + /** + * The list of possible own pieces + */ + private final List possibleOwnPieces; + + /** + * The list of possible enemy pieces + */ + private final List possibleEnemyPieces; + + /** + * Constructor for PossiblePiece + */ + public PossiblePiece() { + super(); + possibleOwnPieces = new ArrayList<>(); + possibleEnemyPieces = new ArrayList<>(); + } + + /** + * Swap the possible pieces + * + * @param possibleOwnPieces the list of possible own pieces + * @param possibleEnemyPieces the list of possible enemy pieces + * @return the swapped possible pieces + */ + public static PossiblePiece swapPossiblePieces(ArrayList possibleOwnPieces, ArrayList possibleEnemyPieces) { + PossiblePiece possiblePiece = new PossiblePiece(); + possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces); + possiblePiece.possibleEnemyPieces.addAll(possibleEnemyPieces); + return possiblePiece; + } + + /** + * Get the possible pieces for the shield + * + * @param possibleOwnPieces the list of possible own pieces + * @return the possible pieces for the shield + */ + public static PossiblePiece shieldPossiblePieces(ArrayList possibleOwnPieces){ + PossiblePiece possiblePiece = new PossiblePiece(); + possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces); + return possiblePiece; + } + + /** + * Add a piece to the list of possible pieces + * + * @param piece the piece to add + */ + public void addOwnPossiblePiece(String piece) { + this.possibleOwnPieces.add(piece); + } + + /** + * Add a piece to the list of possible enemy pieces + * + * @param piece the piece to add + */ + public void addEnemyPossiblePiece(String piece) { + this.possibleEnemyPieces.add(piece); + } + + /** Getter for the list of possible pieces + * @return the list of possible pieces + */ + public List getOwnPossiblePieces() { + return possibleOwnPieces; + } + + /** Getter for the list of possible enemy pieces + * @return the list of possible enemy pieces + */ + public List getEnemyPossiblePieces() { + return possibleEnemyPieces; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java new file mode 100644 index 00000000..9b5eda2f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to all client to inform them about the current ranking. (only in DetermineStartPlayer) + */ +@Serializable +public class RankingResponse extends ServerMessage { + /** + * Constructs a new RankingResponse instance. + */ + public RankingResponse() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java new file mode 100644 index 00000000..eaf06392 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the clients to indicate that the ranking shall be rolled again. (only in DetermineStartPlayer) + */ +@Serializable +public class RankingRollAgain extends ServerMessage { + /** + * Constructs a new RankingRollAgain instance. + */ + public RankingRollAgain() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java new file mode 100644 index 00000000..5a72f341 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java @@ -0,0 +1,69 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; +import pp.mdga.game.Game; + +/** + * A message sent by the server to a client that has reconnected to the game. (give the last saved model) + */ +@Serializable +public class ReconnectBriefing extends ServerMessage { + /** + * The game. + */ + private final Game game; + + /** + * Constructs a new ReconnectBriefing message. + */ + public ReconnectBriefing(Game game) { + super(); + this.game = game; + } + + /** + * Default constructor for serialization purposes. + */ + private ReconnectBriefing() { + this(null); + } + + /** + * Returns the game. + * + * @return the game + */ + public Game getGame() { + return game; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java new file mode 100644 index 00000000..1ebfd673 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to resume the game. + */ +@Serializable +public class ResumeGame extends ServerMessage { + /** + * Constructs a new ResumeGame instance. + */ + public ResumeGame() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java new file mode 100644 index 00000000..c83abefd --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java @@ -0,0 +1,196 @@ +package pp.mdga.message.server; + +/** + * An interface for processing server messages. + * Implementations of this interface can be used to handle different types of server messages. + */ +public interface ServerInterpreter { + /** + * Handles an ActivePlayer message received from the server. + * + * @param msg the ActivePlayer message received + */ + void received(ActivePlayer msg); + + /** + * Handles an AnyPiece message received from the server. + * + * @param msg the AnyPiece message received + */ + void received(AnyPiece msg); + + /** + * Handles a Briefing message received from the server. + * + * @param msg the Briefing message received + */ + void received(Briefing msg); + + /** + * Handles a Ceremony message received from the server. + * + * @param msg the Ceremony message received + */ + void received(CeremonyMessage msg); + + /** + * Handles a Dice message received from the server. + * + * @param msg the Dice message received + */ + void received(Dice msg); + + /** + * Handles a DiceAgain message received from the server. + * + * @param msg the DiceAgain message received + */ + void received(DiceAgain msg); + + /** + * Handles a DiceNow message received from the server. + * + * @param msg the DiceNow message received + */ + void received(DiceNow msg); + + /** + * Handles an EndOfGame message received from the server. + * + * @param msg the EndOfGame message received + */ + void received(EndOfTurn msg); + + /** + * Handles a GameOver message received from the server. + * + * @param msg the GameOver message received + */ + void received(LobbyAccept msg); + + /** + * Handles a LobbyDeny message received from the server. + * + * @param msg the LobbyDeny message received + */ + void received(LobbyDeny msg); + + /** + * Handles a LobbyPlayerJoin message received from the server. + * + * @param msg the LobbyPlayerJoin message received + */ + void received(LobbyPlayerJoin msg); + + /** + * Handles a LobbyPlayerLeave message received from the server. + * + * @param msg the LobbyPlayerLeave message received + */ + void received(LobbyPlayerLeave msg); + + /** + * Handles a MoveMessage message received from the server. + * + * @param msg the MoveMessage message received + */ + void received(MoveMessage msg); + + /** + * Handles a NoTurn message received from the server. + * + * @param msg the NoTurn message received + */ + void received(NoTurn msg); + + /** + * Handles a PauseGame message received from the server. + * + * @param msg the PauseGame message received + */ + void received(PauseGame msg); + + /** + * Handles a PlayCard message received from the server. + * + * @param msg the PlayCard message received + */ + void received(PlayCard msg); + + /** + * Handles a PossibleCard message received from the server. + * + * @param msg the PossibleCard message received + */ + void received(PossibleCard msg); + + /** + * Handles a PossiblePiece message received from the server. + * + * @param msg the PossiblePiece message received + */ + void received(PossiblePiece msg); + + /** + * Handles a RankingResponce message received from the server. + * + * @param msg the RankingResponce message received + */ + void received(RankingResponse msg); + + /** + * Handles a RankingRollAgain message received from the server. + * + * @param msg the RankingRollAgain message received + */ + void received(RankingRollAgain msg); + + /** + * Handles a ReconnectBriefing message received from the server. + * + * @param msg the ReconnectBriefing message received + */ + void received(ReconnectBriefing msg); + + /** + * Handles a ResumeGame message received from the server. + * + * @param msg the ResumeGame message received + */ + void received(ResumeGame msg); + + /** + * Handles a ServerStartGame message received from the server. + * + * @param msg the ServerStartGame message received + */ + void received(ServerStartGame msg); + + /** + * Handles a StartPiece message received from the server. + * + * @param msg the StartPiece message received + */ + void received(StartPiece msg); + + /** + * Handles a UpdateReady message received from the server. + * + * @param msg the UpdateReady message received + */ + void received(UpdateReady msg); + + /** + * Handles a UpdateTSK message received from the server. + * + * @param msg the UpdateTSK message received + */ + void received(UpdateTSK msg); + + /** + * Handles a WaitPiece message received from the server. + * + * @param msg the WaitPiece message received + */ + void received(WaitPiece msg); +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java new file mode 100644 index 00000000..bc1d6b7d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java @@ -0,0 +1,31 @@ +package pp.mdga.message.server; + +import com.jme3.network.AbstractMessage; + +/** + * An abstract base class for server messages used in network transfer. + * It extends the AbstractMessage class provided by the jme3-network library. + */ +public abstract class ServerMessage extends AbstractMessage { + /** + * Constructs a new ServerMessage instance. + */ + protected ServerMessage() { + super(true); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + public abstract void accept(ServerInterpreter interpreter); + + /** + * Gets the bundle key of the informational text to be shown at the client. + * This key is used to retrieve the appropriate localized text for display. + * + * @return the bundle key of the informational text + */ + public abstract String getInfoTextKey(); +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java new file mode 100644 index 00000000..d6ec553d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message indicating that the game shall start. + */ +@Serializable +public class ServerStartGame extends ServerMessage { + /** + * Constructs a new ServerStartGame instance. + */ + public ServerStartGame() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java new file mode 100644 index 00000000..eb9c5508 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java @@ -0,0 +1,71 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the active player that he has to move a start piece. + */ +@Serializable +public class StartPiece extends ServerMessage { + /** + * The identifier for the piece. + */ + private final String pieceIdentifier; + + /** + * Constructs a new StartPiece instance with the specified piece identifier. + * + * @param pieceIdentifier the identifier for the piece + */ + public StartPiece(String pieceIdentifier) { + super(); + this.pieceIdentifier = pieceIdentifier; + } + + /** + * Default constructor for serialization purposes. + */ + private StartPiece() { + super(); + this.pieceIdentifier = ""; + } + + /** + * Gets the identifier for the piece. + * + * @return the piece identifier + */ + public String getPieceIdentifier() { + return pieceIdentifier; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java new file mode 100644 index 00000000..6e815c95 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java @@ -0,0 +1,89 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; +import pp.mdga.game.Color; + +/** + * A message sent by the server to every client to update the readiness status of a player. + */ +@Serializable +public class UpdateReady extends ServerMessage { + /** + * The color associated with the update. + */ + private final Color color; + + /** + * Indicates whether the player is ready. + */ + private final boolean ready; + + /** + * Constructs a new UpdateReady instance with the specified color and readiness status. + * + * @param color the color associated with the update + * @param ready the readiness status + */ + public UpdateReady(Color color, boolean ready) { + super(); + this.color = color; + this.ready = ready; + } + + /** + * Default constructor for serialization purposes. + */ + private UpdateReady() { + super(); + this.color = null; + this.ready = false; + } + + /** + * Gets the color associated with the update. + * + * @return the color + */ + public Color getColor() { + return color; + } + + /** + * Checks if the player is ready. + * + * @return true if the player is ready, false otherwise + */ + public boolean isReady() { + return ready; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java new file mode 100644 index 00000000..017dd29b --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java @@ -0,0 +1,87 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; +import pp.mdga.game.Color; + +/** + * A message sent by the server to every client to update the TSK. + */ +@Serializable +public class UpdateTSK extends ServerMessage { + /** + * The name associated with the update. + */ + private final String name; + + /** + * The color associated with the update. + */ + private final Color color; + + /** + * Constructs a new UpdateTSK instance with the specified name and color. + * + * @param name the name associated with the update + * @param color the color associated with the update + */ + public UpdateTSK(String name, Color color) { + super(); + this.name = name; + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private UpdateTSK() { + this("", null); + } + + /** + * Gets the name associated with the update. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the color associated with the update. + * + * @return the color + */ + public Color getColor() { + return color; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java new file mode 100644 index 00000000..5e32338a --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java @@ -0,0 +1,46 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to the active player to choose a piece from the waiting area. + */ +@Serializable +public class WaitPiece extends ServerMessage { + /** + * Constructs a new WaitPiece instance. + */ + public WaitPiece() { + super(); + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return ""; + } + + /** + * Returns the key for the info text of this message. + * + * @return the key for the info text of this message + */ + @Override + public String getInfoTextKey() { + return ""; + } +} From 1803fb55496f0594bfa071875900993acf362094 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 16:32:51 +0100 Subject: [PATCH 39/44] edted some tests with null tests --- .../client/clientState/ClientStateTest.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 7d45305e..468f87b7 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -13,6 +13,8 @@ import java.util.ArrayList; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; /** @@ -131,12 +133,12 @@ public void setUp() { lobbyDeny = new LobbyDeny(); lobbyPlayerJoin = new LobbyPlayerJoin(name); lobbyPlayerLeave = new LobbyPlayerLeave(name,color); - moveMessage = new MoveMessage(); + moveMessage = new MoveMessage("www");//Todo noTurn = new NoTurn(); pauseGame = new PauseGame(); - playCardSwap = new PlayCard(swapCard); - playCardShield = new PlayCard(shieldCard); - playCardTurbo = new PlayCard(turboCard); + playCardSwap = new PlayCard(swapCard,"www");//Todo + playCardShield = new PlayCard(shieldCard,"www");//Todo + playCardTurbo = new PlayCard(turboCard,"www");//Todo possibleCard = new PossibleCard(); possiblePiece = new PossiblePiece(); rankingResponce = new RankingResponse(); @@ -144,9 +146,9 @@ public void setUp() { reconnectBriefing = new ReconnectBriefing(game); resumeGame = new ResumeGame(); startGame = new ServerStartGame(); - startPieceMessage = new StartPiece(); - updateReady = new UpdateReady(); - updateTSK = new UpdateTSK(); + startPieceMessage = new StartPiece(); //Todo wrong class + updateReady = new UpdateReady(color,true); + updateTSK = new UpdateTSK(name,color); waitPiece = new WaitPiece(); //initialize the clientGameLogic @@ -162,7 +164,7 @@ public void send(ClientMessage msg) { mainSettings = new MainSettings(settingsStateMachine,clientGameLogic); videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic); audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic); - settings = new Settings(); + settings = new Settings(clientAutomaton,clientGameLogic); //initialize the stateMachines @@ -220,10 +222,12 @@ public void send(ClientMessage msg) { @Test public void testInitialStateClientState() { //tests if the clientAutomaton is in Dialogs + assertNotEquals(clientAutomaton.getState() , null); assertTrue(clientAutomaton.getState() instanceof Dialogs); Dialogs dialogs = (Dialogs) clientAutomaton.getState(); DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); //tests if the statemachine is in StartDialog + assertNotEquals(dialogsStateMachine1.getState(), null); assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } @@ -603,7 +607,7 @@ public void testWaitToAnimation() { assertTrue(gameStateMachine.getState() instanceof Waiting); //tests if a powerCard is played,that the client goes into Animation - clientGameLogic.receive(playCard); //Todo ??? richtige message + clientGameLogic.receive(playCardTurbo); //Todo ??? richtige message assertTrue(clientAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine.getState() instanceof Animation); From 321909387d6b434c9f467ec888bf5cf86d53bde6 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Mon, 25 Nov 2024 16:35:27 +0100 Subject: [PATCH 40/44] added new server state chart --- .../main/java/pp.mdga/server/Ceremony.java | 10 ++ .../main/java/pp.mdga/server/ChoosePiece.java | 9 ++ .../pp.mdga/server/DetermineStartPlayer.java | 9 ++ .../main/java/pp.mdga/server/FirstRoll.java | 9 ++ .../src/main/java/pp.mdga/server/Game.java | 10 ++ .../main/java/pp.mdga/server/Interrupt.java | 10 ++ .../src/main/java/pp.mdga/server/Lobby.java | 17 +++ .../main/java/pp.mdga/server/MovePiece.java | 9 ++ .../src/main/java/pp.mdga/server/NoPiece.java | 9 ++ .../src/main/java/pp.mdga/server/NoTurn.java | 9 ++ .../main/java/pp.mdga/server/PowerCard.java | 9 ++ .../main/java/pp.mdga/server/RollDice.java | 9 ++ .../main/java/pp.mdga/server/SecondRoll.java | 9 ++ .../main/java/pp.mdga/server/SelectPiece.java | 9 ++ .../java/pp.mdga/server/ServerGameLogic.java | 133 ++++++++++++++++++ .../java/pp.mdga/server/ServerSender.java | 16 +++ .../main/java/pp.mdga/server/ServerState.java | 28 ++++ .../main/java/pp.mdga/server/StartPiece.java | 9 ++ .../main/java/pp.mdga/server/ThirdRoll.java | 9 ++ .../src/main/java/pp.mdga/server/Turn.java | 9 ++ .../java/pp.mdga/server/WaitingPiece.java | 9 ++ 21 files changed, 350 insertions(+) create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java create mode 100644 Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java new file mode 100644 index 00000000..8e00391d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java @@ -0,0 +1,10 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; +import pp.mdga.message.server.ServerState; + +public class Ceremony extends ServerState { + public Ceremony(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java new file mode 100644 index 00000000..21bee23d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class ChoosePiece extends Turn { + public ChoosePiece(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java new file mode 100644 index 00000000..df8bf459 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class DetermineStartPlayer extends Game { + public DetermineStartPlayer(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java new file mode 100644 index 00000000..b993534d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class FirstRoll extends RollDice { + public FirstRoll(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java new file mode 100644 index 00000000..773570ed --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java @@ -0,0 +1,10 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; +import pp.mdga.message.server.ServerState; + +public class Game extends ServerState { + public Game(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java new file mode 100644 index 00000000..37ce2bde --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java @@ -0,0 +1,10 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; +import pp.mdga.message.server.ServerState; + +public class Interrupt extends ServerState { + public Interrupt(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java new file mode 100644 index 00000000..d6b97b9a --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java @@ -0,0 +1,17 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; +import pp.mdga.message.server.ServerState; + +public class Lobby extends ServerState { + + + /** + * Constructs a server state of the specified game logic. + * + * @param logic the game logic + */ + public Lobby(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java new file mode 100644 index 00000000..14db9e6c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class MovePiece extends Turn { + public MovePiece(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java new file mode 100644 index 00000000..3953272e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class NoPiece extends ChoosePiece { + public NoPiece(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java new file mode 100644 index 00000000..8be6ffc4 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class NoTurn extends ChoosePiece { + public NoTurn(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java new file mode 100644 index 00000000..e8af5bb8 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class PowerCard extends Turn { + public PowerCard(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java new file mode 100644 index 00000000..f38ee1fb --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class RollDice extends Turn { + public RollDice(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java new file mode 100644 index 00000000..e4f69e46 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class SecondRoll extends RollDice { + public SecondRoll(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java new file mode 100644 index 00000000..e5ddb601 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class SelectPiece extends ChoosePiece { + public SelectPiece(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java new file mode 100644 index 00000000..4b1b3c92 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java @@ -0,0 +1,133 @@ +package pp.mdga.message.server; + +import com.jme3.network.Server; +import pp.mdga.game.Game; +import pp.mdga.message.client.*; +import pp.mdga.message.server.ServerSender; +import pp.mdga.message.server.ServerState; +import pp.mdga.server.Lobby; + +import java.lang.System.Logger; +import java.lang.System.Logger.Level; +import java.util.ArrayList; + +public class ServerGameLogic implements ClientInterpreter { + private static final Logger LOGGER = System.getLogger(ServerGameLogic.class.getName()); + + private final ServerSender serverSender; + + private final Game game; + + private final ServerState state; + + private final ServerState lobby = new Lobby(this); + private final ServerState game = new Game(this); + private final ServerState interrupt = new Interrupt(this); + private final ServerState ceremony = new Ceremony(this); + private final ServerState turn = new Turn(this); + private final ServerState determineStartPlayer = new DetermineStartPlayer(this); + private final ServerState rollDice = new RollDice(this); + private final ServerState powerCard = new PowerCard(this); + private final ServerState movePiece = new MovePiece(this); + private final ServerState choosePiece = new ChoosePiece(this); + private final ServerState firstRoll = new FirstRoll(this); + private final ServerState secondRoll = new SecondRoll(this); + private final ServerState thirdRoll = new ThirdRoll(this); + private final ServerState noPiece = new NoPiece(this); + private final ServerState noTurn = new NoTurn(this); + private final ServerState waitingPiece = new WaitingPiece(this); + private final ServerState startPiece = new StartPiece(this); + private final ServerState selectPiece = new SelectPiece(this); + + public ServerGameLogic(ServerSender serverSender, Game game) { + this.serverSender = serverSender; + this.game = game; + this.state = lobby; + } + + + @Override + public void received(AnimationEnd msg, int from) { + + } + + @Override + public void received(DeselectTSK msg, int from) { + + } + + @Override + public void received(ForceStartGame msg, int from) { + + } + + @Override + public void received(JoinServer msg, int from) { + + } + + @Override + public void received(LeaveGame msg, int from) { + + } + + @Override + public void received(LobbyNotReady msg, int from) { + + } + + @Override + public void received(LobbyReady msg, int from) { + + } + + @Override + public void received(RequestBriefing msg, int from) { + + } + + @Override + public void received(RequestDice msg, int from) { + + } + + @Override + public void received(RequestMove msg, int from) { + + } + + @Override + public void received(RequestPlayCard msg, int from) { + + } + + @Override + public void received(SelectCard msg, int from) { + + } + + @Override + public void received(SelectTSK msg, int from) { + + } + + @Override + public void received(ForceContinueGame msg, int from) { + + } + + @Override + public void received(ClientStartGame msg, int from) { + + } + + @Override + public void received(NoPowerCard msg, int from) { + + } + + @Override + public void received(SelectedPieces msg, int from) { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java new file mode 100644 index 00000000..8e104226 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java @@ -0,0 +1,16 @@ +package pp.mdga.message.server; + +import pp.mdga.message.server.ServerMessage; + +/** + * Interface for sending messages to a client. + */ +public interface ServerSender { + /** + * Send the specified message to the client. + * + * @param id the id of the client that shall receive the message + * @param message the message + */ + void send(int id, ServerMessage message); +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java new file mode 100644 index 00000000..8c6cbded --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java @@ -0,0 +1,28 @@ +package pp.mdga.message.server; + +import pp.mdga.game.Game; +import pp.mdga.message.server.ServerGameLogic; + +/** + * Defines the behavior and state transitions for the server-side game logic. + * Different states of the game logic implement this interface to handle various game events and actions. + */ +public class ServerState { + /** + * The server logic object. + */ + private final ServerGameLogic logic; + + /** + * Constructs a server state of the specified game logic. + * + * @param logic the game logic + */ + public ServerState(ServerGameLogic logic) { + this.logic = logic; + } + + + + +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java new file mode 100644 index 00000000..f6ad7a2a --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class StartPiece extends ChoosePiece { + public StartPiece(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java new file mode 100644 index 00000000..80863ef7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class ThirdRoll extends RollDice { + public ThirdRoll(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java new file mode 100644 index 00000000..ecbbde39 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class Turn extends Game { + public Turn(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java new file mode 100644 index 00000000..a3d665d0 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.message.server.ServerGameLogic; + +public class WaitingPiece extends ChoosePiece { + public WaitingPiece(ServerGameLogic logic) { + super(logic); + } +} From 06195854d892bd919b6e8b71e0722a38ffc8ed73 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Mon, 25 Nov 2024 16:35:49 +0100 Subject: [PATCH 41/44] added mdga server controller --- .../pp/mdga/client/server/MdgaServer.java | 209 ++++++++++++++++++ .../mdga/client/server/ReceivedMessage.java | 10 + .../model/src/main/resources/mdga.properties | 0 .../src/main/resources/mdga_de.properties | 0 4 files changed, 219 insertions(+) create mode 100644 Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java create mode 100644 Projekte/mdga/client/src/main/java/pp/mdga/client/server/ReceivedMessage.java create mode 100644 Projekte/mdga/model/src/main/resources/mdga.properties create mode 100644 Projekte/mdga/model/src/main/resources/mdga_de.properties diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java new file mode 100644 index 00000000..c7799d87 --- /dev/null +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java @@ -0,0 +1,209 @@ +package pp.mdga.client.server; + +import com.jme3.network.ConnectionListener; +import com.jme3.network.HostedConnection; +import com.jme3.network.Message; +import com.jme3.network.MessageListener; +import com.jme3.network.Network; +import com.jme3.network.Server; +import com.jme3.network.serializing.Serializer; +import pp.mdga.game.Game; +import pp.mdga.game.Player; +import pp.mdga.message.client.*; +import pp.mdga.message.server.*; + +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.logging.LogManager; + +/** + * Server implementing the visitor pattern as MessageReceiver for ClientMessages + */ +public class MdgaServer implements MessageListener, ConnectionListener, ServerSender { + private static final Logger LOGGER = System.getLogger(MdgaServer.class.getName()); + + private Server myServer; + private final ServerGameLogic logic; + private final BlockingQueue pendingMessages = new LinkedBlockingQueue<>(); + + static { + // Configure logging + LogManager manager = LogManager.getLogManager(); + try { + manager.readConfiguration(new FileInputStream("logging.properties")); + LOGGER.log(Level.INFO, "Successfully read logging properties"); //NON-NLS + } catch (IOException e) { + LOGGER.log(Level.INFO, e.getMessage()); + } + } + + /** + * Starts the Battleships server. + */ + public static void main(String[] args) { + new MdgaServer().run(); + } + + /** + * Creates a new MdgaServer. + */ + public MdgaServer() { + LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS + logic = new ServerGameLogic(new Game(), this); + } + + public void run() { + startServer(); + this.connectionAdded(myServer, myServer.getConnection(0)); + while (true) + processNextMessage(); + } + + private void startServer() { + try { + LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS + myServer = Network.createServer(1234); + + initializeSerializables(); + myServer.start(); + registerListeners(); + LOGGER.log(Level.INFO, "Server started: {0}", myServer.isRunning()); //NON-NLS + } catch (IOException e) { + LOGGER.log(Level.ERROR, "Couldn't start server: {0}", e.getMessage()); //NON-NLS + exit(1); + } + } + + private void processNextMessage() { + try { + pendingMessages.take().process(logic); + } catch (InterruptedException ex) { + LOGGER.log(Level.INFO, "Interrupted while waiting for messages"); //NON-NLS + Thread.currentThread().interrupt(); + } + } + + private void initializeSerializables() { + Serializer.registerClass(AnimationEnd.class); + Serializer.registerClass(ClientStartGame.class); + Serializer.registerClass(DeselectTSK.class); + Serializer.registerClass(ForceContinueGame.class); + Serializer.registerClass(ForceStartGame.class); + Serializer.registerClass(JoinServer.class); + Serializer.registerClass(LeaveGame.class); + Serializer.registerClass(LobbyNotReady.class); + Serializer.registerClass(LobbyReady.class); + Serializer.registerClass(NoPowerCard.class); + Serializer.registerClass(RequestBriefing.class); + Serializer.registerClass(RequestDice.class); + Serializer.registerClass(RequestMove.class); + Serializer.registerClass(RequestPlayCard.class); + Serializer.registerClass(SelectCard.class); + Serializer.registerClass(SelectedPieces.class); + Serializer.registerClass(SelectTSK.class); + + Serializer.registerClass(ActivePlayer.class); + Serializer.registerClass(AnyPiece.class); + Serializer.registerClass(Briefing.class); + Serializer.registerClass(CeremonyMessage.class); + Serializer.registerClass(Dice.class); + Serializer.registerClass(DiceAgain.class); + Serializer.registerClass(DiceNow.class); + Serializer.registerClass(EndOfTurn.class); + Serializer.registerClass(LobbyAccept.class); + Serializer.registerClass(LobbyDeny.class); + Serializer.registerClass(LobbyPlayerJoin.class); + Serializer.registerClass(LobbyPlayerLeave.class); + Serializer.registerClass(MoveMessage.class); + Serializer.registerClass(NoTurn.class); + Serializer.registerClass(PauseGame.class); + Serializer.registerClass(PlayCard.class); + Serializer.registerClass(PossibleCard.class); + Serializer.registerClass(PossiblePiece.class); + Serializer.registerClass(RankingResponse.class); + Serializer.registerClass(RankingRollAgain.class); + Serializer.registerClass(ReconnectBriefing.class); + Serializer.registerClass(ResumeGame.class); + Serializer.registerClass(ServerStartGame.class); + Serializer.registerClass(StartPiece.class); + Serializer.registerClass(UpdateReady.class); + Serializer.registerClass(UpdateTSK.class); + Serializer.registerClass(WaitPiece.class); + } + + private void registerListeners() { + myServer.addMessageListener(this, AnimationEnd.class); + myServer.addMessageListener(this, ClientStartGame.class); + myServer.addMessageListener(this, DeselectTSK.class); + myServer.addMessageListener(this, ForceContinueGame.class); + myServer.addMessageListener(this, ForceStartGame.class); + myServer.addMessageListener(this, JoinServer.class); + myServer.addMessageListener(this, LeaveGame.class); + myServer.addMessageListener(this, LobbyNotReady.class); + myServer.addMessageListener(this, LobbyReady.class); + myServer.addMessageListener(this, NoPowerCard.class); + myServer.addMessageListener(this, RequestBriefing.class); + myServer.addMessageListener(this, RequestDice.class); + myServer.addMessageListener(this, RequestMove.class); + myServer.addMessageListener(this, RequestPlayCard.class); + myServer.addMessageListener(this, SelectCard.class); + myServer.addMessageListener(this, SelectedPieces.class); + myServer.addMessageListener(this, SelectTSK.class); + myServer.addConnectionListener(this); + } + + @Override + public void messageReceived(HostedConnection source, Message message) { + LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS + if (message instanceof ClientMessage clientMessage) + pendingMessages.add(new ReceivedMessage(clientMessage, source.getId())); + } + + @Override + public void connectionAdded(Server server, HostedConnection hostedConnection) { + LOGGER.log(Level.INFO, "new connection {0}", hostedConnection); //NON-NLS + logic.addPlayer(hostedConnection.getId()); + } + + @Override + public void connectionRemoved(Server server, HostedConnection hostedConnection) { + LOGGER.log(Level.INFO, "connection closed: {0}", hostedConnection); //NON-NLS + final Player player = logic.getPlayerById(hostedConnection.getId()); + if (player == null) + LOGGER.log(Level.INFO, "closed connection does not belong to an active player"); //NON-NLS + else { //NON-NLS + LOGGER.log(Level.INFO, "closed connection belongs to {0}", player); //NON-NLS + exit(0); + } + } + + private void exit(int exitValue) { //NON-NLS + LOGGER.log(Level.INFO, "close request"); //NON-NLS + if (myServer != null) + for (HostedConnection client : myServer.getConnections()) //NON-NLS + if (client != null) client.close("Game over"); //NON-NLS + System.exit(exitValue); + } + + /** + * Send the specified message to the specified connection. + * + * @param id the connection id + * @param message the message + */ + public void send(int id, ServerMessage message) { + if (myServer == null || !myServer.isRunning()) { + LOGGER.log(Level.ERROR, "no server running when trying to send {0}", message); //NON-NLS + return; + } + final HostedConnection connection = myServer.getConnection(id); + if (connection != null) + connection.send(message); + else + LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS + } +} diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/server/ReceivedMessage.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/ReceivedMessage.java new file mode 100644 index 00000000..c9c674cc --- /dev/null +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/ReceivedMessage.java @@ -0,0 +1,10 @@ +package pp.mdga.client.server; + +import pp.mdga.message.client.ClientInterpreter; +import pp.mdga.message.client.ClientMessage; + +public record ReceivedMessage(ClientMessage msg, int from) { + void process(ClientInterpreter interpreter) { + msg.accept(interpreter, from); + } +} diff --git a/Projekte/mdga/model/src/main/resources/mdga.properties b/Projekte/mdga/model/src/main/resources/mdga.properties new file mode 100644 index 00000000..e69de29b diff --git a/Projekte/mdga/model/src/main/resources/mdga_de.properties b/Projekte/mdga/model/src/main/resources/mdga_de.properties new file mode 100644 index 00000000..e69de29b From f2d5221328cac9cbfd8e8af6b572365b0a696c1e Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Mon, 25 Nov 2024 16:36:40 +0100 Subject: [PATCH 42/44] added import statement with the refactored server messages --- .../mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java index e1d1b407..9ec3bca9 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java @@ -2,6 +2,7 @@ import pp.mdga.game.Game; import pp.mdga.message.client.ClientMessage; +import pp.mdga.message.server.*; public class ClientGameLogic implements ServerInterpreter { static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName()); From 7178935553528298627de49226b140ff40c1efe1 Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Mon, 25 Nov 2024 16:41:44 +0100 Subject: [PATCH 43/44] refactored the model to incoporate a correct folder structure --- .../client/src/main/java/pp/mdga/client/MdgaState.java | 4 ---- .../java/pp/mdga/client/NotificationSynchronizer.java | 1 - .../client/board/Outline/SelectObjectOutliner.java | 6 ------ .../main/java/pp/mdga/client/server/MdgaServer.java | 4 ++-- .../src/main/java/pp/mdga/client/view/GameView.java | 5 ----- .../src/main/java/pp/mdga/client/view/LobbyView.java | 1 - .../java/{pp.mdga => pp/mdga}/client/Animation.java | 0 .../{pp.mdga => pp/mdga}/client/AudioSettings.java | 0 .../java/{pp.mdga => pp/mdga}/client/Ceremony.java | 0 .../mdga}/client/CeremonyStateMachine.java | 0 .../java/{pp.mdga => pp/mdga}/client/ChoosePiece.java | 0 .../mdga}/client/ChoosePieceStateMachine.java | 0 .../{pp.mdga => pp/mdga}/client/ChoosePowerCard.java | 0 .../{pp.mdga => pp/mdga}/client/ClientAutomaton.java | 0 .../{pp.mdga => pp/mdga}/client/ClientGameLogic.java | 0 .../java/{pp.mdga => pp/mdga}/client/ClientSender.java | 0 .../java/{pp.mdga => pp/mdga}/client/ClientState.java | 0 .../mdga}/client/ClientStateMachine.java | 2 -- .../mdga}/client/DetermineStartPlayer.java | 0 .../mdga}/client/DetermineStartPlayerStateMachine.java | 0 .../src/main/java/pp/mdga/client/DialogStates.java | 8 ++++++++ .../main/java/{pp.mdga => pp/mdga}/client/Dialogs.java | 0 .../mdga}/client/DialogsStateMachine.java | 0 .../java/{pp.mdga => pp/mdga}/client/GameState.java | 0 .../{pp.mdga => pp/mdga}/client/GameStateMachine.java | 0 .../java/{pp.mdga => pp/mdga}/client/Interrupt.java | 0 .../main/java/{pp.mdga => pp/mdga}/client/Lobby.java | 0 .../java/{pp.mdga => pp/mdga}/client/MainSettings.java | 0 .../java/{pp.mdga => pp/mdga}/client/MovePiece.java | 0 .../{pp.mdga => pp/mdga}/client/NetworkDialog.java | 0 .../main/java/{pp.mdga => pp/mdga}/client/NoPiece.java | 0 .../java/{pp.mdga => pp/mdga}/client/Observer.java | 0 .../{pp.mdga => pp/mdga}/client/PlayPowerCard.java | 0 .../main/java/{pp.mdga => pp/mdga}/client/Podium.java | 0 .../java/{pp.mdga => pp/mdga}/client/PowerCard.java | 0 .../mdga}/client/PowerCardStateMachine.java | 0 .../java/{pp.mdga => pp/mdga}/client/RollDice.java | 0 .../{pp.mdga => pp/mdga}/client/RollRankingDice.java | 0 .../java/{pp.mdga => pp/mdga}/client/SelectPiece.java | 0 .../java/{pp.mdga => pp/mdga}/client/Settings.java | 0 .../mdga}/client/SettingsStateMachine.java | 0 .../main/java/{pp.mdga => pp/mdga}/client/Shield.java | 0 .../java/{pp.mdga => pp/mdga}/client/Spectator.java | 0 .../java/{pp.mdga => pp/mdga}/client/StartDialog.java | 2 +- .../java/{pp.mdga => pp/mdga}/client/StartPiece.java | 0 .../java/{pp.mdga => pp/mdga}/client/Statistics.java | 0 .../main/java/{pp.mdga => pp/mdga}/client/Swap.java | 0 .../main/java/{pp.mdga => pp/mdga}/client/Turn.java | 0 .../{pp.mdga => pp/mdga}/client/TurnStateMachine.java | 0 .../{pp.mdga => pp/mdga}/client/VideoSettings.java | 0 .../java/{pp.mdga => pp/mdga}/client/WaitRanking.java | 0 .../main/java/{pp.mdga => pp/mdga}/client/Waiting.java | 0 .../java/{pp.mdga => pp/mdga}/client/WaitingPiece.java | 0 .../src/main/java/{pp.mdga => pp/mdga}/game/Board.java | 0 .../main/java/{pp.mdga => pp/mdga}/game/BonusCard.java | 0 .../main/java/{pp.mdga => pp/mdga}/game/BonusNode.java | 0 .../src/main/java/{pp.mdga => pp/mdga}/game/Color.java | 0 .../src/main/java/{pp.mdga => pp/mdga}/game/Game.java | 0 .../main/java/{pp.mdga => pp/mdga}/game/HomeNode.java | 0 .../src/main/java/{pp.mdga => pp/mdga}/game/Node.java | 0 .../src/main/java/{pp.mdga => pp/mdga}/game/Piece.java | 0 .../java/{pp.mdga => pp/mdga}/game/PieceState.java | 0 .../main/java/{pp.mdga => pp/mdga}/game/Player.java | 0 .../java/{pp.mdga => pp/mdga}/game/PlayerData.java | 0 .../java/{pp.mdga => pp/mdga}/game/ShieldState.java | 0 .../main/java/{pp.mdga => pp/mdga}/game/StartNode.java | 0 .../main/java/{pp.mdga => pp/mdga}/game/Statistic.java | 0 .../mdga}/message/client/AnimationEnd.java | 0 .../mdga}/message/client/ClientInterpreter.java | 0 .../mdga}/message/client/ClientMessage.java | 0 .../mdga}/message/client/ClientStartGame.java | 0 .../mdga}/message/client/DeselectTSK.java | 0 .../mdga}/message/client/ForceContinueGame.java | 0 .../mdga}/message/client/ForceStartGame.java | 0 .../mdga}/message/client/JoinServer.java | 0 .../{pp.mdga => pp/mdga}/message/client/LeaveGame.java | 0 .../mdga}/message/client/LobbyNotReady.java | 0 .../mdga}/message/client/LobbyReady.java | 0 .../mdga}/message/client/NoPowerCard.java | 0 .../mdga}/message/client/RequestBriefing.java | 0 .../mdga}/message/client/RequestDice.java | 0 .../mdga}/message/client/RequestMove.java | 0 .../mdga}/message/client/RequestPlayCard.java | 0 .../mdga}/message/client/SelectCard.java | 0 .../{pp.mdga => pp/mdga}/message/client/SelectTSK.java | 0 .../mdga}/message/client/SelectedPieces.java | 0 .../mdga}/message/server/ActivePlayer.java | 0 .../{pp.mdga => pp/mdga}/message/server/AnyPiece.java | 0 .../{pp.mdga => pp/mdga}/message/server/Briefing.java | 0 .../mdga}/message/server/CeremonyMessage.java | 0 .../java/{pp.mdga => pp/mdga}/message/server/Dice.java | 0 .../{pp.mdga => pp/mdga}/message/server/DiceAgain.java | 0 .../{pp.mdga => pp/mdga}/message/server/DiceNow.java | 0 .../{pp.mdga => pp/mdga}/message/server/EndOfTurn.java | 0 .../mdga}/message/server/LobbyAccept.java | 0 .../{pp.mdga => pp/mdga}/message/server/LobbyDeny.java | 0 .../mdga}/message/server/LobbyPlayerJoin.java | 0 .../mdga}/message/server/LobbyPlayerLeave.java | 0 .../mdga}/message/server/MoveMessage.java | 0 .../{pp.mdga => pp/mdga}/message/server/NoTurn.java | 0 .../{pp.mdga => pp/mdga}/message/server/PauseGame.java | 0 .../{pp.mdga => pp/mdga}/message/server/PlayCard.java | 0 .../mdga}/message/server/PossibleCard.java | 0 .../mdga}/message/server/PossiblePiece.java | 0 .../mdga}/message/server/RankingResponse.java | 0 .../mdga}/message/server/RankingRollAgain.java | 0 .../mdga}/message/server/ReconnectBriefing.java | 0 .../mdga}/message/server/ResumeGame.java | 0 .../mdga}/message/server/ServerInterpreter.java | 0 .../mdga}/message/server/ServerMessage.java | 0 .../mdga}/message/server/ServerStartGame.java | 0 .../mdga}/message/server/StartPiece.java | 0 .../mdga}/message/server/UpdateReady.java | 0 .../{pp.mdga => pp/mdga}/message/server/UpdateTSK.java | 0 .../{pp.mdga => pp/mdga}/message/server/WaitPiece.java | 0 .../mdga}/notification/AcquireCardNotification.java | 0 .../mdga}/notification/ActivePlayerNotification.java | 0 .../mdga}/notification/CeremonyNotification.java | 0 .../mdga}/notification/DiceNowNotification.java | 0 .../mdga}/notification/DicingNotification.java | 0 .../mdga}/notification/DrawCardNotification.java | 0 .../mdga}/notification/GameNotification.java | 0 .../mdga}/notification/HomeMoveNotification.java | 0 .../mdga}/notification/InterruptNotification.java | 0 .../mdga}/notification/LobbyDialogNotification.java | 0 .../mdga}/notification/MovePieceNotification.java | 0 .../mdga}/notification/MoveThrowPieceNotification.java | 0 .../mdga}/notification/NoShieldNotification.java | 0 .../mdga}/notification/Notification.java | 0 .../mdga}/notification/PieceInGameNotification.java | 0 .../mdga}/notification/PlayCardNotification.java | 0 .../mdga}/notification/PlayerInGameNotification.java | 0 .../mdga}/notification/ResumeNotification.java | 0 .../mdga}/notification/RollDiceNotification.java | 0 .../notification/SelectableCardsNotification.java | 0 .../notification/SelectablePiecesNotification.java | 0 .../mdga}/notification/ShieldActiveNotification.java | 0 .../notification/ShieldSuppressedNotification.java | 0 .../mdga}/notification/StartDialogNotification.java | 0 .../mdga}/notification/SwapPieceNotification.java | 0 .../mdga}/notification/TskSelectNotification.java | 0 .../mdga}/notification/TskUnselectNotification.java | 0 .../mdga}/notification/WaitMoveNotification.java | 0 .../java/{pp.mdga => pp/mdga}/server/Ceremony.java | 3 --- .../java/{pp.mdga => pp/mdga}/server/ChoosePiece.java | 2 -- .../mdga}/server/DetermineStartPlayer.java | 2 -- .../java/{pp.mdga => pp/mdga}/server/FirstRoll.java | 2 -- .../main/java/{pp.mdga => pp/mdga}/server/Game.java | 3 --- .../java/{pp.mdga => pp/mdga}/server/Interrupt.java | 3 --- .../main/java/{pp.mdga => pp/mdga}/server/Lobby.java | 3 --- .../java/{pp.mdga => pp/mdga}/server/MovePiece.java | 2 -- .../main/java/{pp.mdga => pp/mdga}/server/NoPiece.java | 2 -- .../main/java/{pp.mdga => pp/mdga}/server/NoTurn.java | 2 -- .../java/{pp.mdga => pp/mdga}/server/PowerCard.java | 2 -- .../java/{pp.mdga => pp/mdga}/server/RollDice.java | 2 -- .../java/{pp.mdga => pp/mdga}/server/SecondRoll.java | 2 -- .../java/{pp.mdga => pp/mdga}/server/SelectPiece.java | 2 -- .../{pp.mdga => pp/mdga}/server/ServerGameLogic.java | 10 +++------- .../java/{pp.mdga => pp/mdga}/server/ServerSender.java | 2 +- .../java/{pp.mdga => pp/mdga}/server/ServerState.java | 5 +---- .../java/{pp.mdga => pp/mdga}/server/StartPiece.java | 2 -- .../java/{pp.mdga => pp/mdga}/server/ThirdRoll.java | 2 -- .../main/java/{pp.mdga => pp/mdga}/server/Turn.java | 2 -- .../java/{pp.mdga => pp/mdga}/server/WaitingPiece.java | 2 -- .../pp/mdga/client/clientState/ClientStateTest.java | 1 - .../pp/mdga/server/serverState/ServerStateTest.java | 2 -- 166 files changed, 16 insertions(+), 77 deletions(-) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Animation.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/AudioSettings.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Ceremony.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/CeremonyStateMachine.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/ChoosePiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/ChoosePieceStateMachine.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/ChoosePowerCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/ClientAutomaton.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/ClientGameLogic.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/ClientSender.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/ClientState.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/ClientStateMachine.java (97%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/DetermineStartPlayer.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/DetermineStartPlayerStateMachine.java (100%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/DialogStates.java rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Dialogs.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/DialogsStateMachine.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/GameState.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/GameStateMachine.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Interrupt.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Lobby.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/MainSettings.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/MovePiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/NetworkDialog.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/NoPiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Observer.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/PlayPowerCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Podium.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/PowerCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/PowerCardStateMachine.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/RollDice.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/RollRankingDice.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/SelectPiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Settings.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/SettingsStateMachine.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Shield.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Spectator.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/StartDialog.java (73%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/StartPiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Statistics.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Swap.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Turn.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/TurnStateMachine.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/VideoSettings.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/WaitRanking.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/Waiting.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/client/WaitingPiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/Board.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/BonusCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/BonusNode.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/Color.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/Game.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/HomeNode.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/Node.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/Piece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/PieceState.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/Player.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/PlayerData.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/ShieldState.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/StartNode.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/game/Statistic.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/AnimationEnd.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/ClientInterpreter.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/ClientMessage.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/ClientStartGame.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/DeselectTSK.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/ForceContinueGame.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/ForceStartGame.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/JoinServer.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/LeaveGame.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/LobbyNotReady.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/LobbyReady.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/NoPowerCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/RequestBriefing.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/RequestDice.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/RequestMove.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/RequestPlayCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/SelectCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/SelectTSK.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/client/SelectedPieces.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/ActivePlayer.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/AnyPiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/Briefing.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/CeremonyMessage.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/Dice.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/DiceAgain.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/DiceNow.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/EndOfTurn.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/LobbyAccept.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/LobbyDeny.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/LobbyPlayerJoin.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/LobbyPlayerLeave.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/MoveMessage.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/NoTurn.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/PauseGame.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/PlayCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/PossibleCard.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/PossiblePiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/RankingResponse.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/RankingRollAgain.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/ReconnectBriefing.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/ResumeGame.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/ServerInterpreter.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/ServerMessage.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/ServerStartGame.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/StartPiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/UpdateReady.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/UpdateTSK.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/message/server/WaitPiece.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/AcquireCardNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/ActivePlayerNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/CeremonyNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/DiceNowNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/DicingNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/DrawCardNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/GameNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/HomeMoveNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/InterruptNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/LobbyDialogNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/MovePieceNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/MoveThrowPieceNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/NoShieldNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/Notification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/PieceInGameNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/PlayCardNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/PlayerInGameNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/ResumeNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/RollDiceNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/SelectableCardsNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/SelectablePiecesNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/ShieldActiveNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/ShieldSuppressedNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/StartDialogNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/SwapPieceNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/TskSelectNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/TskUnselectNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/notification/WaitMoveNotification.java (100%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/Ceremony.java (61%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/ChoosePiece.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/DetermineStartPlayer.java (77%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/FirstRoll.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/Game.java (59%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/Interrupt.java (61%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/Lobby.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/MovePiece.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/NoPiece.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/NoTurn.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/PowerCard.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/RollDice.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/SecondRoll.java (75%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/SelectPiece.java (75%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/ServerGameLogic.java (92%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/ServerSender.java (91%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/ServerState.java (83%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/StartPiece.java (75%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/ThirdRoll.java (74%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/Turn.java (72%) rename Projekte/mdga/model/src/main/java/{pp.mdga => pp/mdga}/server/WaitingPiece.java (76%) diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaState.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaState.java index 58414b23..74b4f91a 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaState.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaState.java @@ -1,9 +1,5 @@ package pp.mdga.client; -import pp.mdga.notification.Notification; -import pp.mdga.notification.PieceInGameNotification; -import pp.mdga.notification.PlayerInGameNotification; - public enum MdgaState { NONE, MAIN, diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java index 76767434..44a6c726 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java @@ -2,7 +2,6 @@ import pp.mdga.client.view.GameView; import pp.mdga.client.view.LobbyView; -import pp.mdga.notification.*; import java.util.ArrayList; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/Outline/SelectObjectOutliner.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/Outline/SelectObjectOutliner.java index e54a97c8..993e71d8 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/Outline/SelectObjectOutliner.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/Outline/SelectObjectOutliner.java @@ -1,18 +1,12 @@ package pp.mdga.client.board.Outline; import com.jme3.asset.AssetManager; -import com.jme3.material.Material; -import com.jme3.material.RenderState; -import com.jme3.material.RenderState.BlendMode; import com.jme3.math.ColorRGBA; -import com.jme3.post.Filter; import com.jme3.post.FilterPostProcessor; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; -import com.jme3.scene.Node; import com.jme3.scene.Spatial; -import pp.mdga.game.Color; public class SelectObjectOutliner { diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java index c7799d87..a128bb82 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java @@ -9,8 +9,8 @@ import com.jme3.network.serializing.Serializer; import pp.mdga.game.Game; import pp.mdga.game.Player; -import pp.mdga.message.client.*; -import pp.mdga.message.server.*; +import pp.mdga.server.ServerGameLogic; +import pp.mdga.server.ServerSender; import java.io.FileInputStream; import java.io.IOException; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java index 2a3a04e7..e41c1614 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java @@ -8,11 +8,6 @@ import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaState; import pp.mdga.client.gui.GuiHandler; -import pp.mdga.game.Color; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; public class GameView extends MdgaView { private BoardHandler boardHandler; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java index d15c7010..d594bb9e 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java @@ -5,7 +5,6 @@ import pp.mdga.client.dialog.SingleButtonLeftDialog; import pp.mdga.client.dialog.SingleButtonRightDialog; import pp.mdga.client.MdgaApp; -import pp.mdga.client.MdgaState; import pp.mdga.game.Color; import java.util.ArrayList; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Animation.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Animation.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/AudioSettings.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/AudioSettings.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Ceremony.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Ceremony.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/CeremonyStateMachine.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/CeremonyStateMachine.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePieceStateMachine.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePieceStateMachine.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePowerCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePowerCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientAutomaton.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientAutomaton.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/ClientAutomaton.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ClientAutomaton.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientGameLogic.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ClientGameLogic.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientSender.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientSender.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/ClientSender.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ClientSender.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientState.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/ClientState.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ClientState.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientStateMachine.java similarity index 97% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/ClientStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ClientStateMachine.java index 92620f35..9537ccb7 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientStateMachine.java @@ -1,7 +1,5 @@ package pp.mdga.client; -import pp.mdga.message.server.*; - public abstract class ClientStateMachine extends ClientState { private ClientState state; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayer.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayer.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayerStateMachine.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayerStateMachine.java diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogStates.java new file mode 100644 index 00000000..f5ad1568 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogStates.java @@ -0,0 +1,8 @@ +package pp.mdga.client; + +public abstract class DialogStates extends ClientState{ + + public DialogStates(ClientState parent, ClientGameLogic logic){ + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Dialogs.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Dialogs.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogsStateMachine.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/DialogsStateMachine.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/GameState.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/GameState.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/GameStateMachine.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/GameStateMachine.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Interrupt.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Interrupt.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Lobby.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Lobby.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/MainSettings.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/MainSettings.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/MovePiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/MovePiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/NetworkDialog.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/NetworkDialog.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/NoPiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/NoPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Observer.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Observer.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Observer.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Observer.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/PlayPowerCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/PlayPowerCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Podium.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Podium.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCardStateMachine.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCardStateMachine.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/RollDice.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/RollDice.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/RollRankingDice.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/RollRankingDice.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/SelectPiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/SelectPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Settings.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Settings.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/SettingsStateMachine.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/SettingsStateMachine.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Shield.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Shield.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Spectator.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Spectator.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/StartDialog.java similarity index 73% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/StartDialog.java index ee529941..90bb1e2b 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/StartDialog.java @@ -1,6 +1,6 @@ package pp.mdga.client; -public class StartDialog extends ClientState { +public class StartDialog extends DialogStates { public StartDialog(ClientState parent, ClientGameLogic logic) { super(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/StartPiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/StartPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Statistics.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Statistics.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Swap.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Swap.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Turn.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Turn.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/TurnStateMachine.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/TurnStateMachine.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/VideoSettings.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/VideoSettings.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/WaitRanking.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/WaitRanking.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Waiting.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Waiting.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/WaitingPiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/WaitingPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Board.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Board.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/Board.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/Board.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/BonusCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/BonusCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/BonusCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/BonusNode.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusNode.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/BonusNode.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/BonusNode.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Color.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Color.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/Color.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/Color.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/Game.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/HomeNode.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/HomeNode.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/HomeNode.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/HomeNode.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Node.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Node.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/Node.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/Node.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Piece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/Piece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/PieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/PieceState.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/PieceState.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/PieceState.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Player.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/Player.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/PlayerData.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/PlayerData.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/PlayerData.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/ShieldState.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/ShieldState.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/ShieldState.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/ShieldState.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/StartNode.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/StartNode.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/StartNode.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/StartNode.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/game/Statistic.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Statistic.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/game/Statistic.java rename to Projekte/mdga/model/src/main/java/pp/mdga/game/Statistic.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/AnimationEnd.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/AnimationEnd.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/AnimationEnd.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/AnimationEnd.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientInterpreter.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientInterpreter.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientInterpreter.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientInterpreter.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientMessage.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientMessage.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientMessage.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientStartGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientStartGame.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientStartGame.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientStartGame.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/DeselectTSK.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/DeselectTSK.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceContinueGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ForceContinueGame.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceContinueGame.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/ForceContinueGame.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceStartGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ForceStartGame.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceStartGame.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/ForceStartGame.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/JoinServer.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/JoinServer.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/JoinServer.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/JoinServer.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LeaveGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LeaveGame.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/LeaveGame.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/LeaveGame.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyNotReady.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyNotReady.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyNotReady.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyNotReady.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyReady.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyReady.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyReady.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyReady.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/NoPowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/NoPowerCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/NoPowerCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/NoPowerCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestBriefing.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestBriefing.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestBriefing.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestBriefing.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestDice.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestDice.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestDice.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestDice.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestMove.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestMove.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestPlayCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestPlayCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectTSK.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectTSK.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectedPieces.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectedPieces.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ActivePlayer.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/ActivePlayer.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/AnyPiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/AnyPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/Briefing.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/Briefing.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/CeremonyMessage.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/CeremonyMessage.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/CeremonyMessage.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/Dice.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/Dice.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/DiceAgain.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/DiceAgain.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/DiceNow.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/DiceNow.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/EndOfTurn.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/EndOfTurn.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyAccept.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyAccept.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyDeny.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyDeny.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerJoin.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerJoin.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerLeave.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerLeave.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/MoveMessage.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/MoveMessage.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/NoTurn.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/NoTurn.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PauseGame.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/PauseGame.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PlayCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/PlayCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PossibleCard.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/PossibleCard.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PossiblePiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/PossiblePiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/RankingResponse.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingResponse.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/RankingResponse.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/RankingRollAgain.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/RankingRollAgain.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ReconnectBriefing.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/ReconnectBriefing.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ResumeGame.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/ResumeGame.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerInterpreter.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerInterpreter.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerMessage.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerMessage.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerStartGame.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerStartGame.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/StartPiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/StartPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/UpdateReady.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/UpdateReady.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/UpdateTSK.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/UpdateTSK.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/WaitPiece.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/message/server/WaitPiece.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/AcquireCardNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/AcquireCardNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/AcquireCardNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/AcquireCardNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/ActivePlayerNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/ActivePlayerNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/ActivePlayerNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/ActivePlayerNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/CeremonyNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/CeremonyNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/CeremonyNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/CeremonyNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/DiceNowNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/DiceNowNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/DiceNowNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/DiceNowNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/DicingNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/DicingNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/DicingNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/DicingNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/DrawCardNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/DrawCardNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/DrawCardNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/DrawCardNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/GameNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/GameNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/GameNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/GameNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/HomeMoveNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/HomeMoveNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/HomeMoveNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/HomeMoveNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/InterruptNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/InterruptNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/InterruptNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/InterruptNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/LobbyDialogNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/LobbyDialogNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/LobbyDialogNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/LobbyDialogNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/MovePieceNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/MovePieceNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/MovePieceNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/MovePieceNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/MoveThrowPieceNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/MoveThrowPieceNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/MoveThrowPieceNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/MoveThrowPieceNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/NoShieldNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/NoShieldNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/NoShieldNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/NoShieldNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/Notification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/Notification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/Notification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/Notification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/PieceInGameNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/PieceInGameNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/PieceInGameNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/PieceInGameNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/PlayCardNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/PlayCardNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/PlayCardNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/PlayCardNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/PlayerInGameNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/PlayerInGameNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/PlayerInGameNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/PlayerInGameNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/ResumeNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/ResumeNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/ResumeNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/ResumeNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/RollDiceNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/RollDiceNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/RollDiceNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/RollDiceNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/SelectableCardsNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableCardsNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/SelectableCardsNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableCardsNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/SelectablePiecesNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectablePiecesNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/SelectablePiecesNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectablePiecesNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/ShieldActiveNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/ShieldActiveNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/ShieldActiveNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/ShieldActiveNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/ShieldSuppressedNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/ShieldSuppressedNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/ShieldSuppressedNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/ShieldSuppressedNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/StartDialogNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/StartDialogNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/StartDialogNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/StartDialogNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/SwapPieceNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/SwapPieceNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/SwapPieceNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/SwapPieceNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/TskSelectNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/TskSelectNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/TskSelectNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/TskSelectNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/TskUnselectNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/TskUnselectNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/TskUnselectNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/TskUnselectNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/WaitMoveNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/WaitMoveNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/WaitMoveNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/WaitMoveNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/Ceremony.java similarity index 61% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/Ceremony.java index 8e00391d..35c9b51c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Ceremony.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/Ceremony.java @@ -1,8 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; -import pp.mdga.message.server.ServerState; - public class Ceremony extends ServerState { public Ceremony(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/ChoosePiece.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/ChoosePiece.java index 21bee23d..a91abdea 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ChoosePiece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ChoosePiece.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class ChoosePiece extends Turn { public ChoosePiece(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/DetermineStartPlayer.java similarity index 77% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/DetermineStartPlayer.java index df8bf459..3686ab3e 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/DetermineStartPlayer.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class DetermineStartPlayer extends Game { public DetermineStartPlayer(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/FirstRoll.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/FirstRoll.java index b993534d..18ceb186 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/FirstRoll.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/FirstRoll.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class FirstRoll extends RollDice { public FirstRoll(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/Game.java similarity index 59% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/Game.java index 773570ed..ad3f5897 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/Game.java @@ -1,8 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; -import pp.mdga.message.server.ServerState; - public class Game extends ServerState { public Game(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/Interrupt.java similarity index 61% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/Interrupt.java index 37ce2bde..1f9e0351 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Interrupt.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/Interrupt.java @@ -1,8 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; -import pp.mdga.message.server.ServerState; - public class Interrupt extends ServerState { public Interrupt(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/Lobby.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/Lobby.java index d6b97b9a..02c32338 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/Lobby.java @@ -1,8 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; -import pp.mdga.message.server.ServerState; - public class Lobby extends ServerState { diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/MovePiece.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/MovePiece.java index 14db9e6c..b536b228 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/MovePiece.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class MovePiece extends Turn { public MovePiece(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/NoPiece.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/NoPiece.java index 3953272e..ea3bdfd2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/NoPiece.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class NoPiece extends ChoosePiece { public NoPiece(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/NoTurn.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/NoTurn.java index 8be6ffc4..79c77433 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/NoTurn.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class NoTurn extends ChoosePiece { public NoTurn(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/PowerCard.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/PowerCard.java index e8af5bb8..a00592b0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/PowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/PowerCard.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class PowerCard extends Turn { public PowerCard(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/RollDice.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/RollDice.java index f38ee1fb..f93c7599 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/RollDice.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/RollDice.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class RollDice extends Turn { public RollDice(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/SecondRoll.java similarity index 75% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/SecondRoll.java index e4f69e46..140ac1b9 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/SecondRoll.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/SecondRoll.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class SecondRoll extends RollDice { public SecondRoll(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/SelectPiece.java similarity index 75% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/SelectPiece.java index e5ddb601..d022a16c 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/SelectPiece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/SelectPiece.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class SelectPiece extends ChoosePiece { public SelectPiece(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/ServerGameLogic.java similarity index 92% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/ServerGameLogic.java index 4b1b3c92..bb754961 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ServerGameLogic.java @@ -1,15 +1,11 @@ -package pp.mdga.message.server; +package pp.mdga.server; -import com.jme3.network.Server; import pp.mdga.game.Game; import pp.mdga.message.client.*; -import pp.mdga.message.server.ServerSender; -import pp.mdga.message.server.ServerState; -import pp.mdga.server.Lobby; +import pp.mdga.message.server.NoTurn; +import pp.mdga.message.server.StartPiece; import java.lang.System.Logger; -import java.lang.System.Logger.Level; -import java.util.ArrayList; public class ServerGameLogic implements ClientInterpreter { private static final Logger LOGGER = System.getLogger(ServerGameLogic.class.getName()); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/ServerSender.java similarity index 91% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/ServerSender.java index 8e104226..63ce27b1 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerSender.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ServerSender.java @@ -1,4 +1,4 @@ -package pp.mdga.message.server; +package pp.mdga.server; import pp.mdga.message.server.ServerMessage; diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/ServerState.java similarity index 83% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/ServerState.java index 8c6cbded..949eb48f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ServerState.java @@ -1,7 +1,4 @@ -package pp.mdga.message.server; - -import pp.mdga.game.Game; -import pp.mdga.message.server.ServerGameLogic; +package pp.mdga.server; /** * Defines the behavior and state transitions for the server-side game logic. diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/StartPiece.java similarity index 75% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/StartPiece.java index f6ad7a2a..b3d7a2d5 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/StartPiece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/StartPiece.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class StartPiece extends ChoosePiece { public StartPiece(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/ThirdRoll.java similarity index 74% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/ThirdRoll.java index 80863ef7..cb588fb0 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ThirdRoll.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ThirdRoll.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class ThirdRoll extends RollDice { public ThirdRoll(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/Turn.java similarity index 72% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/Turn.java index ecbbde39..77c28708 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/Turn.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class Turn extends Game { public Turn(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/WaitingPiece.java similarity index 76% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/server/WaitingPiece.java index a3d665d0..ed088e8f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/WaitingPiece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/WaitingPiece.java @@ -1,7 +1,5 @@ package pp.mdga.server; -import pp.mdga.message.server.ServerGameLogic; - public class WaitingPiece extends ChoosePiece { public WaitingPiece(ServerGameLogic logic) { super(logic); diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 468f87b7..d48890a0 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -9,7 +9,6 @@ import pp.mdga.game.Color; import pp.mdga.game.Game; import pp.mdga.message.client.ClientMessage; -import pp.mdga.message.server.*; import java.util.ArrayList; diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 5d11bbce..bd3c78e2 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -3,9 +3,7 @@ import org.junit.Before; import org.junit.Test; import pp.mdga.game.Game; -import pp.mdga.message.client.*; import pp.mdga.message.server.ServerMessage; -import pp.mdga.message.server.WaitPiece; import pp.mdga.server.*; import static org.junit.Assert.*; From 7eafa3da390b2fc136deb700c3c295bfa00157fd Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Mon, 25 Nov 2024 17:43:29 +0100 Subject: [PATCH 44/44] refactored the whole client package structure --- .../main/java/pp/mdga/client/Animation.java | 7 - .../java/pp/mdga/client/AudioSettings.java | 7 - .../main/java/pp/mdga/client/Ceremony.java | 2 + .../mdga/client/ChoosePieceStateMachine.java | 12 -- .../java/pp/mdga/client/ChoosePowerCard.java | 7 - .../java/pp/mdga/client/ClientAutomaton.java | 12 +- .../java/pp/mdga/client/ClientGameLogic.java | 1 + .../java/pp/mdga/client/DialogStates.java | 8 -- .../src/main/java/pp/mdga/client/Dialogs.java | 2 + .../mdga/client/{GameState.java => Game.java} | 6 +- .../main/java/pp/mdga/client/Interrupt.java | 4 +- .../src/main/java/pp/mdga/client/Lobby.java | 7 - .../main/java/pp/mdga/client/MovePiece.java | 7 - .../java/pp/mdga/client/NetworkDialog.java | 7 - .../src/main/java/pp/mdga/client/NoPiece.java | 7 - .../java/pp/mdga/client/PlayPowerCard.java | 7 - .../main/java/pp/mdga/client/RollDice.java | 7 - .../java/pp/mdga/client/RollRankingDice.java | 7 - .../main/java/pp/mdga/client/SelectPiece.java | 7 - .../main/java/pp/mdga/client/Settings.java | 2 + .../src/main/java/pp/mdga/client/Shield.java | 7 - .../main/java/pp/mdga/client/Spectator.java | 7 - .../main/java/pp/mdga/client/StartPiece.java | 7 - .../src/main/java/pp/mdga/client/Swap.java | 7 - .../java/pp/mdga/client/VideoSettings.java | 7 - .../main/java/pp/mdga/client/WaitRanking.java | 7 - .../src/main/java/pp/mdga/client/Waiting.java | 7 - .../java/pp/mdga/client/WaitingPiece.java | 7 - .../CeremonyStateMachine.java | 6 +- .../client/{ => ceremonyState}/Podium.java | 5 +- .../{ => ceremonyState}/Statistics.java | 5 +- .../mdga/client/dialogState/DialogStates.java | 11 ++ .../DialogsStateMachine.java | 6 +- .../pp/mdga/client/dialogState/Lobby.java | 10 ++ .../client/dialogState/NetworkDialog.java | 10 ++ .../client/{ => dialogState}/StartDialog.java | 5 +- .../pp/mdga/client/gameState/Animation.java | 10 ++ .../{ => gameState}/DetermineStartPlayer.java | 8 +- .../{ => gameState}/GameStateMachine.java | 6 +- .../pp/mdga/client/gameState/GameStates.java | 10 ++ .../pp/mdga/client/gameState/Spectator.java | 10 ++ .../pp/mdga/client/{ => gameState}/Turn.java | 8 +- .../pp/mdga/client/gameState/Waiting.java | 10 ++ .../DetermineStartPlayerStateMachine.java | 9 +- .../DetermineStartPlayerStates.java | 11 ++ .../RollRankingDice.java | 11 ++ .../WaitRanking.java | 11 ++ .../turnState}/ChoosePiece.java | 8 +- .../client/gameState/turnState/MovePiece.java | 10 ++ .../gameState/turnState/PlayPowerCard.java | 10 ++ .../{ => gameState/turnState}/PowerCard.java | 8 +- .../client/gameState/turnState/RollDice.java | 10 ++ .../turnState}/TurnStateMachine.java | 6 +- .../gameState/turnState/TurnStates.java | 11 ++ .../ChoosePieceStateMachine.java | 16 +++ .../choosePieceState/ChoosePieceStates.java | 11 ++ .../turnState/choosePieceState/NoPiece.java | 10 ++ .../choosePieceState/SelectPiece.java | 10 ++ .../choosePieceState/StartPiece.java | 10 ++ .../choosePieceState/WaitingPiece.java | 10 ++ .../powerCardState/ChoosePowerCard.java | 10 ++ .../PowerCardStateMachine.java | 6 +- .../powerCardState/PowerCardStates.java | 11 ++ .../turnState/powerCardState/Shield.java | 10 ++ .../turnState/powerCardState/Swap.java | 10 ++ .../client/settingsState/AudioSettings.java | 10 ++ .../{ => settingsState}/MainSettings.java | 5 +- .../client/settingsState/SettingStates.java | 10 ++ .../SettingsStateMachine.java | 6 +- .../client/settingsState/VideoSettings.java | 10 ++ .../client/clientState/ClientStateTest.java | 128 ++++++++++-------- 71 files changed, 457 insertions(+), 233 deletions(-) delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/Animation.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/AudioSettings.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePieceStateMachine.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePowerCard.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/DialogStates.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{GameState.java => Game.java} (64%) delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/Lobby.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/MovePiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/NetworkDialog.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/NoPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/PlayPowerCard.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/RollDice.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/RollRankingDice.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/SelectPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/Shield.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/Spectator.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/StartPiece.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/Swap.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/VideoSettings.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/WaitRanking.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/Waiting.java delete mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/WaitingPiece.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => ceremonyState}/CeremonyStateMachine.java (64%) rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => ceremonyState}/Podium.java (56%) rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => ceremonyState}/Statistics.java (57%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/DialogStates.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => dialogState}/DialogsStateMachine.java (64%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/Lobby.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/NetworkDialog.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => dialogState}/StartDialog.java (58%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Animation.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => gameState}/DetermineStartPlayer.java (63%) rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => gameState}/GameStateMachine.java (62%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/GameStates.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Spectator.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => gameState}/Turn.java (60%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Waiting.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => gameState/determineStartPlayerState}/DetermineStartPlayerStateMachine.java (57%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/DetermineStartPlayerStates.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/RollRankingDice.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/WaitRanking.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => gameState/turnState}/ChoosePiece.java (59%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/MovePiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PlayPowerCard.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => gameState/turnState}/PowerCard.java (59%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/RollDice.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => gameState/turnState}/TurnStateMachine.java (62%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/TurnStates.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/ChoosePieceStateMachine.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/ChoosePieceStates.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/NoPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/SelectPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/StartPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/WaitingPiece.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ChoosePowerCard.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => gameState/turnState/powerCardState}/PowerCardStateMachine.java (62%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/PowerCardStates.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Shield.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Swap.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/AudioSettings.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => settingsState}/MainSettings.java (57%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/SettingStates.java rename Projekte/mdga/model/src/main/java/pp/mdga/client/{ => settingsState}/SettingsStateMachine.java (62%) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/VideoSettings.java diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Animation.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Animation.java deleted file mode 100644 index 6ed12c3b..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Animation.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class Animation extends ClientState { - public Animation(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/AudioSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/AudioSettings.java deleted file mode 100644 index add83883..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/AudioSettings.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class AudioSettings extends ClientState { - public AudioSettings(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Ceremony.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Ceremony.java index 432f90f9..03d5a6d0 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Ceremony.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Ceremony.java @@ -1,5 +1,7 @@ package pp.mdga.client; +import pp.mdga.client.ceremonyState.CeremonyStateMachine; + public class Ceremony extends ClientState { private final CeremonyStateMachine ceremonyStateMachine; diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePieceStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePieceStateMachine.java deleted file mode 100644 index 5346214c..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePieceStateMachine.java +++ /dev/null @@ -1,12 +0,0 @@ -package pp.mdga.client; - -public class ChoosePieceStateMachine extends ClientStateMachine{ - public ChoosePieceStateMachine(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } - - @Override - public NoPiece initialState() { - return new NoPiece(this, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePowerCard.java deleted file mode 100644 index a11259b0..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePowerCard.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class ChoosePowerCard extends ClientState { - public ChoosePowerCard(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientAutomaton.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientAutomaton.java index c90e199b..f3882764 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientAutomaton.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientAutomaton.java @@ -2,13 +2,23 @@ public class ClientAutomaton extends ClientStateMachine { + private Dialogs dialogs; + private Ceremony ceremony; + private Game game; + private Interrupt interrupt; + public ClientAutomaton(ClientGameLogic logic){ super(null, logic); + dialogs = new Dialogs(this, logic); + ceremony = new Ceremony(this, logic); + game = new Game(this, logic); entry(); } + + @Override public Dialogs initialState(){ - return new Dialogs(this, logic); + return dialogs; } } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientGameLogic.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientGameLogic.java index 9ec3bca9..47b4388e 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientGameLogic.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientGameLogic.java @@ -1,5 +1,6 @@ package pp.mdga.client; +import pp.mdga.client.gameState.turnState.choosePieceState.StartPiece; import pp.mdga.game.Game; import pp.mdga.message.client.ClientMessage; import pp.mdga.message.server.*; diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogStates.java deleted file mode 100644 index f5ad1568..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogStates.java +++ /dev/null @@ -1,8 +0,0 @@ -package pp.mdga.client; - -public abstract class DialogStates extends ClientState{ - - public DialogStates(ClientState parent, ClientGameLogic logic){ - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Dialogs.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Dialogs.java index 02a63715..04592b47 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Dialogs.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Dialogs.java @@ -1,5 +1,7 @@ package pp.mdga.client; +import pp.mdga.client.dialogState.DialogsStateMachine; + public class Dialogs extends ClientState { private final DialogsStateMachine dialogsStateMachine; diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/GameState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Game.java similarity index 64% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/GameState.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Game.java index 8819c103..d167ce1f 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/GameState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Game.java @@ -1,9 +1,11 @@ package pp.mdga.client; -public class GameState extends ClientState { +import pp.mdga.client.gameState.GameStateMachine; + +public class Game extends ClientState { private final GameStateMachine gameStateMachine; - public GameState(ClientState parent, ClientGameLogic logic) { + public Game(ClientState parent, ClientGameLogic logic) { super(parent, logic); this.gameStateMachine = new GameStateMachine(parent, logic); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Interrupt.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Interrupt.java index 739a6bd2..bea81fd8 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Interrupt.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Interrupt.java @@ -2,9 +2,9 @@ public class Interrupt extends ClientState { - private final GameState lastState; + private final Game lastState; - public Interrupt(ClientState parent, ClientGameLogic logic, GameState lastState) { + public Interrupt(ClientState parent, ClientGameLogic logic, Game lastState) { super(parent, logic); this.lastState = lastState; } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Lobby.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Lobby.java deleted file mode 100644 index 0f23c854..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Lobby.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class Lobby extends ClientState { - public Lobby(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/MovePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/MovePiece.java deleted file mode 100644 index 13bd9b85..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/MovePiece.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class MovePiece extends ClientState { - public MovePiece(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/NetworkDialog.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/NetworkDialog.java deleted file mode 100644 index 8075ae90..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/NetworkDialog.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class NetworkDialog extends ClientState { - public NetworkDialog(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/NoPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/NoPiece.java deleted file mode 100644 index 42375b01..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/NoPiece.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class NoPiece extends ClientState { - public NoPiece(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/PlayPowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/PlayPowerCard.java deleted file mode 100644 index 4278445f..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/PlayPowerCard.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class PlayPowerCard extends ClientState { - public PlayPowerCard(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/RollDice.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/RollDice.java deleted file mode 100644 index 4af7c7ad..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/RollDice.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class RollDice extends ClientState { - public RollDice(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/RollRankingDice.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/RollRankingDice.java deleted file mode 100644 index f1a27dce..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/RollRankingDice.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class RollRankingDice extends ClientState { - public RollRankingDice(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/SelectPiece.java deleted file mode 100644 index 790e91b2..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/SelectPiece.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class SelectPiece extends ClientState { - public SelectPiece(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Settings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Settings.java index a30942ab..74983f07 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Settings.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Settings.java @@ -1,5 +1,7 @@ package pp.mdga.client; +import pp.mdga.client.settingsState.SettingsStateMachine; + public class Settings extends ClientState { private final SettingsStateMachine settingsStateMachine; diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Shield.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Shield.java deleted file mode 100644 index a3f205ba..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Shield.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class Shield extends ClientState { - public Shield(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Spectator.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Spectator.java deleted file mode 100644 index 293fc2b3..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Spectator.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class Spectator extends ClientState { - public Spectator(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/StartPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/StartPiece.java deleted file mode 100644 index 7e52fd56..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/StartPiece.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class StartPiece extends ClientState { - public StartPiece(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Swap.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Swap.java deleted file mode 100644 index da3ef3c5..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Swap.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class Swap extends ClientState { - public Swap(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/VideoSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/VideoSettings.java deleted file mode 100644 index 0b397e1a..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/VideoSettings.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class VideoSettings extends ClientState { - public VideoSettings(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/WaitRanking.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/WaitRanking.java deleted file mode 100644 index b9db2175..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/WaitRanking.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class WaitRanking extends ClientState { - public WaitRanking(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Waiting.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Waiting.java deleted file mode 100644 index 14a32cdf..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Waiting.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class Waiting extends ClientState { - public Waiting(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/WaitingPiece.java deleted file mode 100644 index 7b12a023..00000000 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/WaitingPiece.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.client; - -public class WaitingPiece extends ClientState { - public WaitingPiece(ClientState parent, ClientGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/CeremonyStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/CeremonyStateMachine.java similarity index 64% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/CeremonyStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/CeremonyStateMachine.java index 758950f8..87d5a76e 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/CeremonyStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/CeremonyStateMachine.java @@ -1,4 +1,8 @@ -package pp.mdga.client; +package pp.mdga.client.ceremonyState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.ClientStateMachine; public class CeremonyStateMachine extends ClientStateMachine { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Podium.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Podium.java similarity index 56% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/Podium.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Podium.java index f962aa68..8adcb0ea 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Podium.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Podium.java @@ -1,4 +1,7 @@ -package pp.mdga.client; +package pp.mdga.client.ceremonyState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; public class Podium extends ClientState { public Podium(ClientState parent, ClientGameLogic logic) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Statistics.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Statistics.java similarity index 57% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/Statistics.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Statistics.java index 8eecb5ce..79f7eb1b 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Statistics.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Statistics.java @@ -1,4 +1,7 @@ -package pp.mdga.client; +package pp.mdga.client.ceremonyState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; public class Statistics extends ClientState { public Statistics(ClientState parent, ClientGameLogic logic) { 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 new file mode 100644 index 00000000..f4c549d2 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/DialogStates.java @@ -0,0 +1,11 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public abstract class DialogStates extends ClientState { + + public DialogStates(ClientState parent, ClientGameLogic logic){ + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogsStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/DialogsStateMachine.java similarity index 64% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/DialogsStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/DialogsStateMachine.java index e1b833ad..62145bfd 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogsStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/DialogsStateMachine.java @@ -1,4 +1,8 @@ -package pp.mdga.client; +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.ClientStateMachine; public class DialogsStateMachine extends ClientStateMachine { public DialogsStateMachine(ClientState parent, ClientGameLogic logic) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/Lobby.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/Lobby.java new file mode 100644 index 00000000..92aac41b --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/Lobby.java @@ -0,0 +1,10 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Lobby extends DialogStates { + public Lobby(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/NetworkDialog.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/NetworkDialog.java new file mode 100644 index 00000000..fada99fc --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/NetworkDialog.java @@ -0,0 +1,10 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class NetworkDialog extends DialogStates { + public NetworkDialog(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/StartDialog.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/StartDialog.java similarity index 58% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/StartDialog.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/StartDialog.java index 90bb1e2b..6147c578 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/StartDialog.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/StartDialog.java @@ -1,4 +1,7 @@ -package pp.mdga.client; +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; public class StartDialog extends DialogStates { public StartDialog(ClientState parent, ClientGameLogic logic) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Animation.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Animation.java new file mode 100644 index 00000000..28f827cc --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Animation.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Animation extends GameStates { + public Animation(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayer.java similarity index 63% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayer.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayer.java index 3a773bc8..007a6ba4 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayer.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayer.java @@ -1,6 +1,10 @@ -package pp.mdga.client; +package pp.mdga.client.gameState; -public class DetermineStartPlayer extends ClientState { +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.determineStartPlayer.DetermineStartPlayerStateMachine; + +public class DetermineStartPlayer extends GameStates { private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine; public DetermineStartPlayer(ClientState parent, ClientGameLogic logic) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/GameStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/GameStateMachine.java similarity index 62% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/GameStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/GameStateMachine.java index 4028c28e..c7043a5f 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/GameStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/GameStateMachine.java @@ -1,4 +1,8 @@ -package pp.mdga.client; +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.ClientStateMachine; public class GameStateMachine extends ClientStateMachine { public GameStateMachine(ClientState parent, ClientGameLogic logic) { 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 new file mode 100644 index 00000000..05d1c404 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/GameStates.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public abstract class GameStates extends ClientState { + public GameStates(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Spectator.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Spectator.java new file mode 100644 index 00000000..f79af4fe --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Spectator.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Spectator extends GameStates { + public Spectator(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/Turn.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Turn.java similarity index 60% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/Turn.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Turn.java index 3bdef5e6..162dce9a 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/Turn.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Turn.java @@ -1,6 +1,10 @@ -package pp.mdga.client; +package pp.mdga.client.gameState; -public class Turn extends ClientState { +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.TurnStateMachine; + +public class Turn extends GameStates { private final TurnStateMachine turnStateMachine; public Turn(ClientState parent, ClientGameLogic logic) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Waiting.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Waiting.java new file mode 100644 index 00000000..1a598100 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Waiting.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Waiting extends GameStates { + public Waiting(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayerStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/DetermineStartPlayerStateMachine.java similarity index 57% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayerStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/DetermineStartPlayerStateMachine.java index 16c192c7..40a85b01 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/DetermineStartPlayerStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/DetermineStartPlayerStateMachine.java @@ -1,6 +1,11 @@ -package pp.mdga.client; +package pp.mdga.client.gameState.determineStartPlayer; -public class DetermineStartPlayerStateMachine extends ClientStateMachine{ +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.ClientStateMachine; +import pp.mdga.client.RollRankingDice; + +public class DetermineStartPlayerStateMachine extends ClientStateMachine { public DetermineStartPlayerStateMachine(ClientState parent, ClientGameLogic logic) { super(parent, logic); } 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 new file mode 100644 index 00000000..d0b7b24f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/DetermineStartPlayerStates.java @@ -0,0 +1,11 @@ +package pp.mdga.client.gameState.determineStartPlayerState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.GameStates; + +public class DetermineStartPlayerStates extends GameStates { + public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/RollRankingDice.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/RollRankingDice.java new file mode 100644 index 00000000..56225b22 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/RollRankingDice.java @@ -0,0 +1,11 @@ +package pp.mdga.client.gameState.determineStartPlayerState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.determineStartPlayer.DetermineStartPlayerStates; + +public class RollRankingDice extends DetermineStartPlayerStates { + public RollRankingDice(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/WaitRanking.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/WaitRanking.java new file mode 100644 index 00000000..29944582 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/WaitRanking.java @@ -0,0 +1,11 @@ +package pp.mdga.client.gameState.determineStartPlayerState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.GameStates; + +public class WaitRanking extends GameStates { + public WaitRanking(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePiece.java similarity index 59% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePiece.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePiece.java index 828b12bd..b78ec9c9 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/ChoosePiece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePiece.java @@ -1,6 +1,10 @@ -package pp.mdga.client; +package pp.mdga.client.gameState.turnState; -public class ChoosePiece extends ClientState { +import pp.mdga.client.gameState.turnState.choosePieceState.ChoosePieceStateMachine; +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class ChoosePiece extends TurnStates { private final ChoosePieceStateMachine choosePieceStateMachine; diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/MovePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/MovePiece.java new file mode 100644 index 00000000..5766a930 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/MovePiece.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class MovePiece extends TurnStates { + public MovePiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PlayPowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PlayPowerCard.java new file mode 100644 index 00000000..70b12fd8 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PlayPowerCard.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class PlayPowerCard extends TurnStates { + public PlayPowerCard(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCard.java similarity index 59% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCard.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCard.java index 42ea2741..dd1f54bf 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCard.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCard.java @@ -1,6 +1,10 @@ -package pp.mdga.client; +package pp.mdga.client.gameState.turnState; -public class PowerCard extends ClientState { +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStateMachine; + +public class PowerCard extends TurnStates { private final PowerCardStateMachine powerCardStateMachine; public PowerCard(ClientState parent, ClientGameLogic logic) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/RollDice.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/RollDice.java new file mode 100644 index 00000000..c09f2580 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/RollDice.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class RollDice extends TurnStates { + public RollDice(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/TurnStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/TurnStateMachine.java similarity index 62% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/TurnStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/TurnStateMachine.java index 60501cd8..e43f4665 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/TurnStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/TurnStateMachine.java @@ -1,4 +1,8 @@ -package pp.mdga.client; +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.ClientStateMachine; public class TurnStateMachine extends ClientStateMachine { public TurnStateMachine(ClientState parent, ClientGameLogic logic) { 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 new file mode 100644 index 00000000..6ca2cd4d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/TurnStates.java @@ -0,0 +1,11 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.GameStates; + +public abstract class TurnStates extends GameStates { + public TurnStates(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/ChoosePieceStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/ChoosePieceStateMachine.java new file mode 100644 index 00000000..b50bc0cc --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/ChoosePieceStateMachine.java @@ -0,0 +1,16 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.ClientStateMachine; + +public class ChoosePieceStateMachine extends ClientStateMachine { + public ChoosePieceStateMachine(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public NoPiece initialState() { + return new NoPiece(this, 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 new file mode 100644 index 00000000..231b2d37 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/ChoosePieceStates.java @@ -0,0 +1,11 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.TurnStates; + +public abstract class ChoosePieceStates extends TurnStates { + public ChoosePieceStates(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/NoPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/NoPiece.java new file mode 100644 index 00000000..c538abaa --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/NoPiece.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class NoPiece extends ChoosePieceStates { + public NoPiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/SelectPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/SelectPiece.java new file mode 100644 index 00000000..6118d2cd --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/SelectPiece.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class SelectPiece extends ChoosePieceStates { + public SelectPiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/StartPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/StartPiece.java new file mode 100644 index 00000000..8cce510a --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/StartPiece.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class StartPiece extends ChoosePieceStates { + public StartPiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/WaitingPiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/WaitingPiece.java new file mode 100644 index 00000000..d8aed13c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/WaitingPiece.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class WaitingPiece extends ChoosePieceStates { + public WaitingPiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ChoosePowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ChoosePowerCard.java new file mode 100644 index 00000000..babcf7bf --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ChoosePowerCard.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState.powerCardState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class ChoosePowerCard extends PowerCardStates { + public ChoosePowerCard(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCardStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/PowerCardStateMachine.java similarity index 62% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCardStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/PowerCardStateMachine.java index 037417bc..912ffead 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/PowerCardStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/PowerCardStateMachine.java @@ -1,4 +1,8 @@ -package pp.mdga.client; +package pp.mdga.client.gameState.turnState.powerCardState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.ClientStateMachine; public class PowerCardStateMachine extends ClientStateMachine { public PowerCardStateMachine(ClientState parent, ClientGameLogic logic) { 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 new file mode 100644 index 00000000..753e5aa8 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/PowerCardStates.java @@ -0,0 +1,11 @@ +package pp.mdga.client.gameState.turnState.powerCardState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.TurnStates; + +public abstract class PowerCardStates extends TurnStates { + public PowerCardStates(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Shield.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Shield.java new file mode 100644 index 00000000..f66b1be9 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Shield.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState.powerCardState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Shield extends PowerCardStates { + public Shield(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Swap.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Swap.java new file mode 100644 index 00000000..0704a028 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Swap.java @@ -0,0 +1,10 @@ +package pp.mdga.client.gameState.turnState.powerCardState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Swap extends PowerCardStates { + public Swap(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/AudioSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/AudioSettings.java new file mode 100644 index 00000000..af494e93 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/AudioSettings.java @@ -0,0 +1,10 @@ +package pp.mdga.client.settingsState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class AudioSettings extends SettingStates { + public AudioSettings(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/MainSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/MainSettings.java similarity index 57% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/MainSettings.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/MainSettings.java index e8af6b05..95050b8a 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/MainSettings.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/MainSettings.java @@ -1,4 +1,7 @@ -package pp.mdga.client; +package pp.mdga.client.settingsState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; public class MainSettings extends ClientState { public MainSettings(ClientState parent, ClientGameLogic logic) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/SettingStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/SettingStates.java new file mode 100644 index 00000000..2b9fb2ff --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/SettingStates.java @@ -0,0 +1,10 @@ +package pp.mdga.client.settingsState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public abstract class SettingStates extends ClientState { + public SettingStates(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/SettingsStateMachine.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/SettingsStateMachine.java similarity index 62% rename from Projekte/mdga/model/src/main/java/pp/mdga/client/SettingsStateMachine.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/SettingsStateMachine.java index 0abb565e..750375b4 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/SettingsStateMachine.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/SettingsStateMachine.java @@ -1,4 +1,8 @@ -package pp.mdga.client; +package pp.mdga.client.settingsState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.ClientStateMachine; public class SettingsStateMachine extends ClientStateMachine { public SettingsStateMachine(ClientState parent, ClientGameLogic logic) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/VideoSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/VideoSettings.java new file mode 100644 index 00000000..ebe24638 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/VideoSettings.java @@ -0,0 +1,10 @@ +package pp.mdga.client.settingsState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class VideoSettings extends SettingStates { + public VideoSettings(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index d48890a0..e09b5533 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -4,10 +4,28 @@ import org.junit.Test; import pp.mdga.client.*; import pp.mdga.client.Ceremony; -import pp.mdga.client.StartPiece; +import pp.mdga.client.ceremonyState.CeremonyStateMachine; +import pp.mdga.client.ceremonyState.Podium; +import pp.mdga.client.ceremonyState.Statistics; +import pp.mdga.client.dialogState.DialogsStateMachine; +import pp.mdga.client.dialogState.Lobby; +import pp.mdga.client.dialogState.NetworkDialog; +import pp.mdga.client.dialogState.StartDialog; +import pp.mdga.client.gameState.*; +import pp.mdga.client.gameState.turnState.choosePieceState.*; +import pp.mdga.client.gameState.determineStartPlayer.DetermineStartPlayerStateMachine; +import pp.mdga.client.gameState.turnState.*; +import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCard; +import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStateMachine; +import pp.mdga.client.gameState.turnState.powerCardState.Shield; +import pp.mdga.client.gameState.turnState.powerCardState.Swap; +import pp.mdga.client.Settings; +import pp.mdga.client.settingsState.AudioSettings; +import pp.mdga.client.settingsState.MainSettings; +import pp.mdga.client.settingsState.SettingsStateMachine; +import pp.mdga.client.settingsState.VideoSettings; import pp.mdga.game.BonusCard; import pp.mdga.game.Color; -import pp.mdga.game.Game; import pp.mdga.message.client.ClientMessage; import java.util.ArrayList; @@ -35,7 +53,7 @@ public class ClientStateTest { private DetermineStartPlayerStateMachine determineStartPlayerStateMachine; private Dialogs dialogs; private DialogsStateMachine dialogsStateMachine; - private GameState gameState; + private Game gameState; private GameStateMachine gameStateMachine; private Interrupt interrupt; private Lobby lobby; @@ -104,12 +122,12 @@ public class ClientStateTest { private BonusCard shieldCard; private BonusCard turboCard; - private Game game; + private pp.mdga.game.Game game; @Before public void setUp() { //initialize the game - game = new Game(); + game = new pp.mdga.game.Game(); //initialize the playerID from=1234; @@ -179,7 +197,7 @@ public void send(ClientMessage msg) { //initialize the states dialogs = new Dialogs(clientAutomaton,clientGameLogic); - gameState = new GameState(clientAutomaton,clientGameLogic); + gameState = new Game(clientAutomaton,clientGameLogic); ceremony = new Ceremony(clientAutomaton,clientGameLogic); interrupt = new Interrupt(clientAutomaton,clientGameLogic,gameState); @@ -243,10 +261,10 @@ public void testDialogsToGame() { clientGameLogic.receive(startGame); //tests if the client is in the gameState after receiving the message - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //tests if the new State of the GameStateMachine is in DetermineStartPlayer - GameState gameState1 = (GameState) clientAutomaton.getState(); + Game gameState1 = (Game) clientAutomaton.getState(); GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); @@ -272,7 +290,7 @@ public void testDialogsToClientStateEndState() { public void testClientGameToCeremony() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the Ceremony-Message to the client clientGameLogic.receive(ceremonyMessage); @@ -295,7 +313,7 @@ public void testClientGameSubStatesToInterrupt() { clientAutomaton.gotoState(gameState); //tests if the client is in GameState - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the Ceremony-Message to the client clientGameLogic.receive(interrupt); @@ -338,7 +356,7 @@ public void testClientInterruptToGame() { //Todo sends the continue-message //tests if the client is in the game - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); } /** @@ -562,10 +580,10 @@ public void testLobbyToRollRankingDice() { clientGameLogic.receive();//TODO message //tests if the clientStateMachine is in the GameState - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //tests if the clientStateMachine is in the DetermineStartPlayer - GameState gameState1 = (GameState) clientAutomaton.getState(); + Game gameState1 = (Game) clientAutomaton.getState(); GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); @@ -590,7 +608,7 @@ public void testDetermineStartPlayerToWait() { public void testWaitToAnimation() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the client in WaitState gameStateMachine.gotoState(waiting); @@ -598,7 +616,7 @@ public void testWaitToAnimation() { //tests if a piece is moved,that the client goes into Animation clientGameLogic.receive(moveMessage); //Todo ??? richtige message - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Animation); //sends the client in WaitState @@ -607,7 +625,7 @@ public void testWaitToAnimation() { //tests if a powerCard is played,that the client goes into Animation clientGameLogic.receive(playCardTurbo); //Todo ??? richtige message - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Animation); //sends the client in WaitState @@ -616,7 +634,7 @@ public void testWaitToAnimation() { //tests if a die is rolled,that the client goes into Animation clientGameLogic.receive(dice); //Todo ??? richtige message - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Animation); } @@ -627,7 +645,7 @@ public void testWaitToAnimation() { public void testWaitToTurn() { //sends client in gameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Waiting gameStateMachine.gotoState(waiting); @@ -637,7 +655,7 @@ public void testWaitToTurn() { clientGameLogic.receive(activePlayer); //tests if the client is in GameState - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //tests if Client is in Turn assertTrue(gameStateMachine.getState() instanceof Turn); @@ -714,7 +732,7 @@ public void testPowerCardSubStatesToRollDice() { public void testStayInPlayPowerCard() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -727,7 +745,7 @@ public void testStayInPlayPowerCard() { //Todo send messages to test to stay in playPowerCard //tests if the client is in PlayPowerCard - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } @@ -739,7 +757,7 @@ public void testStayInPlayPowerCard() { public void testPlayPowerCardToRollDice() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -753,7 +771,7 @@ public void testPlayPowerCardToRollDice() { //Todo test other messages, that there is no state change //tests if the client is in RollDice - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof RollDice); } @@ -839,7 +857,7 @@ public void testChoosePowerCardToRollDice() { //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -856,7 +874,7 @@ public void testChoosePowerCardToRollDice() { //todo send the messages, to force a state change to rollDice //tests if the turnStateMachine is in RollDice - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof RollDice); } @@ -868,7 +886,7 @@ public void testChoosePowerCardToRollDice() { public void testChoosePowerCardToSwap() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -885,7 +903,7 @@ public void testChoosePowerCardToSwap() { //todo send the messages, to force a state change to swap //tests if the client is in Swap - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(powerCardStateMachine.getState() instanceof Swap); @@ -898,7 +916,7 @@ public void testChoosePowerCardToSwap() { public void testChoosePowerCardToShield() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -915,7 +933,7 @@ public void testChoosePowerCardToShield() { //todo send the messages, to force a state change to shield //tests if the client is in Shield - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(powerCardStateMachine.getState() instanceof Shield); @@ -928,7 +946,7 @@ public void testChoosePowerCardToShield() { public void testStayInShield() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -945,7 +963,7 @@ public void testStayInShield() { //todo send the messages, which dont force a statechange //tests if the client is in PlayPowerCard - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof PowerCard); assertTrue(powerCardStateMachine.getState() instanceof PlayPowerCard); @@ -958,7 +976,7 @@ public void testStayInShield() { public void testShieldToPowerCardEndState() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -976,7 +994,7 @@ public void testShieldToPowerCardEndState() { //todo send the message to force the statechange //tests if the client is in PlayPowerCard - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } @@ -988,7 +1006,7 @@ public void testShieldToPowerCardEndState() { public void testSwapToPowerCardEndState() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1005,7 +1023,7 @@ public void testSwapToPowerCardEndState() { //todo send the message to force the statechange //tests if the client is in PlayPowerCard - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } @@ -1017,7 +1035,7 @@ public void testSwapToPowerCardEndState() { public void testNoPieceInWaitingPiece() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1036,7 +1054,7 @@ public void testNoPieceInWaitingPiece() { //sends to the clientGameLogic the message WaitPiece clientGameLogic.receive(waitPiece); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); @@ -1049,7 +1067,7 @@ public void testNoPieceInWaitingPiece() { public void testNoPieceInSelectedPiece() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1068,7 +1086,7 @@ public void testNoPieceInSelectedPiece() { //sends to the clientGameLogic the message SelectPiece clientGameLogic.receive(selectPiece); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); @@ -1081,7 +1099,7 @@ public void testNoPieceInSelectedPiece() { public void testNoPieceInStartPiece() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1100,7 +1118,7 @@ public void testNoPieceInStartPiece() { //sends to the clientGameLogic the message StartPiece clientGameLogic.receive(startPiece); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); @@ -1113,7 +1131,7 @@ public void testNoPieceInStartPiece() { public void testNoPieceInWait() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1132,7 +1150,7 @@ public void testNoPieceInWait() { //sends to the clientGameLogic the message NoTurn clientGameLogic.receive(noTurn); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof Waiting); } @@ -1144,7 +1162,7 @@ public void testNoPieceInWait() { public void testStayInWaitingPiece() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1160,7 +1178,7 @@ public void testStayInWaitingPiece() { //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); @@ -1173,7 +1191,7 @@ public void testStayInWaitingPiece() { public void testWaitingPieceInChoosePieceEndState() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1189,7 +1207,7 @@ public void testWaitingPieceInChoosePieceEndState() { //Todo send the message to the clientGameLogic to force a state change - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof MovePiece); } @@ -1201,7 +1219,7 @@ public void testWaitingPieceInChoosePieceEndState() { public void testStayInSelectedPiece() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1217,7 +1235,7 @@ public void testStayInSelectedPiece() { //Todo send all server messages which dont force a state change here - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); @@ -1230,7 +1248,7 @@ public void testStayInSelectedPiece() { public void testSelectedPieceInChoosePieceEndState() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1246,7 +1264,7 @@ public void testSelectedPieceInChoosePieceEndState() { //Todo send the message which force a state change - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof MovePiece); } @@ -1258,7 +1276,7 @@ public void testSelectedPieceInChoosePieceEndState() { public void testStayInStartPiece() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1274,7 +1292,7 @@ public void testStayInStartPiece() { //todo send all messages which dont force a state change - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); @@ -1287,7 +1305,7 @@ public void testStayInStartPiece() { public void testStartPieceToChoosePieceEndState() { //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); //sends the gameStateMachine in the Turn gameStateMachine.gotoState(turn); @@ -1303,7 +1321,7 @@ public void testStartPieceToChoosePieceEndState() { //Todo send the message which force a state change - assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(clientAutomaton.getState() instanceof Game); assertTrue(gameStateMachine.getState() instanceof Turn); assertTrue(turnStateMachine.getState() instanceof MovePiece); }