diff --git a/Projekte/.run/MdgaApp.run.xml b/Projekte/.run/MdgaApp.run.xml deleted file mode 100644 index 82e2f2b6..00000000 --- a/Projekte/.run/MdgaApp.run.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - \ No newline at end of file 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 60684f0f..1a20e865 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 new file mode 100644 index 00000000..612d0534 --- /dev/null +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java @@ -0,0 +1,235 @@ +package pp.mdga.client.server; + +import com.jme3.network.*; +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; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; +import java.util.Map; +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(this, new Game()); + } + + 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(StartGame.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(RequestDie.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(Die.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, StartGame.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, RequestDie.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); + } + + + public void messageReceived(HostedConnection source, ClientMessage message) { + LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS + pendingMessages.add(new ReceivedMessage(message, source.getId())); + } + + @Override + public void connectionAdded(Server server, HostedConnection hostedConnection) { + LOGGER.log(Level.INFO, "new connection {0}", hostedConnection); //NON-NLS + // ToDo: Synchronize data between server and client. + logic.getGame().addPlayer(hostedConnection.getId(), new Player()); + } + + @Override + public void connectionRemoved(Server server, HostedConnection hostedConnection) { + LOGGER.log(Level.INFO, "connection closed: {0}", hostedConnection); //NON-NLS + final Player player = logic.getGame().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); + this.handleDisconnect(hostedConnection.getId()); + } + } + + /** + * This method will be used to handle unintentional disconnections from players. + * + * @param id as the id of the disconnected player. + */ + public void handleDisconnect(int id) { + this.logic.received(new Disconnected(), id); + } + + public 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 + } + + /** + * This method will be used to send the given message parameter to all connected players which are saved inside the + * players attribute of Game class. + * + * @param message as the message which will be sent to all players as a ServerMessage. + */ + public void broadcast(ServerMessage message) { + for (Map.Entry entry: this.logic.getGame().getPlayers().entrySet()) { + this.send(entry.getKey(), message); + } + } + + //TODO: + @Override + public void messageReceived(HostedConnection source, Message m) { + + } +} 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/client/src/main/java/pp/mdga/client/view/GameView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java index 37cfeaf7..76db7612 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 @@ -20,11 +20,6 @@ import pp.mdga.client.button.ButtonRight; import pp.mdga.client.button.SettingsButton; 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/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 73f8f285..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Animation.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Animation extends ClientState { -} 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 b1eaade6..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/AudioSettings.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class AudioSettings extends ClientState { -} 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 deleted file mode 100644 index 7be5866a..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Ceremony.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.client; - -public class Ceremony extends ClientState { - private final CeremonyStateMachine ceremonyStateMachine = new 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 deleted file mode 100644 index 0449027d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/CeremonyStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class CeremonyStateMachine extends ClientStateMachine { -} 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 deleted file mode 100644 index 0b9fd192..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePiece.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.client; - -public class ChoosePiece extends ClientState { - private final ChoosePieceStateMachine choosePieceStateMachine = new 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 deleted file mode 100644 index 45c965b6..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePieceStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class ChoosePieceStateMachine extends ClientStateMachine{ -} 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 72a8d3d4..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ChoosePowerCard.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class ChoosePowerCard extends ClientState { -} 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 deleted file mode 100644 index f5261224..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientAutomaton.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class ClientAutomaton extends ClientStateMachine { -} 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 deleted file mode 100644 index 6483e582..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientGameLogic.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class ClientGameLogic { -} 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 deleted file mode 100644 index 9e7c3786..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientState.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public abstract class ClientState { -} 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 deleted file mode 100644 index 0c8717e9..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/ClientStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public abstract class ClientStateMachine extends ClientState { -} 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 deleted file mode 100644 index b12b6a6d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayer.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.client; - -public class DetermineStartPlayer extends ClientState { - private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine = new 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 deleted file mode 100644 index f8a2aeda..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DetermineStartPlayerStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class DetermineStartPlayerStateMachine extends ClientStateMachine{ -} 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 deleted file mode 100644 index 6b144ca8..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Dialogs.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.client; - -public class Dialogs extends ClientState { - private final DialogsStateMachine dialogsStateMachine = new DialogsStateMachine(); -} 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 deleted file mode 100644 index a1097aab..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/DialogsStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class DialogsStateMachine extends ClientStateMachine { -} 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 deleted file mode 100644 index f4ac25fc..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameState.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.client; - -public class GameState extends ClientState { - private final GameStateMachine gameStateMachine = new 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 deleted file mode 100644 index 9686b7e6..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/GameStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class GameStateMachine extends ClientStateMachine { -} 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 deleted file mode 100644 index 287363cc..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Interrupt.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Interrupt extends ClientState { -} 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 a2f0f1c0..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Lobby.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Lobby extends ClientState { -} 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 deleted file mode 100644 index 67e641bd..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/MainSettings.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class MainSettings extends ClientState { -} 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 e8c4c60b..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/MovePiece.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class MovePiece extends ClientState { -} 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 846a5a02..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/NetworkDialog.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class NetworkDialog extends ClientState { -} 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 a52655b3..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/NoPiece.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class NoPiece extends ClientState { -} 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 1d79e516..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PlayPowerCard.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class PlayPowerCard extends ClientState { -} 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 deleted file mode 100644 index 8819183e..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Podium.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Podium extends ClientState { -} 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 deleted file mode 100644 index 2ad3c2d1..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCard.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.client; - -public class PowerCard extends ClientState { - private final PowerCardStateMachine powerCardStateMachine = new 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 deleted file mode 100644 index 0bb5c60c..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/PowerCardStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class PowerCardStateMachine extends ClientStateMachine { -} 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 f1056203..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollDice.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class RollDice extends ClientState { -} 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 45871c8d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/RollRankingDice.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class RollRankingDice extends ClientState { -} 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 083ba28f..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/SelectPiece.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class SelectPiece extends ClientState { -} 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 deleted file mode 100644 index 2c118580..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Settings.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.client; - -public class Settings extends ClientState { - private final SettingsStateMachine settingsStateMachine = new 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 deleted file mode 100644 index e45870dd..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/SettingsStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class SettingsStateMachine extends ClientStateMachine { -} 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 eaaa67cc..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Shield.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Shield extends ClientState { -} 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 50fc01f7..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Spectator.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Spectator extends ClientState { -} 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 deleted file mode 100644 index d258c93c..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartDialog.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class StartDialog extends ClientState { -} 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 1330df6c..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/StartPiece.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class StartPiece extends ClientState { -} 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 deleted file mode 100644 index e46a5e1d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Statistics.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Statistics extends ClientState { -} 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 60a9d28e..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Swap.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Swap extends ClientState { -} 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 deleted file mode 100644 index db60e158..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Turn.java +++ /dev/null @@ -1,5 +0,0 @@ -package pp.mdga.client; - -public class Turn extends ClientState { - private final TurnStateMachine turnStateMachine = new 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 deleted file mode 100644 index 892cf3e6..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/TurnStateMachine.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class TurnStateMachine extends ClientStateMachine { -} 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 32d13929..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/VideoSettings.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class VideoSettings extends ClientState { -} 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 5614da6a..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitRanking.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class WaitRanking extends ClientState { -} 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 4f0d719b..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/Waiting.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class Waiting extends ClientState { -} 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 d07fe63e..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/client/WaitingPiece.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client; - -public class WaitingPiece extends ClientState { -} 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 deleted file mode 100644 index 99b42856..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Color.java +++ /dev/null @@ -1,9 +0,0 @@ -package pp.mdga.game; - -public enum Color { - ARMY, - NAVY, - CYBER, - AIRFORCE - -} 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 deleted file mode 100644 index b564a96b..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/AnimationEnd.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class AnimationEnd extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 0b7ec4d5..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientInterpreter.java +++ /dev/null @@ -1,37 +0,0 @@ -package pp.mdga.message.client; - -public interface ClientInterpreter { - void received(AnimationEnd animationEnd, int from); - - void received(DeselectTSK deselectTSK , int from); - - void received(ForceStartGame forceStartGame, int from); - - void received(JoinServer joinServer , int from); - - void received(LeaveGame leaveGame , int from); - - void received(LobbyNotReady lobbyNotReady , int from); - - void received(LobbyReady lobbyReady , int from); - - void received(RequestBriefing requestBriefing , int from); - - void received(RequestDice requestDice , int from); - - void received(RequestMove requestMove , int from); - - void received(RequestPlayCard requestPlayCard , int from); - - void received(SelectCard selectCard , int from); - - void received(SelectTSK selectTSK , int from); - - void received(ForceContinueGame forceContinueGame, int from); - - void received(ClientStartGame clientStartGame, int from); - - void received(NoPowerCard noPowerCard, int from); - - void received(SelectedPieces selectedPieces, 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 deleted file mode 100644 index 9ae2d921..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientMessage.java +++ /dev/null @@ -1,11 +0,0 @@ -package pp.mdga.message.client; - -import com.jme3.network.AbstractMessage; - -public abstract class ClientMessage extends AbstractMessage { - protected ClientMessage() { - super(true); - } - - 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 deleted file mode 100644 index 86a69f73..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ClientStartGame.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class ClientStartGame extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 21e0d39d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/DeselectTSK.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class DeselectTSK extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 1dd6e603..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceContinueGame.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class ForceContinueGame extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 32bf769c..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/ForceStartGame.java +++ /dev/null @@ -1,17 +0,0 @@ -package pp.mdga.message.client; - -public class ForceStartGame extends ClientMessage { - public ForceStartGame() { - - } - - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 9971ab68..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/JoinServer.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class JoinServer extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 2da13e64..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LeaveGame.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class LeaveGame extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 8709c648..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyNotReady.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class LobbyNotReady extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 838111ba..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/LobbyReady.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class LobbyReady extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 3fa227de..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/NoPowerCard.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class NoPowerCard extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index d1c12ff8..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestBriefing.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class RequestBriefing extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 298866d1..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestDice.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.client; - -public class RequestDice extends ClientMessage { - @Override - public String toString() { - return "null"; - } - - @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 deleted file mode 100644 index 48fd187d..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestMove.java +++ /dev/null @@ -1,32 +0,0 @@ -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 pieceIdentifier; - } - - @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 deleted file mode 100644 index 67885e0f..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/RequestPlayCard.java +++ /dev/null @@ -1,32 +0,0 @@ -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 card.toString(); - } - - @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 deleted file mode 100644 index 44957a6c..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectCard.java +++ /dev/null @@ -1,26 +0,0 @@ -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"; - } - - @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 deleted file mode 100644 index 02a5c4cf..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectTSK.java +++ /dev/null @@ -1,26 +0,0 @@ -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"; - } - - @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 deleted file mode 100644 index 50290e19..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/client/SelectedPieces.java +++ /dev/null @@ -1,32 +0,0 @@ -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"; - } - - @Override - public void accept(ClientInterpreter interpreter, int from) { - interpreter.received(this, from); - } -} 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 e7c35daa..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ActivePlayer.java +++ /dev/null @@ -1,32 +0,0 @@ -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) { - - } - - @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 42e3cec6..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/AnyPiece.java +++ /dev/null @@ -1,38 +0,0 @@ -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) { - - } - - @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 db89d408..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Briefing.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class Briefing 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/Ceremony.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java deleted file mode 100644 index 8a13db46..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Ceremony.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class Ceremony 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/Dice.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java deleted file mode 100644 index 7330505f..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/Dice.java +++ /dev/null @@ -1,59 +0,0 @@ -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) { - - } - - @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 ee1798ee..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceAgain.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class DiceAgain 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/DiceNow.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java deleted file mode 100644 index 3a87ca60..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/DiceNow.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class DiceNow 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/EndOfTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java deleted file mode 100644 index 62c33df2..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/EndOfTurn.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class EndOfTurn 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/LobbyAccept.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java deleted file mode 100644 index 324c69e5..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyAccept.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class LobbyAccept 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/LobbyDeny.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java deleted file mode 100644 index 0cbd29f0..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyDeny.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class LobbyDeny 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/LobbyPlayerJoin.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java deleted file mode 100644 index 5d686153..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerJoin.java +++ /dev/null @@ -1,24 +0,0 @@ -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) { - - } - - @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 4f4ab6a3..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/LobbyPlayerLeave.java +++ /dev/null @@ -1,31 +0,0 @@ -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) { - - } - - @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 4a7a3a39..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/MoveMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -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) { - - } - - @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 c1b1f436..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/NoTurn.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class NoTurn 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/PauseGame.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java deleted file mode 100644 index d9416c30..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PauseGame.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class PauseGame 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/PlayCard.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java deleted file mode 100644 index 4b5f61ae..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PlayCard.java +++ /dev/null @@ -1,41 +0,0 @@ -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) { - - } - - @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 d543b3c6..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossibleCard.java +++ /dev/null @@ -1,40 +0,0 @@ -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) { - - } - - @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 d85b9453..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/PossiblePiece.java +++ /dev/null @@ -1,47 +0,0 @@ -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) { - - } - - @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/RankingRollAgain.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java deleted file mode 100644 index a1c200f9..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/RankingRollAgain.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class RankingRollAgain 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/ReconnectBriefing.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java deleted file mode 100644 index 7910e2c2..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ReconnectBriefing.java +++ /dev/null @@ -1,25 +0,0 @@ -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) { - - } - - @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 764dbb52..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ResumeGame.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class ResumeGame 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/ServerInterpreter.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java deleted file mode 100644 index d8f068cc..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerInterpreter.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.message.server; - -public interface ServerInterpreter { -} 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 b97aec1a..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerMessage.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -import com.jme3.network.AbstractMessage; - -public abstract class ServerMessage extends AbstractMessage { - protected ServerMessage() { - super(true); - } - - public abstract void accept(ServerInterpreter interpreter); - - 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 5a684bb8..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/ServerStartGame.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class ServerStartGame 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/StartPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java deleted file mode 100644 index 902c467b..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/StartPiece.java +++ /dev/null @@ -1,24 +0,0 @@ -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) { - - } - - @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 c7ad2593..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateReady.java +++ /dev/null @@ -1,31 +0,0 @@ -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) { - - } - - @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 c3d8e7fa..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/UpdateTSK.java +++ /dev/null @@ -1,31 +0,0 @@ -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) { - - } - - @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 41cd1151..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/message/server/WaitPiece.java +++ /dev/null @@ -1,13 +0,0 @@ -package pp.mdga.message.server; - -public class WaitPiece extends ServerMessage { - @Override - public void accept(ServerInterpreter interpreter) { - - } - - @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 b9910dbc..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/DetermineStartPlayer.java +++ /dev/null @@ -1,44 +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; - -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) { -// logic.send(); - -// broadcastUpdate(new Dice()); - } - - @Override - public void update() { - 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 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 dab977c8..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.RankingResponce; - -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(RankingResponce 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/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/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 2dbb77f5..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/ServerGameLogic.java +++ /dev/null @@ -1,131 +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; - } - - 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 90c08897..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.RankingResponce; -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(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 */ } - - /** - * 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 a55c0ef0..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.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; - - /** - * 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 RankingResponce message is sent. - * - * @param msg the RankingResponce message - */ - @Override - 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 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 aeb05091..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Turn.java +++ /dev/null @@ -1,36 +0,0 @@ -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); - - 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 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/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()); -// } - } -} 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 new file mode 100644 index 00000000..2832f0fa --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Ceremony.java @@ -0,0 +1,19 @@ +package pp.mdga.client; + +public class Ceremony extends ClientState { + + + public Ceremony(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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 new file mode 100644 index 00000000..8e2a4a78 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientGameLogic.java @@ -0,0 +1,250 @@ +package pp.mdga.client; + +import pp.mdga.game.BonusCard; +import pp.mdga.game.Color; +import pp.mdga.game.Game; +import pp.mdga.game.Piece; +import pp.mdga.message.client.ClientMessage; +import pp.mdga.message.server.*; + +import java.util.Map; +import java.util.UUID; + +public class ClientGameLogic implements ServerInterpreter { + static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName()); + + private Game game; + private final ClientSender clientSender; + private ClientState state; + private Map pieces; + private Map cards; + + private Dialogs dialogs = new Dialogs(null, this); + private GameState gameState = new GameState(null, this); + private Ceremony ceremony = new Ceremony(null, this); + private Interrupt interrupt = new Interrupt(null, this); + + public ClientGameLogic(Game game, ClientSender clientSender) { + this.game = game; + this.clientSender = clientSender; + state = dialogs; + } + + 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; + } + + @Override + public void received(ActivePlayer msg) { + state.received(msg); + } + + @Override + public void received(AnyPiece msg) { + state.received(msg); + } + + @Override + public void received(Briefing msg) { + state.received(msg); + } + + @Override + public void received(CeremonyMessage msg) { + state.received(msg); + } + + @Override + public void received(Die msg) { + state.received(msg); + } + + @Override + public void received(DiceAgain msg) { + state.received(msg); + } + + @Override + public void received(DiceNow msg) { + state.received(msg); + } + + @Override + public void received(EndOfTurn msg) { + state.received(msg); + } + + @Override + public void received(LobbyAccept msg) { + state.received(msg); + } + + @Override + public void received(LobbyDeny msg) { + state.received(msg); + } + + @Override + public void received(LobbyPlayerJoin msg) { + state.received(msg); + } + + @Override + public void received(LobbyPlayerLeave msg) { + state.received(msg); + } + + @Override + public void received(MoveMessage msg) { + state.received(msg); + } + + @Override + public void received(NoTurn msg) { + state.received(msg); + } + + @Override + public void received(PauseGame msg) { + state.received(msg); + } + + @Override + public void received(PlayCard msg) { + state.received(msg); + } + + @Override + public void received(PossibleCard msg) { + state.received(msg); + } + + @Override + public void received(PossiblePiece msg) { + state.received(msg); + } + + @Override + public void received(RankingResponse msg) { + state.received(msg); + } + + @Override + public void received(RankingRollAgain msg) { + state.received(msg); + } + + @Override + public void received(ReconnectBriefing msg) { + state.received(msg); + } + + @Override + public void received(ResumeGame msg) { + state.received(msg); + } + + @Override + public void received(ServerStartGame msg) { + state.received(msg); + } + + @Override + public void received(StartPiece msg) { + state.received(msg); + } + + @Override + public void received(UpdateReady msg) { + state.received(msg); + } + + @Override + public void received(UpdateTSK msg) { + state.received(msg); + } + + @Override + public void received(WaitPiece msg) { + state.received(msg); + } + + @Override + public void received(Spectator msg) { + state.received(msg); + } + + public void selectPiece(UUID pieceId){ + state.selectPiece(pieceId); + } + + public void selectCard(UUID cardId){ + state.selectCard(cardId); + } + + public void selectTsk(Color color){ + state.selectTSK(color); + } + + public void selectDice(){ + state.selectDice(); + } + + public void selectName(String name){ + state.setName(name); + } + + public void selectReady(boolean ready){ + state.selectReady(); + } + + public void selectHost(){ + state.selectHost(); + } + + public void selectLeave(){ + state.selectLeave(); + } + + public void selectJoin(){ + state.selectJoin(); + } + + public void selectStart(){ + state.selectStart(); + } + + public void setState(ClientState state){ + this.state.exit(); + this.state = state; + } + + public GameState getGameState(){ + return gameState; + } + + public Ceremony getCeremony(){ + return ceremony; + } + + public Interrupt getInterrupt(){ + return interrupt; + } + + public Dialogs getDialogs(){ + return dialogs; + } +} 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 new file mode 100644 index 00000000..5a89118c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientState.java @@ -0,0 +1,223 @@ +package pp.mdga.client; + +import pp.mdga.game.Color; +import pp.mdga.message.server.*; + +import java.lang.System.Logger.Level; +import java.util.UUID; + +public abstract class ClientState implements Observer, ServerInterpreter { + 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 abstract void enter(); + + public abstract void exit(); + + public ClientState getParent(){ + return parent; + } + + public void update() {/* do nothing */} + + @Override + public String toString(){ + return getClass().getSimpleName(); + } + + @Override + public void received(ActivePlayer msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(AnyPiece msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(Briefing msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(CeremonyMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(Die msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(DiceAgain msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(DiceNow msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(EndOfTurn msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(LobbyAccept msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(LobbyDeny msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(LobbyPlayerJoin msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(LobbyPlayerLeave msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(MoveMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(NoTurn msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(PauseGame msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(PlayCard msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(PossibleCard msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(PossiblePiece msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(RankingResponse msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(RankingRollAgain msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(ReconnectBriefing msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(ResumeGame msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(ServerStartGame msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(StartPiece msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(UpdateReady msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(UpdateTSK msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(Spectator msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(WaitPiece msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + public void selectPiece(UUID id) { + LOGGER.log(Level.DEBUG, "Selecting piece not allowed."); + } + + public void selectCard(UUID id) { + LOGGER.log(Level.DEBUG, "Selecting card not allowed."); + } + + public void selectTSK(Color color) { + LOGGER.log(Level.DEBUG, "Selecting TSK not allowed."); + } + + public void selectDice() { + LOGGER.log(Level.DEBUG, "Selecting dice not allowed."); + } + + public void setName(String name) { + LOGGER.log(Level.DEBUG, "Setting name not allowed."); + } + + public void selectReady() { + LOGGER.log(Level.DEBUG, "Selecting ready not allowed."); + } + + public void selectHost() { + LOGGER.log(Level.DEBUG, "Selecting host not allowed."); + } + + public void selectJoin() { + LOGGER.log(Level.DEBUG, "Selecting join not allowed."); + } + + public void selectLeave() { + LOGGER.log(Level.DEBUG, "Selecting leave not allowed."); + } + + public void deselectTSK(Color color) { + LOGGER.log(Level.DEBUG, "Deselecting TSK not allowed."); + } + + public void selectUnready(){ + LOGGER.log(Level.DEBUG, "Selecting unready not allowed."); + } + + public void selectStart(){ + LOGGER.log(Level.DEBUG, "Starting not allowed"); + } +} 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 new file mode 100644 index 00000000..54288e29 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Dialogs.java @@ -0,0 +1,53 @@ +package pp.mdga.client; + +import pp.mdga.client.dialogState.DialogStates; +import pp.mdga.client.dialogState.Lobby; +import pp.mdga.client.dialogState.NetworkDialog; +import pp.mdga.client.dialogState.StartDialog; + +public class Dialogs extends ClientState { + + private DialogStates currentState; + + private final Lobby lobby = new Lobby(this, logic); + private final NetworkDialog networkDialog = new NetworkDialog(this, logic); + private final StartDialog startDialog = new StartDialog(this, logic); + + + public Dialogs(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void exit(){ + currentState.exit(); + } + + @Override + public void enter(){ + currentState = startDialog; + } + + public void setState(DialogStates newState){ + currentState.exit(); + currentState = newState; + currentState.enter(); + } + + public Lobby getLobby() { + return lobby; + } + + public NetworkDialog getNetworkDialog() { + return networkDialog; + } + + public StartDialog getStartDialog() { + return startDialog; + } + + public void startGame(){ + exit(); + logic.setState(logic.getGameState()); + } +} 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 new file mode 100644 index 00000000..b7b9a8cf --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/GameState.java @@ -0,0 +1,29 @@ +package pp.mdga.client; + +import pp.mdga.client.gameState.*; + +public class GameState extends ClientState { + + private GameStates state; + + private Animation animation = new Animation(this, logic); + private DetermineStartPlayer determineStartPlayer = new DetermineStartPlayer(this, logic); + private Spectator spectator = new Spectator(this, logic); + private Turn turn = new Turn(this, logic); + private Waiting waiting = new Waiting(this, logic); + + public GameState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + state = determineStartPlayer; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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 new file mode 100644 index 00000000..3d0cb8cd --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Interrupt.java @@ -0,0 +1,18 @@ +package pp.mdga.client; + +public class Interrupt extends ClientState { + + public Interrupt(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/Observer.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/Observer.java similarity index 67% rename from Projekte/mdga/model/src/main/java/pp.mdga/server/Observer.java rename to Projekte/mdga/model/src/main/java/pp/mdga/client/Observer.java index a95ad2ad..73290304 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Observer.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Observer.java @@ -1,4 +1,4 @@ -package pp.mdga.server; +package pp.mdga.client; public interface Observer { void update(); 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 new file mode 100644 index 00000000..7f57598b --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/Settings.java @@ -0,0 +1,18 @@ +package pp.mdga.client; + +public class Settings extends ClientState { + + public Settings(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/CeremonyStates.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/CeremonyStates.java new file mode 100644 index 00000000..8bd888c7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/CeremonyStates.java @@ -0,0 +1,10 @@ +package pp.mdga.client.ceremonyState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public abstract class CeremonyStates extends ClientState { + protected CeremonyStates(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Podium.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Podium.java new file mode 100644 index 00000000..b7bac3c2 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Podium.java @@ -0,0 +1,20 @@ +package pp.mdga.client.ceremonyState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Podium extends CeremonyStates { + public Podium(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Statistics.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Statistics.java new file mode 100644 index 00000000..76f00d76 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/Statistics.java @@ -0,0 +1,20 @@ +package pp.mdga.client.ceremonyState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Statistics extends CeremonyStates { + public Statistics(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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/dialogState/Lobby.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/Lobby.java new file mode 100644 index 00000000..e2eb9091 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/Lobby.java @@ -0,0 +1,63 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.Dialogs; +import pp.mdga.game.Color; +import pp.mdga.message.client.*; +import pp.mdga.message.server.ServerStartGame; + +public class Lobby extends DialogStates { + + private final Dialogs parent; + + public Lobby(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (Dialogs) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + @Override + public void selectLeave() { + parent.setState(parent.getStartDialog()); + } + + @Override + public void selectTSK(Color color) { + logic.send(new SelectTSK(color)); + } + + @Override + public void deselectTSK(Color color) { + logic.send(new DeselectTSK(color)); + } + + @Override + public void selectReady() { + logic.send(new LobbyReady()); + } + + @Override + public void selectUnready(){ + logic.send(new LobbyNotReady()); + } + + @Override + public void selectStart(){ + logic.send(new StartGame()); + } + + @Override + public void received(ServerStartGame msg){ + parent.startGame(); + } +} 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..923c3b82 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/NetworkDialog.java @@ -0,0 +1,62 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.Dialogs; + +public class NetworkDialog extends DialogStates { + + private final Dialogs parent; + + public NetworkDialog(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (Dialogs) parent; + } + + private boolean checkIP(String IP){ + String[] parts = IP.split("\\."); + + // Step 2: Check if there are exactly 4 parts + if (parts.length != 4) { + return false; + } + + // Step 3: Check each part for valid number + for (String part : parts) { + try { + // Step 4: Convert each part into a number + int num = Integer.parseInt(part); + + // Step 5: Check whether the number lies in between 0 and 255 + if (num < 0 || num > 255) { + return false; + } + } catch (NumberFormatException e) { + // If parsing fails, it's not a valid number + return false; + } + } + + // If all checks passed, return true + return true; + } + + @Override + public void enter() { + } + + @Override + public void exit() { + } + + public void selectBack() { + parent.setState(parent.getStartDialog()); + } + + public void selectJoin(String IP) { + if(checkIP(IP)){ + parent.setState(parent.getLobby()); + } + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/StartDialog.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/StartDialog.java new file mode 100644 index 00000000..0ebac81c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/StartDialog.java @@ -0,0 +1,37 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.Dialogs; + +public class StartDialog extends DialogStates { + + private final Dialogs parent; + + public StartDialog(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (Dialogs) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + public void selectJoin() { + parent.setState(parent.getNetworkDialog()); + } + + public void selectHost() { + parent.setState(parent.getLobby()); + } + + public void selectLeave() { + parent.exit(); + } +} 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..0d662c08 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Animation.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayer.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayer.java new file mode 100644 index 00000000..9bfb9a6e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayer.java @@ -0,0 +1,21 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class DetermineStartPlayer extends GameStates { + + public DetermineStartPlayer(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..4610a264 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Spectator.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Turn.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Turn.java new file mode 100644 index 00000000..d5ecd747 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Turn.java @@ -0,0 +1,21 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class Turn extends GameStates { + + public Turn(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..2ac53405 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/Waiting.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..6be7ece5 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/DetermineStartPlayerStates.java @@ -0,0 +1,12 @@ +package pp.mdga.client.gameState.determineStartPlayerState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.GameStates; + +public abstract 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..774f5f00 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/RollRankingDice.java @@ -0,0 +1,20 @@ +package pp.mdga.client.gameState.determineStartPlayerState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class RollRankingDice extends DetermineStartPlayerStates { + public RollRankingDice(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..3619c7d9 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/WaitRanking.java @@ -0,0 +1,21 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePiece.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePiece.java new file mode 100644 index 00000000..a161030f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePiece.java @@ -0,0 +1,21 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class ChoosePiece extends TurnStates { + + public ChoosePiece(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..2fb60032 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/MovePiece.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..8d5724f7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PlayPowerCard.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCard.java new file mode 100644 index 00000000..02682c4f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCard.java @@ -0,0 +1,21 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class PowerCard extends TurnStates { + + public PowerCard(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..bf0544cd --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/RollDice.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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/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..2daf6271 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/NoPiece.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..bfac2134 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/SelectPiece.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..9a192957 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/StartPiece.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..77b44da1 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/WaitingPiece.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..9638f798 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ChoosePowerCard.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..748e57ad --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Shield.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..b88c53d3 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/Swap.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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..c8e6f258 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/AudioSettings.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/MainSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/MainSettings.java new file mode 100644 index 00000000..44241156 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/MainSettings.java @@ -0,0 +1,20 @@ +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) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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/settingsState/VideoSettings.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/VideoSettings.java new file mode 100644 index 00000000..214ebcb5 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/VideoSettings.java @@ -0,0 +1,20 @@ +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); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } +} 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 new file mode 100644 index 00000000..7e7e2344 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Color.java @@ -0,0 +1,12 @@ +package pp.mdga.game; + +public enum Color { + AIRFORCE, + CYBER, + NAVY, + ARMY; + + public Color next() { + return values()[(ordinal() + 1) % values().length]; + } +} 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 52% 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 index 7807061f..6ddfae36 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,35 +2,33 @@ 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. * The game state is updated by the game logic. */ public class Game { + /** + * Constants. + */ + public static final int AMOUNT_OF_TURBO_CARDS = 16; + public static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12; + + /** + * Attributes. + */ private int diceModifier = 1; private int diceEyes; - private Map players = new HashMap(); + private Map players = new HashMap<>(); 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 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; + private final ArrayList observers = new ArrayList<>(); + private boolean allRanked = false; + private boolean movablePieces = false; + private boolean allReady = false; /** * This constructor creates a new Game object. @@ -48,223 +46,23 @@ public Game() { board = new Board(); } - /** - * This method returns the dice modifier. - * - * @return the dice modifier - */ - public int getDiceModifier() { - return diceModifier; - } - - /** - * This method sets the dice modifier. - * - * @param diceModifier the new dice modifier - */ - public void setDiceModifier(int diceModifier) { - this.diceModifier = diceModifier; - } - - /** - * This method returns the dice eyes. - * - * @return the dice eyes - */ - public int getDiceEyes() { - return diceEyes; - } - - /** - * This method sets the dice eyes. - * - * @param diceEyes the new dice eyes - */ - public void setDiceEyes(int diceEyes) { - this.diceEyes = diceEyes; - } - - /** - * This method returns the players. - * - * @return the players - */ - public Map getPlayers() { - return players; - } - - /** - * This method sets the players. - * - * @param players the new players - */ - public void setPlayers(Map players) { - this.players = players; - } - - /** - * This method returns the game statistics. - * - * @return the game statistics - */ - public Statistic getGameStatistics() { - return gameStatistics; - } - - /** - * This method sets the game statistics. - * - * @param gameStatistics the new game statistics - */ - public void setGameStatistics(Statistic gameStatistics) { - this.gameStatistics = gameStatistics; - } - - /** - * This method returns the draw pile. - * - * @return the draw pile - */ - public ArrayList getDrawPile() { - return drawPile; - } - - /** - * This method sets the draw pile. - * - * @param drawPile the new draw pile - */ - public void setDrawPile(ArrayList drawPile) { - this.drawPile = drawPile; - } - - /** - * This method returns the discard pile. - * - * @return the discard pile - */ - public ArrayList getDiscardPile() { - return discardPile; - } - - /** - * This method sets the discard pile. - * - * @param discardPile the new discard pile - */ - public void setDiscardPile(ArrayList discardPile) { - this.discardPile = discardPile; - } - - /** - * This method returns the board. - * - * @return the board - */ - public Board getBoard() { - return board; - } - - /** - * This method sets the board. - * - * @param board the new board - */ - public void setBoard(Board board) { - this.board = board; - } - - /** - * This method returns the active color. - * - * @return the active color - */ - public Color getActiveColor() { - return activeColor; - } - - /** - * This method sets the active color. - * - * @param activeColor the new active color - */ - public void setActiveColor(Color activeColor) { - this.activeColor = activeColor; - } - - /** - * This method returns the order of the players. - * - * @return the order of the players - */ - public LinkedList getOrder() { - return order; - } - - /** - * This method sets the order of the players. - * - * @param order the new order of the players - */ - public void setOrder(LinkedList 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. * - * @param color the color of the player + * @param id the id of the player * @param player the player to be added */ - public void addPlayer(Color color, Player player) { - players.put(color, player); + public void addPlayer(int id, Player player) { + players.put(id, player); } /** * This method removes a player from the game. * - * @param color the color of the player + * @param id the color of the player */ - public void removePlayer(Color color) { - players.remove(color); + public void removePlayer(int id) { + players.remove(id); } /** @@ -286,49 +84,135 @@ public void removeObserver(Observer observer) { } /** - * This method returns the game has started. * - * @return the game has started + * @param id + * @param active */ - public Boolean getGameHasStarted() { - return gameHasStarted; + public void updatePlayerActiveState(int id, boolean active) { + this.players.get(id).setActive(active); } /** - * This method sets the game has started. + * This method will be used to return the player which has the given id parameter. * - * @param gameHasStarted the new game has started + * @param id as the unique id of a player as an Integer. + * @return the player with the given id as a Player object. */ - public void setGameHasStarted(Boolean gameHasStarted) { - this.gameHasStarted = gameHasStarted; + public Player getPlayerById(int id) { + return this.players.get(id); } /** - * This method returns the player has disconnected. + * This method will be used to the get the player depending on the given color parameter. * - * @return the player has disconnected + * @param color as the color of the player as a Color enumeration. + * @return the player with the given color as a Player object. */ - public Boolean playerHasDisconnected() { - return playerHasDisconnected; + public Player getPlayerByColor(Color color) { + for (Map.Entry entry : this.players.entrySet()) { + if (entry.getValue().getColor() == color) { + return entry.getValue(); + } + } + + return null; } /** - * This method sets the game interruption state. + * This method will be used to return the number of active players of this game. * - * @param gameIsInterrupted the new game interruption state + * @return activePlayers as an Integer. */ - public void setGameIsInterrupted(Boolean gameIsInterrupted) { - this.gameIsInterrupted = gameIsInterrupted; - if (!gameIsInterrupted) notifyObservers(); + public int getNumberOfActivePlayers() { + int activePlayers = 0; + for (Map.Entry entry : this.players.entrySet()) { + if (entry.getValue().isActive()) { + activePlayers++; + } + } + + return activePlayers; } /** - * This method returns whether the game is interrupted. - * - * @return true if the game is interrupted, false otherwise + * This method notifies the observers. */ - public Boolean gameIsInterrupted() { - return gameIsInterrupted; + public void notifyObservers() { + for (Observer observer : new ArrayList<>(observers)) { + //TODO: observer.update(); + } + } + + /** + * This method returns the dice modifier. + * + * @return the dice modifier + */ + public int getDiceModifier() { + return diceModifier; + } + + /** + * This method returns the dice eyes. + * + * @return the dice eyes + */ + public int getDiceEyes() { + return diceEyes; + } + + /** + * This method returns the players. + * + * @return the players + */ + public Map getPlayers() { + return players; + } + + /** + * This method returns the game statistics. + * + * @return the game statistics + */ + public Statistic getGameStatistics() { + return gameStatistics; + } + + /** + * This method returns the draw pile. + * + * @return the draw pile + */ + public List getDrawPile() { + return drawPile; + } + + /** + * This method returns the discard pile. + * + * @return the discard pile + */ + public List getDiscardPile() { + return discardPile; + } + + /** + * This method returns the board. + * + * @return the board + */ + public Board getBoard() { + return board; + } + + /** + * This method returns the active color. + * + * @return the active color + */ + public Color getActiveColor() { + return activeColor; } /** @@ -340,6 +224,78 @@ public Boolean getMovablePieces() { return movablePieces; } + /** + * This method sets the dice modifier. + * + * @param diceModifier the new dice modifier + */ + public void setDiceModifier(int diceModifier) { + this.diceModifier = diceModifier; + } + + /** + * This method sets the dice eyes. + * + * @param diceEyes the new dice eyes + */ + public void setDiceEyes(int diceEyes) { + this.diceEyes = diceEyes; + } + + /** + * This method sets the players. + * + * @param players the new players + */ + public void setPlayers(Map players) { + this.players = players; + } + + /** + * This method sets the game statistics. + * + * @param gameStatistics the new game statistics + */ + public void setGameStatistics(Statistic gameStatistics) { + this.gameStatistics = gameStatistics; + } + + /** + * This method sets the draw pile. + * + * @param drawPile the new draw pile + */ + public void setDrawPile(List drawPile) { + this.drawPile = drawPile; + } + + /** + * This method sets the discard pile. + * + * @param discardPile the new discard pile + */ + public void setDiscardPile(List discardPile) { + this.discardPile = discardPile; + } + + /** + * This method sets the board. + * + * @param board the new board + */ + public void setBoard(Board board) { + this.board = board; + } + + /** + * This method sets the active color. + * + * @param activeColor the new active color + */ + public void setActiveColor(Color activeColor) { + this.activeColor = activeColor; + } + /** * This method sets the game interruption state. * @@ -347,17 +303,7 @@ public Boolean getMovablePieces() { */ public void setMovablePieces(Boolean movablePieces) { this.movablePieces = movablePieces; - if (!movablePieces) notifyObservers(); - } - - /** - * This method sets the player has disconnected. - * - * @param playerHasDisconnected the new player has disconnected - */ - public void setPlayerHasDisconnected(Boolean playerHasDisconnected) { - this.playerHasDisconnected = playerHasDisconnected; - if (playerHasDisconnected) notifyObservers(); + if (Boolean.FALSE.equals(movablePieces)) notifyObservers(); } /** @@ -376,46 +322,25 @@ public Boolean allRanked() { */ public void setAllRanked(Boolean allRanked) { this.allRanked = allRanked; - if (allRanked) notifyObservers(); + if (Boolean.TRUE.equals(allRanked)) notifyObservers(); } /** - * This method returns the start player. + * This method returns the all ready state. * - * @return the start player + * @return the already state */ - public Player getStartPlayer() { - return startPlayer; + public Boolean allReady() { + return allReady; } /** - * This method sets the start player. + * This method sets the all ready state. * - * @param startPlayer the new start player + * @param allReady the new all-ready state */ - public void setStartPlayer(Player startPlayer) { - this.startPlayer = startPlayer; - } - - /** - * This method notifies the observers. - */ - public void notifyObservers() { - for (Observer observer : new ArrayList<>(observers)) { - 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]; + public void setAllReady(Boolean allReady) { + this.allReady = allReady; + if (Boolean.TRUE.equals(allReady)) notifyObservers(); } } 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 55% 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 index e9e16645..c536438f 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 @@ -6,21 +6,31 @@ * This class will be used to handle general PlayerData */ public class Player { - private String name; private Statistic playerStatistic; private ArrayList handCards; - private final int id; + private Color color; + private boolean isReady; + private boolean active = true; /** * This constructor constructs a new Player object + * + * @param name the name of the player */ - public Player(int id) { - this.id = id; + public Player(String name) { + this.name = name; playerStatistic = new Statistic(); handCards = new ArrayList<>(); } + /** + * Constructor. + */ + public Player() { + this(""); + } + /** * This method returns the give name of the Player * @@ -62,7 +72,7 @@ public ArrayList getHandCards() { * * @param card the card to be added to the players hand */ - public void addHandCards(BonusCard card){ + public void addHandCards(BonusCard card) { handCards.add(card); } @@ -81,11 +91,56 @@ public BonusCard removeHandCard(BonusCard card) { } /** - * Returns the id of the connection to the client represented by this player. + * This method returns the color of the player * - * @return the id + * @return the color of the player */ - public int getId() { - return id; + 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; + } + + /** + * This method returns if the player is ready + * + * @return true if the player is ready, false otherwise + */ + public boolean isReady() { + return isReady; + } + + /** + * This method will be used to return active attribute of Player class. + * + * @return active as a Boolean. + */ + public boolean isActive() { + return this.active; + } + + /** + * This method sets the player to ready + * + * @param ready true if the player is ready, false otherwise + */ + public void setReady(boolean ready) { + isReady = ready; + } + + /** + * This method will be used to set active attribute of Player class to the given active parameter. + * + * @param active as the new active value as a Boolean. + */ + public void setActive(boolean active) { + this.active = active; } } 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 new file mode 100644 index 00000000..c6bfa62e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/AnimationEnd.java @@ -0,0 +1,37 @@ +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 { + /** + * 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 new file mode 100644 index 00000000..e38ee74f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientInterpreter.java @@ -0,0 +1,150 @@ +package pp.mdga.message.client; + +/** + * Visitor interface for processing all client messages. + */ +public interface ClientInterpreter { + /** + * 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); + + /** + * 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); + + /** + * 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(StartGame msg, 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); + + /** + * 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); + + /** + * 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); + + /** + * 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); + + /** + * Processes a received Disconnected message. + * + * @param msg the Disconnected message to be processed + * @param from the connection ID from which the message was received + */ + void received(Disconnected msg, 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); + + /** + * Processes a received RequestDie message. + * + * @param msg the RequestDie message to be processed + * @param from the connection ID from which the message was received + */ + void received(RequestDie msg, 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); + + /** + * 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); + + /** + * 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); + + /** + * 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); + + /** + * 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); + + /** + * 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); + + /** + * 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 new file mode 100644 index 00000000..35a22cf2 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientMessage.java @@ -0,0 +1,24 @@ +package pp.mdga.message.client; + +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 new file mode 100644 index 00000000..bde881e1 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientStartGame.java @@ -0,0 +1,37 @@ +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 { + /** + * 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 new file mode 100644 index 00000000..5f2d4e26 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/DeselectTSK.java @@ -0,0 +1,62 @@ +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; + } + + /** + * Default constructor for serialization purposes. + */ + private DeselectTSK() { + color = null; + } + + /** + * 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 "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/Disconnected.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/Disconnected.java new file mode 100644 index 00000000..0b901ff7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/Disconnected.java @@ -0,0 +1,34 @@ +package pp.mdga.message.client; + +import com.jme3.network.serializing.Serializable; + +/** + * + */ +@Serializable +public class Disconnected extends ClientMessage { + public Disconnected() { + 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/ForceContinueGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ForceContinueGame.java new file mode 100644 index 00000000..de6615f1 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ForceContinueGame.java @@ -0,0 +1,37 @@ +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 { + /** + * 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/JoinServer.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/JoinServer.java new file mode 100644 index 00000000..965fbaea --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/JoinServer.java @@ -0,0 +1,49 @@ +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 { + + private final String name; + + /** + * Constructs a new JoinServer instance. + */ + public JoinServer(String name) { + super(); + this.name = name; + } + + /** + * Constructs a new JoinServer instance. + */ + public JoinServer() { + super(); + name = null; + } + + /** + * 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 new file mode 100644 index 00000000..c6c7fda3 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LeaveGame.java @@ -0,0 +1,37 @@ +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 { + /** + * 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 new file mode 100644 index 00000000..fb853c3f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyNotReady.java @@ -0,0 +1,37 @@ +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 { + /** + * 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 new file mode 100644 index 00000000..3427a15c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyReady.java @@ -0,0 +1,37 @@ +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 { + /** + * 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 new file mode 100644 index 00000000..edce79c8 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/NoPowerCard.java @@ -0,0 +1,37 @@ +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 { + /** + * 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 new file mode 100644 index 00000000..60fa41ba --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestBriefing.java @@ -0,0 +1,37 @@ +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 { + /** + * 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/RequestDie.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestDie.java new file mode 100644 index 00000000..b50b467e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestDie.java @@ -0,0 +1,37 @@ +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 RequestDie extends ClientMessage { + /** + * Constructs a new RequestDie instance. + */ + public RequestDie() { + super(); + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + return "RequestDie{}"; + } + + /** + * 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 new file mode 100644 index 00000000..80ccd63e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestMove.java @@ -0,0 +1,60 @@ +package pp.mdga.message.client; + +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 + * + * @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() { + return pieceIdentifier; + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + 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 new file mode 100644 index 00000000..8c21b0b0 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestPlayCard.java @@ -0,0 +1,106 @@ +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 ownPieceIdentifier; + + private final String enemyPieceIdentifier; + + /** + * Constructs a new RequestPlayCard instance. + * + * @param card the bonus card to be played + * @param ownPieceIdentifier the identifier of the piece + */ + public RequestPlayCard(BonusCard card, String ownPieceIdentifier, String enemyPieceIdentifier) { + this.ownPieceIdentifier = ownPieceIdentifier; + this.card = card; + this.enemyPieceIdentifier = enemyPieceIdentifier; + } + + /** + * Default constructor for serialization purposes. + */ + private RequestPlayCard() { + card = 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); + } + + /** + * 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 getOwnPieceIdentifier() { + return ownPieceIdentifier; + } + + /** + * Gets the enemy piece identifier associated with this request. + * + * @return the enemy piece identifier + */ + public String getEnemyPieceIdentifier() { + return enemyPieceIdentifier; + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String 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 new file mode 100644 index 00000000..2d806a82 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectCard.java @@ -0,0 +1,61 @@ +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; + } + + /** + * Default constructor for serialization purposes. + */ + private SelectCard() { + card = null; + } + + /** + * 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 "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 new file mode 100644 index 00000000..0bb1d071 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectTSK.java @@ -0,0 +1,56 @@ +package pp.mdga.message.client; + +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; + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + 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 new file mode 100644 index 00000000..d98b21bf --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectedPieces.java @@ -0,0 +1,60 @@ +package pp.mdga.message.client; + +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 + * + * @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() { + return pieceIdentifier; + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + 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); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/message/client/StartGame.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/StartGame.java new file mode 100644 index 00000000..c0ce62a5 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/StartGame.java @@ -0,0 +1,46 @@ +package pp.mdga.message.client; + +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 StartGame extends ClientMessage { + + private final boolean forceStartGame; + + public StartGame(boolean forceStartGame){ + super(); + this.forceStartGame = forceStartGame; + } + + /** + * Constructs a new ForceStartGame message. + */ + public StartGame() { + super(); + forceStartGame = false; + } + + /** + * Returns a string representation of this message. + * + * @return a string representation of this message + */ + @Override + public String toString() { + 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/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/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/Die.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/Die.java new file mode 100644 index 00000000..607dea38 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/Die.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 Die 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 Die(int diceEye, List moveablePieces) { + super(); + this.diceEye = diceEye; + this.moveablePieces = moveablePieces; + } + + /** + * Default constructor for serialization purposes. + */ + private Die() { + diceEye = 0; + moveablePieces = null; + } + + /** + * Constructor for inactivePlayer + * + * @param diceEye the eye of the dice + * @return a new Dice object + */ + public static Die inactivePlayer(int diceEye) { + return new Die(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 Die activePlayer(int diceEye, List moveablePieces) { + return new Die(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/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..a04f8639 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerJoin.java @@ -0,0 +1,87 @@ +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; + + /** + * The ID of the new Player + */ + private final int id; + + /** + * Constructs a new LobbyPlayerJoin instance with the specified player name. + * + * @param name the name of the player joining the lobby + */ + public LobbyPlayerJoin(int id, String name) { + super(); + this.name = name; + this.id = id; + } + + /** + * Default constructor for serialization purposes. + */ + private LobbyPlayerJoin() { + name = null; + id = 0; + } + + /** + * Returns the name of the player joining the lobby. + * + * @return the name of the player joining the lobby + */ + public String getName() { + return name; + } + + /** + * Returns the id of the new Player + * + * @return the id of the player + */ + public int getId(){ + return id; + } + + /** + * 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..7cf928f2 --- /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 int id; + + /** + * 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 id the id of the player leaving the lobby + * @param color the color associated with the player leaving the lobby + */ + public LobbyPlayerLeave(int id, Color color) { + super(); + this.id = id; + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private LobbyPlayerLeave() { + id = 0; + color = null; + } + + /** + * Returns the name of the player leaving the lobby. + * + * @return the name of the player leaving the lobby + */ + public int getId() { + return id; + } + + /** + * 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..0b7e26b5 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerInterpreter.java @@ -0,0 +1,203 @@ +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 Die message received from the server. + * + * @param msg the Dice message received + */ + void received(Die 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); + + /** + * Handles a Spectator message received from the server. + * + * @param msg the Spectator message received. + */ + void received(Spectator 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/Spectator.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/Spectator.java new file mode 100644 index 00000000..88c92b77 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/Spectator.java @@ -0,0 +1,32 @@ +package pp.mdga.message.server; + +/** + * + */ +public class Spectator extends ServerMessage { + /** + * Construc + */ + public Spectator() { + super(); + } + + /** + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + interpreter.received(this); + } + + + /** + * + * @return + */ + @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..233f6e7c --- /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 int playerId; + + /** + * Indicates whether the player is ready. + */ + private final boolean ready; + + /** + * Constructs a new UpdateReady instance with the specified color and readiness status. + * + * @param playerId the playerId associated with the update + * @param ready the readiness status + */ + public UpdateReady(int playerId, boolean ready) { + super(); + this.playerId = playerId; + this.ready = ready; + } + + /** + * Default constructor for serialization purposes. + */ + private UpdateReady() { + super(); + this.playerId = 0; + this.ready = false; + } + + /** + * Gets the playerId associated with the update. + * + * @return the playerId + */ + public int getPlayerId() { + return playerId; + } + + /** + * 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..e6cd5e03 --- /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 int id; + + /** + * The color associated with the update. + */ + private final Color color; + + /** + * Constructs a new UpdateTSK instance with the specified name and color. + * + * @param id the name associated with the update + * @param color the color associated with the update + */ + public UpdateTSK(int id, Color color) { + super(); + this.id = id; + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private UpdateTSK() { + this(0, null); + } + + /** + * Gets the name associated with the update. + * + * @return the name + */ + public int getId() { + return id; + } + + /** + * 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 ""; + } +} 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 new file mode 100644 index 00000000..d9da6d38 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/MoveThrowPieceNotification.java @@ -0,0 +1,64 @@ +package pp.mdga.notification; + +import pp.mdga.game.Color; + +import java.util.UUID; + +public class MoveThrowPieceNotification extends Notification{ + + private UUID pieceId1; + private UUID pieceId2; + private int nodeIndex; + private Color colorPiece2; + + /** + * This constructor is used to create a new MoveThrowPieceNotification + * + * @param pieceId1 the pieceId1 + * @param pieceId2 the pieceId2 + * @param nodeIndex the nodeIndex + * @param colorPiece2 the color + */ + public MoveThrowPieceNotification(UUID pieceId1, UUID pieceId2, int nodeIndex, Color colorPiece2) { + this.pieceId1 = pieceId1; + this.pieceId2 = pieceId2; + this.nodeIndex = nodeIndex; + this.colorPiece2 = colorPiece2; + } + + /** + * This method returns the pieceId1 + * + * @return the pieceId1 + */ + public UUID getPieceId1() { + return pieceId1; + } + + /** + * This method returns the pieceId2 + * + * @return the pieceId2 + */ + public UUID getPieceId2() { + return pieceId2; + } + + /** + * This method returns the nodeIndex + * + * @return the nodeIndex + */ + public int getNodeIndex() { + return nodeIndex; + } + + /** + * This method returns the color + * + * @return the color + */ + public Color getColor() { + return colorPiece2; + } +} 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 67% 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 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(){ + + } } 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/SelectableMoveNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableMoveNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/SelectableMoveNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableMoveNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/SelectableSwapNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableSwapNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/SelectableSwapNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableSwapNotification.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/ThrowPieceNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/ThrowPieceNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/ThrowPieceNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/ThrowPieceNotification.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/ChoosePieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/ChoosePieceState.java new file mode 100644 index 00000000..beb19efa --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ChoosePieceState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class ChoosePieceState extends TurnState { + public ChoosePieceState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/DetermineStartPlayerState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/DetermineStartPlayerState.java new file mode 100644 index 00000000..9f041111 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/DetermineStartPlayerState.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.server.automaton.GameState; + +public class DetermineStartPlayerState extends GameState { + public DetermineStartPlayerState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/FirstRollStateState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/FirstRollStateState.java new file mode 100644 index 00000000..b8d91c26 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/FirstRollStateState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class FirstRollStateState extends RollDiceState { + public FirstRollStateState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/MovePieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/MovePieceState.java new file mode 100644 index 00000000..27aac8fd --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/MovePieceState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class MovePieceState extends TurnState { + public MovePieceState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/NoPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/NoPieceState.java new file mode 100644 index 00000000..a4120ecb --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/NoPieceState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class NoPieceState extends ChoosePieceState { + public NoPieceState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/NoTurnState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/NoTurnState.java new file mode 100644 index 00000000..d96a3e78 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/NoTurnState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class NoTurnState extends ChoosePieceState { + public NoTurnState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/PowerCardState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/PowerCardState.java new file mode 100644 index 00000000..d5db6a11 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/PowerCardState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class PowerCardState extends TurnState { + public PowerCardState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/RollDiceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/RollDiceState.java new file mode 100644 index 00000000..cf1edf5c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/RollDiceState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class RollDiceState extends TurnState { + public RollDiceState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/SecondRollState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/SecondRollState.java new file mode 100644 index 00000000..f612cd2c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/SecondRollState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class SecondRollState extends RollDiceState { + public SecondRollState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/SelectPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/SelectPieceState.java new file mode 100644 index 00000000..37a0c8f9 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/SelectPieceState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class SelectPieceState extends ChoosePieceState { + public SelectPieceState(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..3ea9735e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ServerGameLogic.java @@ -0,0 +1,216 @@ +package pp.mdga.server; + +import pp.mdga.game.Game; +import pp.mdga.message.client.*; +import pp.mdga.server.automaton.*; + +import java.lang.System.Logger; + +/** + * + */ +public class ServerGameLogic implements ClientInterpreter { + /** + * Constants. + */ + private static final Logger LOGGER = System.getLogger(ServerGameLogic.class.getName()); + + /** + * + */ + private final ServerSender serverSender; + private final Game game; + + /** + * States + */ + private ServerState currentState; + private final ServerState lobbyState; + private final ServerState gameState; + private final ServerState interruptState; + private final ServerState ceremonyState; + + /** + * Constructor. + * + * @param serverSender + * @param game + */ + public ServerGameLogic(ServerSender serverSender, Game game) { + this.serverSender = serverSender; + this.game = game; + this.lobbyState = new LobbyState(this); + this.gameState = new GameState(this); + this.interruptState = new InterruptState(this); + this.ceremonyState = new CeremonyState(this); + this.currentState = this.lobbyState; + } + + + @Override + public void received(AnimationEnd msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(DeselectTSK msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(StartGame msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(JoinServer msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(LeaveGame msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(LobbyReady msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(LobbyNotReady msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(Disconnected msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(RequestBriefing msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(RequestDie msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(RequestMove msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(RequestPlayCard msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(SelectCard msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(SelectTSK msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(ForceContinueGame msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(ClientStartGame msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(NoPowerCard msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(SelectedPieces msg, int from) { + this.currentState.received(msg, from); + } + + /** + * This method will be used to return serverSender attribute of ServerGameLogic class. + * + * @return serverSender as a ServerSender object. + */ + public ServerSender getServerSender() { + return this.serverSender; + } + + /** + * This method will be used to return game attribute of ServerGameLogic class. + * + * @return game as a Game object. + */ + public Game getGame() { + return this.game; + } + + /** + * This method will be used to return currentState attribute of ServerGameLogic class. + * + * @return currentState as a ServerState object. + */ + public ServerState getCurrentState() { + return this.currentState; + } + + /** + * This method will be used to return lobbyState attribute of ServerGameLogic class. + * + * @return lobbyState as a ServerState object. + */ + public ServerState getLobbyState() { + return this.lobbyState; + } + + /** + * This method will be used to return gameState attribute of ServerGameLogic class. + * + * @return gameState as a ServerState object. + */ + public ServerState getGameState() { + return this.gameState; + } + + /** + * This method will be used to return interruptState attribute of ServerGameLogic class. + * + * @return interruptState as a ServerState object. + */ + public ServerState getInterruptState() { + return this.interruptState; + } + + /** + * This method will be used to return ceremonyState attribute of ServerGameLogic class. + * + * @return ceremonyState as a ServerState object. + */ + public ServerState getCeremonyState() { + return this.ceremonyState; + } + + /** + * This method will be used to set currentState attribute of ServerGameLogic class to the given state parameter. + * In Addition, the currentState will be exited, changed and entered. + * + * @param state as the new currentState attribute as a ServerState object. + */ + public void setCurrentState(ServerState state) { + if (this.currentState != null) { + this.currentState.exit(); + } + this.currentState = state; + this.currentState.enter(); + } +} 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..7d628e6c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ServerSender.java @@ -0,0 +1,24 @@ +package pp.mdga.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); + + /** + * This method will be used to send the given message parameter to all connected players which are saved inside the + * players attribute of Game class. + * + * @param message as the message which will be sent to all players as a ServerMessage. + */ + void broadcast(ServerMessage message); +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/StartPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/StartPieceState.java new file mode 100644 index 00000000..fff134ce --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/StartPieceState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class StartPieceState extends ChoosePieceState { + public StartPieceState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/ThirdRollState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/ThirdRollState.java new file mode 100644 index 00000000..d5607225 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/ThirdRollState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class ThirdRollState extends RollDiceState { + public ThirdRollState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/TurnState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/TurnState.java new file mode 100644 index 00000000..cbf0f999 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/TurnState.java @@ -0,0 +1,9 @@ +package pp.mdga.server; + +import pp.mdga.server.automaton.GameState; + +public class TurnState extends GameState { + public TurnState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/WaitingPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/WaitingPieceState.java new file mode 100644 index 00000000..64095bf1 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/WaitingPieceState.java @@ -0,0 +1,7 @@ +package pp.mdga.server; + +public class WaitingPieceState extends ChoosePieceState { + public WaitingPieceState(ServerGameLogic logic) { + super(logic); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/CeremonyState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/CeremonyState.java new file mode 100644 index 00000000..4182bdb1 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/CeremonyState.java @@ -0,0 +1,33 @@ +package pp.mdga.server.automaton; + +import pp.mdga.server.ServerGameLogic; + +/** + * + */ +public class CeremonyState extends ServerState { + /** + * Constructor. + * + * @param logic as the server game logic which is the automaton as a ServerGameLogic object. + */ + public CeremonyState(ServerGameLogic logic) { + super(logic); + } + + /** + * This method will be used whenever this state will be entered. + */ + @Override + public void enter() { + // ToDo: Close server. + } + + /** + * This method will be used whenever this state will be exited. + */ + @Override + public void exit() { + + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/GameState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/GameState.java new file mode 100644 index 00000000..f49f50d0 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/GameState.java @@ -0,0 +1,60 @@ +package pp.mdga.server.automaton; + +import pp.mdga.message.client.Disconnected; +import pp.mdga.message.client.LeaveGame; +import pp.mdga.message.server.PauseGame; +import pp.mdga.server.ServerGameLogic; + +/** + * + */ +public class GameState extends ServerState { + /** + * Constructor. + * + * @param logic as the server game logic which is the automaton as a ServerGameLogic object. + */ + public GameState(ServerGameLogic logic) { + super(logic); + } + + /** + * This method will be used whenever this state will be entered. + */ + @Override + public void enter() { + + } + + /** + * This method will be used whenever this state will be exited. + */ + @Override + public void exit() { + + } + + /** + * + * @param msg as the message which was sent by the player as a Disconnected object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(Disconnected msg, int from) { + this.logic.getServerSender().broadcast(new PauseGame()); + this.logic.setCurrentState(this.logic.getInterruptState()); + } + + /** + * + * @param msg as the message which was sent by the player as a LeaveGame object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(LeaveGame msg, int from) { + this.logic.getGame().updatePlayerActiveState(from, false); + if (this.logic.getGame().getNumberOfActivePlayers() == 1) { + this.logic.setCurrentState(this.logic.getCeremonyState()); + } + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/InterruptState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/InterruptState.java new file mode 100644 index 00000000..b0283d83 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/InterruptState.java @@ -0,0 +1,47 @@ +package pp.mdga.server.automaton; + +import com.jme3.system.Timer; +import pp.mdga.message.client.ForceContinueGame; +import pp.mdga.message.server.ResumeGame; +import pp.mdga.server.ServerGameLogic; + +/** + * + */ +public class InterruptState extends ServerState { + /** + * Attributes. + */ + private Timer timer; + + /** + * Constructor. + * + * @param logic as the server game logic which is the automaton as a ServerGameLogic object. + */ + public InterruptState(ServerGameLogic logic) { + super(logic); + } + + /** + * This method will be used whenever this state will be entered. + */ + @Override + public void enter() { + // Create timer and connect signal. + } + + /** + * This method will be used whenever this state will be exited. + */ + @Override + public void exit() { + + } + + @Override + public void received(ForceContinueGame msg, int from) { + this.logic.getServerSender().broadcast(new ResumeGame()); + this.logic.setCurrentState(this.logic.getGameState()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/LobbyState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/LobbyState.java new file mode 100644 index 00000000..9e1674ac --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/LobbyState.java @@ -0,0 +1,88 @@ +package pp.mdga.server.automaton; + +import pp.mdga.message.client.*; +import pp.mdga.message.server.ServerStartGame; +import pp.mdga.message.server.UpdateReady; +import pp.mdga.message.server.UpdateTSK; +import pp.mdga.server.ServerGameLogic; + +/** + * + */ +public class LobbyState extends ServerState { + /** + * Constructs a server state of the specified game logic. + * + * @param logic the game logic + */ + public LobbyState(ServerGameLogic logic) { + super(logic); + } + + /** + * This method will be used whenever this state will be entered. + */ + @Override + public void enter() { + + } + + /** + * This method will be used whenever this state will be exited. + */ + @Override + public void exit() { + + } + + /** + * + * @param msg as the message which was sent by the player as a SelectTSK object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(SelectTSK msg, int from) { + this.logic.getServerSender().broadcast(new UpdateTSK(from, msg.getColor())); + } + + /** + * + * @param msg as the message which was sent by the player as a DeselectTSK object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(DeselectTSK msg, int from) { + this.logic.getServerSender().broadcast(new UpdateTSK(from, msg.getColor())); + } + + /** + * + * @param msg as the message which was sent by the player as a LobbyReady object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(LobbyReady msg, int from) { + this.logic.getServerSender().broadcast(new UpdateReady(from, true)); + } + + /** + * + * @param msg as the message which was sent by the player as a LobbyNotReady object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(LobbyNotReady msg, int from) { + this.logic.getServerSender().broadcast(new UpdateReady(from, false)); + } + + /** + * + * @param msg as the message which was sent by the player as a ForceStartGame object. + * @param from as the client id of the player as an Integer. + */ + @Override + public void received(StartGame msg, int from) { + this.logic.getServerSender().broadcast(new ServerStartGame()); + this.logic.setCurrentState(this.logic.getGameState()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/ServerState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/ServerState.java new file mode 100644 index 00000000..ce6a99fd --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/ServerState.java @@ -0,0 +1,196 @@ +package pp.mdga.server.automaton; + +import pp.mdga.message.client.*; +import pp.mdga.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 abstract class ServerState { + /** + * The server logic object. + */ + protected final ServerGameLogic logic; + + /** + * Constructs a server state of the specified game logic. + * + * @param logic the game logic + */ + public ServerState(ServerGameLogic logic) { + this.logic = logic; + } + + /** + * This method will be used whenever this state will be entered. + */ + public abstract void enter(); + + /** + * This method will be used whenever this state will be exited. + */ + public abstract void exit(); + + /** + * This method will be called whenever the server received an AnimationEnd message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a AnimationEnd object. + * @param from as the client id of the player as an Integer. + */ + public void received(AnimationEnd msg, int from) {} + + /** + * This method will be called whenever the server received an DeselectTSK message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a DeselectTSK object. + * @param from as the client id of the player as an Integer. + */ + public void received(DeselectTSK msg, int from) {} + + /** + * This method will be called whenever the server received a StartGame message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a StartGame object. + * @param from as the client id of the player as an Integer. + */ + public void received(StartGame msg, int from) {} + + /** + * This method will be called whenever the server received a JoinServer message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a JoinServer object. + * @param from as the client id of the player as an Integer. + */ + public void received(JoinServer msg, int from) {} + + /** + * This method will be called whenever the server received an LeaveGame message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a LeaveGame object. + * @param from as the client id of the player as an Integer. + */ + public void received(LeaveGame msg, int from) {} + + /** + * This method will be called whenever the server received a LobbyReady message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a LobbyReady object. + * @param from as the client id of the player as an Integer. + */ + public void received(LobbyReady msg, int from) {} + + /** + * This method will be called whenever the server received a LobbyNotReady message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a LobbyNotReady object. + * @param from as the client id of the player as an Integer. + */ + public void received(LobbyNotReady msg, int from) {} + + /** + * This method will be called whenever the server received a Disconnected message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a Disconnected object. + * @param from as the client id of the player as an Integer. + */ + public void received(Disconnected msg, int from) {} + + /** + * This method will be called whenever the server received a Briefing message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a Briefing object. + * @param from as the client id of the player as an Integer. + */ + public void received(RequestBriefing msg, int from) {} + + /** + * This method will be called whenever the server received a Die message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a Die object. + * @param from as the client id of the player as an Integer. + */ + public void received(RequestDie msg, int from) {} + + /** + * This method will be called whenever the server received a RequestMove message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a RequestMove object. + * @param from as the client id of the player as an Integer. + */ + public void received(RequestMove msg, int from) {} + + /** + * This method will be called whenever the server received a PlayCard message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a PlayCard object. + * @param from as the client id of the player as an Integer. + */ + public void received(RequestPlayCard msg, int from) {} + + /** + * This method will be called whenever the server received a SelectCard message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a SelectCard object. + * @param from as the client id of the player as an Integer. + */ + public void received(SelectCard msg, int from) {} + + /** + * This method will be called whenever the server received a SelectTSK message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a SelectTSK object. + * @param from as the client id of the player as an Integer. + */ + public void received(SelectTSK msg, int from) {} + + /** + * This method will be called whenever the server received a ForceContinueGame message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a ForceContinueGame object. + * @param from as the client id of the player as an Integer. + */ + public void received(ForceContinueGame msg, int from) {} + + /** + * This method will be called whenever the server received a ClientStartGame message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a ClientStartGame object. + * @param from as the client id of the player as an Integer. + */ + public void received(ClientStartGame msg, int from) {} + + /** + * This method will be called whenever the server received a NoPowerCard message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a NoPowerCard object. + * @param from as the client id of the player as an Integer. + */ + public void received(NoPowerCard msg, int from) {} + + /** + * This method will be called whenever the server received a SelectedPieces message. + * It will also get the client id of the player who send this message. + * + * @param msg as the message which was sent by the player as a SelectedPieces object. + * @param from as the client id of the player as an Integer. + */ + public void received(SelectedPieces msg, int 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 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/LobbyStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyStateTest.java new file mode 100644 index 00000000..c8c2344f --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyStateTest.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 LobbyStateTest { + + @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/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java new file mode 100644 index 00000000..0293f46d --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -0,0 +1,1429 @@ +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.ceremonyState.Podium; +import pp.mdga.client.ceremonyState.Statistics; +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.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.VideoSettings; +import pp.mdga.game.BonusCard; +import pp.mdga.game.Color; +import pp.mdga.message.client.ClientMessage; + +import java.util.ArrayList; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * this test-class tests the testcases T170-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 CeremonyMessage 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 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 pp.mdga.game.Game game; + + @Before + public void setUp() { + //initialize the game + game = new pp.mdga.game.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(color); + anyPiece = new AnyPiece(); + briefing = new Briefing(); + ceremonyMessage = new CeremonyMessage(); + dice = new Dice(6,new ArrayList<>()); + diceAgain = new DiceAgain(); + diceNow = new DiceNow(); + endOfTurn = new EndOfTurn(); + lobbyAccept = new LobbyAccept(); + lobbyDeny = new LobbyDeny(); + lobbyPlayerJoin = new LobbyPlayerJoin(name); + lobbyPlayerLeave = new LobbyPlayerLeave(name,color); + moveMessage = new MoveMessage("www");//Todo + noTurn = new NoTurn(); + pauseGame = new PauseGame(); + 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(); + rankingRollAgain = new RankingRollAgain(); + reconnectBriefing = new ReconnectBriefing(game); + resumeGame = new ResumeGame(); + startGame = new ServerStartGame(); + startPieceMessage = new StartPiece(); //Todo wrong class + updateReady = new UpdateReady(color,true); + updateTSK = new UpdateTSK(name,color); + waitPiece = new WaitPiece(); + + //initialize the clientGameLogic + clientGameLogic = new ClientGameLogic(game, new ClientSender() { + @Override + public void send(ClientMessage msg) { + + } + }); + clientAutomaton = (ClientAutomaton) clientGameLogic.getState(); + + //initialize the settings + mainSettings = new MainSettings(settingsStateMachine,clientGameLogic); + videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic); + audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic); + settings = new Settings(clientAutomaton,clientGameLogic); + + + //initialize the stateMachines + ceremonyStateMachine =ceremony.getCeremonyStateMachine(); + choosePieceStateMachine = choosePiece.getChoosePieceStateMachine(); + determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerStateMachine(); + dialogsStateMachine = dialogs.getDialogsStateMachine(); + gameStateMachine = gameState.getGameStateMachine(); + powerCardStateMachine = powerCard.getPowerCardStateMachine(); + settingsStateMachine = settings.getSettingsStateMachine(); + turnStateMachine = turn.getTurnStateMachine(); + + + //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 + 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); + } + + /** + * UC-ClientState-02: Test the transition from dialogs to the game state. + */ + @Test + public void testDialogsToGame() { + //tests if the client is in Dialogs + clientAutomaton.gotoState(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 = (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(determineStartPlayerStateMachine1.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 + //TODO how????????? + } + + /** + * UC-ClientState-04: Test the transition from ClientGame to Ceremony. + */ + @Test + public void testClientGameToCeremony() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(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 = ceremony1.getCeremonyStateMachine(); + 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.gotoState(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() { + //sends the ClientAutomaton in Interrupt + clientAutomaton.gotoState(interrupt); + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo send all messages except the continue-message + + assertTrue(clientAutomaton.getState() instanceof Interrupt); + } + + /** + * UC-ClientState-08: Test the transition from ClientInterrupt to the game state. + */ + @Test + public void testClientInterruptToGame() { + //sends the ClientAutomaton in Interrupt + clientAutomaton.gotoState(interrupt); + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo sends the continue-message + + //tests if the client is in the game + assertTrue(clientAutomaton.getState() instanceof GameState); + } + + /** + * UC-ClientState-09: Test the transition from Interrupt to dialogs. + */ + @Test + public void testInterruptToDialogs() { + //sends the ClientAutomaton in Interrupt + clientAutomaton.gotoState(interrupt); + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //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); + } + + /** + * UC-ClientState-10: Test the transition from Ceremony to dialogs. + */ + @Test + public void testCeremonyToDialogs() { + //send the client in the ceremony + clientAutomaton.gotoState(ceremony); + assertTrue(clientAutomaton.getState() instanceof Ceremony); + + //sends the ceremony machine in the statistics + ceremonyStateMachine.gotoState(statistics); + assertTrue(ceremonyStateMachine.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); + } + + /** + * UC-ClientState-11: Test the transition from StartDialog to NetworkDialog1. + */ + @Test + public void testStartDialogToNetworkDialog1() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in StartDialog + dialogsStateMachine.gotoState(startDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + } + + /** + * UC-ClientState-12: Test the transition from StartDialog to NetworkDialog2. + */ + @Test + public void testStartDialogToNetworkDialog2() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in StartDialog + dialogsStateMachine.gotoState(startDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + } + + /** + * UC-ClientState-13: Test the transition from StartDialog to the dialogs end state. + */ + @Test + public void testStartDialogToDialogsEndState() { + // Implementation goes here + //TODO how to test? + } + + /** + * UC-ClientState-14: Test the transition from NetworkDialog to StartDialog. + */ + @Test + public void testNetworkDialogToStartDialog() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo simulate pushBtn + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + } + + /** + * UC-ClientState-15: Test the transition from NetworkDialog to NetworkDialog1. + */ + @Test + public void testNetworkDialogToNetworkDialog1() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo test receiving all messages and making input + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + } + + /** + * UC-ClientState-16: Test the transition from NetworkDialog to NetworkDialog2. + */ + @Test + public void testNetworkDialogToNetworkDialog2() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo simulate try connect to server ith wrong variables + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + 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(dialogsStateMachine.getState() instanceof NetworkDialog); + } + + /** + * UC-ClientState-17: Test the transition from NetworkDialog to Lobby. + */ + @Test + public void testNetworkDialogToLobby() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo simulate connect to server with send lobby request + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); + } + + /** + * UC-ClientState-18: Test the transition from Lobby to StartDialog. + */ + @Test + public void testLobbyToStartDialog() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in Lobby + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); + + //todo simulate leave the lobby + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + } + + /** + * UC-ClientState-19: Test remaining in the Lobby state. + */ + @Test + public void testStayInLobby() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in 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(dialogsStateMachine.getState() instanceof Lobby); + } + + /** + * UC-ClientState-20: Test the transition from Lobby to RollRankingDice. + */ + @Test + public void testLobbyToRollRankingDice() { + //sends the clientStatemachine in Dialogs + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the clientStatemachine in Lobby + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.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.getGameStateMachine(); + assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); + + //tests if the clientStateMachine is in the RollRankingDice + DetermineStartPlayer determineStartPlayer1 = (DetermineStartPlayer) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); + assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); + } + + /** + * UC-ClientState-21: Test the transition from DetermineStartPlayer to Wait. + */ + @Test + public void testDetermineStartPlayerToWait() { + // Todo Implementation goes here + } + + /** + * UC-ClientState-22: Test the transition from Wait to Animation. + */ + @Test + public void testWaitToAnimation() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the client in WaitState + 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(gameStateMachine.getState() instanceof Animation); + + //sends the client in WaitState + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); + + //tests if a powerCard is played,that the client goes into Animation + clientGameLogic.receive(playCardTurbo); //Todo ??? richtige message + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Animation); + + //sends the client in WaitState + 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(gameStateMachine.getState() instanceof Animation); + } + + /** + * UC-ClientState-23: Test the transition from Wait to Turn. + */ + @Test + public void testWaitToTurn() { + //sends client in gameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Waiting + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); + + //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(gameStateMachine.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() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + } + + /** + * UC-ClientState-32: Test the transition from PlayPowerCard to RollDice. + */ + @Test + public void testPlayPowerCardToRollDice() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + } + + /** + * 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() { + + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + } + + /** + * UC-ClientState-43: Test the transition from ChoosePowerCard to Swap. + */ + @Test + public void testChoosePowerCardToSwap() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof Swap); + } + + /** + * UC-ClientState-44: Test the transition from ChoosePowerCard to Shield. + */ + @Test + public void testChoosePowerCardToShield() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof Shield); + } + + /** + * UC-ClientState-45: Test staying in the Shield state. + */ + @Test + public void testStayInShield() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof PlayPowerCard); + } + + /** + * UC-ClientState-46: Test the transition from Shield to PowerCardEndState. + */ + @Test + public void testShieldToPowerCardEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in 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); + + //todo send the message to force the statechange + + //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + } + + /** + * UC-ClientState-47: Test the transition from Swap to PowerCardEndState. + */ + @Test + public void testSwapToPowerCardEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + } + + /** + * UC-ClientState-48: Test no piece in WaitingPiece state. + */ + @Test + public void testNoPieceInWaitingPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + turnStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message WaitPiece + clientGameLogic.receive(waitPiece); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + } + + /** + * UC-ClientState-49: Test no piece in SelectedPiece state. + */ + @Test + public void testNoPieceInSelectedPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message SelectPiece + clientGameLogic.receive(selectPiece); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + } + + /** + * UC-ClientState-50: Test no piece in StartPiece state. + */ + @Test + public void testNoPieceInStartPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message StartPiece + clientGameLogic.receive(startPiece); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + } + + /** + * UC-ClientState-51: Test no piece in Wait state. + */ + @Test + public void testNoPieceInWait() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message NoTurn + clientGameLogic.receive(noTurn); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof Waiting); + } + + /** + * UC-ClientState-52: Test staying in the WaitingPiece state. + */ + @Test + public void testStayInWaitingPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + } + + /** + * UC-ClientState-53: Test the WaitingPiece to ChoosePiece end state. + */ + @Test + public void testWaitingPieceInChoosePieceEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); + } + + /** + * UC-ClientState-54: Test staying in the SelectedPiece state. + */ + @Test + public void testStayInSelectedPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + } + + /** + * UC-ClientState-55: Test the SelectedPiece to ChoosePiece end state. + */ + @Test + public void testSelectedPieceInChoosePieceEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in SelectPiece + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + + //Todo send the message which force a state change + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); + } + + /** + * UC-ClientState-56: Test staying in the StartPiece state. + */ + @Test + public void testStayInStartPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in 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(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + } + + /** + * UC-ClientState-57: Test the StartPiece to ChoosePiece end state. + */ + @Test + public void testStartPieceToChoosePieceEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + + //Todo send the message which force a state change + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); + } + + /** + * 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/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..f410785c --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -0,0 +1,1097 @@ +package pp.mdga.server.serverState; + +import org.junit.Before; +import org.junit.Test; +import pp.mdga.game.Game; +import pp.mdga.message.server.ServerMessage; +import pp.mdga.server.*; +import pp.mdga.server.automaton.CeremonyState; +import pp.mdga.server.automaton.InterruptState; +import pp.mdga.server.automaton.LobbyState; +import pp.mdga.server.automaton.ServerAutomaton; + +import static org.junit.Assert.*; + +/** + * this test-class tests the Testcases T132-T169 + */ +public class ServerStateTest { + + //Todo + 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; + + //Todo + private int from; + private int fromHost; + + //Todo + private GameStateMachine gameStateMachine; + private TurnStateMachine turnStateMachine; + private RollDiceMachine rollDiceMachine; + private ChoosePieceStateMachine choosePieceStateMachine; + private ServerAutomaton serverAutomaton; + + //TODO + private Animation animation; + private CeremonyState ceremonyState; + private ChoosePieceState choosePieceState; + private DetermineStartPlayerState determineStartPlayerState; + private FirstRollStateState firstRollState; + private GameState gameState; + private InterruptState interruptState; + private LobbyState lobbyState; + private MovePieceState movePieceState; + private NoPieceState noPiece; + private NoTurnState noTurnState; + private PlayPowerCard playPowerCard; + private PowerCardState powerCardState; + private RollDiceState rollDiceState; + private SecondRollState secondRoll; + private SelectPieceState selectPiece; + private StartPieceState startPiece; + private ThirdRollState thirdRoll; + private TurnState turnState; + private WaitingPieceState waitingPiece; + + /** + * TODO + */ + @Before + 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; + fromHost = 2345; + + choosePieceStateMachine = choosePieceState.getChoosePieceMachine(); + rollDiceMachine = rollDiceState.getRollDicemachine(); + turnStateMachine = turnState.getTurnStatemachine(); + serverAutomaton = logic.getServerAutomaton(); + gameStateMachine = gameState.getGameStatemachine(); + + thirdRoll = new ThirdRollState(rollDiceMachine, logic); + secondRoll = new SecondRollState(rollDiceMachine, logic); + firstRollState = new FirstRollStateState(rollDiceMachine, logic); + + noPiece = new NoPieceState(choosePieceStateMachine, logic); + noTurnState = new NoTurnState(choosePieceStateMachine, logic); + waitingPiece = new WaitingPieceState(choosePieceStateMachine, logic); + startPiece = new StartPieceState(choosePieceStateMachine, logic); + selectPiece = new SelectPieceState(choosePieceStateMachine, logic); + + powerCardState = new PowerCardState(turnStateMachine, logic); + playPowerCard = new PlayPowerCard(turnStateMachine, logic); + rollDiceState = new RollDiceState(turnStateMachine, logic); + choosePieceState = new ChoosePieceState(turnStateMachine, logic); + movePieceState = new MovePieceState(turnStateMachine, logic); + + determineStartPlayerState = new DetermineStartPlayerState(gameStateMachine, logic); + turnState = new TurnState(gameStateMachine, logic); + animation = new Animation(gameStateMachine, logic); + + lobbyState = new LobbyState(serverAutomaton, logic); + gameState = new GameState(serverAutomaton, logic); + ceremonyState = new CeremonyState(serverAutomaton, logic); + interruptState = new InterruptState(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 LobbyState); + } + + /** + * 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 + serverAutomaton.gotoState(lobbyState); + assertTrue(serverAutomaton.getState() instanceof LobbyState); + + //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 DetermineStartPlayerState); + } + + /** + * this method tests, that the server stays in the Lobby + */ + @Test + public void testStayInLobby() { + //sends the server in the lobby-state + serverAutomaton.gotoState(lobbyState); + assertTrue(serverAutomaton.getState() instanceof LobbyState); + + //TODO 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(serverAutomaton.getState() instanceof LobbyState); + } + + /** + * this method tests, that the server can go into the interrupt-state + */ + @Test + public void testServerGameSubStatesToInterrupt() { + //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 InterruptState); + } + + /** + * tests the state-change from Game to Ceremony if the Game is finished + */ + @Test + public void testServerGameToCeremony() { + //sends the server in the gameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //Todo game is finished + + //tests if the server is in the Ceremony-state + assertTrue(serverAutomaton.getState() instanceof CeremonyState); + } + + /** + * 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 + serverAutomaton.gotoState(interruptState); + assertTrue(serverAutomaton.getState() instanceof InterruptState); + + //sends the continue-message to the server + logic.received(forceContinueGame, from); + + //tests if new Stet is in GameState + 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 + serverAutomaton.gotoState(interruptState); + assertTrue(serverAutomaton.getState() instanceof InterruptState); + + //todo implement the timer + + //tests if new Stet is in GameState + 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 + serverAutomaton.gotoState(interruptState); + assertTrue(serverAutomaton.getState() instanceof InterruptState); + + //Todo implement the timer + + //tests if new Stet is in GameState + 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 + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayerState); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState); + + //TODO sends messages to the server + + //tests if the server is still in DSP-state + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState); + } + + /** + * 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 + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayerState); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState); + + //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 DetermineStartPlayerState); + } + + /** + * 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 + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayerState); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState); + + //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); + } + + /** + * 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 + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Animation + gameStateMachine.gotoState(animation); + assertTrue(gameStateMachine.getState() instanceof Animation); + + //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 TurnState); + TurnState turnState1 = (TurnState) gameStateMachine.getState(); + TurnStateMachine turnStateMachine = (TurnStateMachine) turnState1.getTurnStateMachine(); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + } + + /** + * 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 + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //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); + } + + /** + * 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 + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //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 CeremonyState); + } + + /** + * 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 + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(powerCardState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + } + + /** + * Tests the transition from PowerCard state to PlayPowerCard state. + * UC-ServerState-17 + */ + @Test + public void testPowerCardToPlayPowerCard() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(powerCardState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + + //todo + + //tests if the server is in PlayPowerCard + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + } + + /** + * Tests the transition from PlayPowerCard state to RollDice state. + * UC-ServerState-18 + */ + @Test + public void testPlayPowerCardToRollDice() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //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 TurnState); + 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 TurnState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + RollDiceState rollDiceState = (RollDiceState) turnStateMachine.getState(); + RollDiceMachine rollDiceMachine1 = rollDiceState.getRollDiceStateMachine(); + assertTrue(rollDiceMachine1.getState() instanceof FirstRollStateState); + } + + /** + * Tests the transition from ChoosePiece state to MovePiece state. + * UC-ServerState-19 + */ + @Test + public void testChoosePieceToMovePiece() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //Todo ??? + + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof MovePieceState); + } + + /** + * Tests the transition from MovePiece state to TurnEndState. + * UC-ServerState-20 + */ + @Test + public void testMovePieceToTurnEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in MovePiece + turnStateMachine.gotoState(movePieceState); + assertTrue(turnStateMachine.getState() instanceof MovePieceState); + + //Todo no 6 was rolled, so the server looks, if there are 2 or less player are still in the game + //TODO + + } + + /** + * Tests the transition from MovePiece state to FirstRoll state. + * UC-ServerState-21 + */ + @Test + public void testMovePieceToFirstRoll() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in MovePiece + turnStateMachine.gotoState(movePieceState); + assertTrue(turnStateMachine.getState() instanceof MovePieceState); + + //Todo the player rolled a 6 and the player is not finished + + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + RollDiceState rollDiceState = (RollDiceState) turnStateMachine.getState(); + RollDiceMachine rollDiceMachine1 = rollDiceState.getRollDiceStateMachine(); + assertTrue(rollDiceMachine1.getState() instanceof FirstRollStateState); + } + + /** + * Tests the transition from FirstRoll state to RollDiceEndState. + * UC-ServerState-22 + */ + @Test + public void testFirstRollToRollDiceEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDiceState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + + //sends the RollDiceMachine in FirstRoll + rollDiceMachine.gotoState(firstRollState); + assertTrue(rollDiceMachine.getState() instanceof FirstRollStateState); + + //TODO 2 Möglichkeiten + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + } + + /** + * Tests the transition from FirstRoll state to SecondRoll state. + * UC-ServerState-23 + */ + @Test + public void testFirstRollToSecondRoll() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDiceState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + + //sends the RollDiceMachine in FirstRoll + rollDiceMachine.gotoState(firstRollState); + assertTrue(rollDiceMachine.getState() instanceof FirstRollStateState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + assertTrue(rollDiceMachine.getState() instanceof SecondRollState); + } + + /** + * Tests the transition from SecondRoll state to RollDiceEndState. + * UC-ServerState-24 + */ + @Test + public void testSecondRollToRollDiceEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDiceState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + + //sends the RollDiceMachine in SecondRoll + rollDiceMachine.gotoState(secondRoll); + assertTrue(rollDiceMachine.getState() instanceof SecondRollState); + + //Todo + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + } + + /** + * Tests the transition from SecondRoll state to ThirdRoll state. + * UC-ServerState-25 + */ + @Test + public void testSecondRollToThirdRoll() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDiceState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + + //sends the RollDiceMachine in SecondRoll + rollDiceMachine.gotoState(secondRoll); + assertTrue(rollDiceMachine.getState() instanceof SecondRollState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + assertTrue(rollDiceMachine.getState() instanceof ThirdRollState); + } + + /** + * Tests the transition from ThirdRoll state to RollDiceEndState. + * UC-ServerState-26 + */ + @Test + public void testThirdRollToRollDiceEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDiceState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + + //sends the RollDiceMachine in ThirdRoll + rollDiceMachine.gotoState(thirdRoll); + assertTrue(rollDiceMachine.getState() instanceof ThirdRollState); + + //Todo + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + } + + /** + * Tests the transition from ThirdRoll state to TurnEndState. + * UC-ServerState-27 + */ + @Test + public void testThirdRollToTurnEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDiceState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + + //sends the RollDiceMachine in ThirdRoll + rollDiceMachine.gotoState(thirdRoll); + assertTrue(rollDiceMachine.getState() instanceof ThirdRollState); + + //Todo + } + + /** + * Tests the transition from NoPiece state to WaitingPiece state. + * UC-ServerState-28 + */ + @Test + public void testNoPieceToWaitingPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + + //TODO + + //tests if the server is in WaitingPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + + } + + /** + * Tests the transition from NoPiece state to NoTurn state. + * UC-ServerState-29 + */ + @Test + public void testNoPieceToNoTurn() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + + //TODO + + //tests if the server is in NoTurn + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof NoTurnState); + } + + /** + * Tests the transition from NoTurn state to TurnEndState. + * UC-ServerState-30 + */ + @Test + public void testNoTurnToTurnEndState() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in NoTurn + choosePieceStateMachine.gotoState(noTurnState); + assertTrue(choosePieceStateMachine.getState() instanceof NoTurnState); + + //TODO + } + + /** + * Tests that the system stays in the WaitingPiece state. + * UC-ServerState-31 + */ + @Test + public void testStayInWaitingPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in WaitingPiece + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + + //TODO + + //tests if the server is in WaitingPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + } + + /** + * Tests the transition from WaitingPiece state to MovePiece state. + * UC-ServerState-32 + */ + @Test + public void testWaitingPieceToMovePiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in WaitingPiece + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + + //TODO + } + + /** + * Tests the transition from NoPiece state to SelectPiece state. + * UC-ServerState-33 + */ + @Test + public void testNoPieceToSelectPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + + //TODO + + //tests if the server is in SelectPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + } + + /** + * Tests the transition from NoPiece state to StartPiece state. + * UC-ServerState-34 + */ + @Test + public void testNoPieceToStartPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + + //TODO + + //tests if the server is in StartPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + } + + /** + * Tests that the system stays in the SelectPiece state. + * UC-ServerState-35 + */ + @Test + public void testStayInSelectPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in SelectPiece + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + + //TODO + + //tests if the server is in SelectPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + } + + /** + * Tests the transition from SelectPiece state to MovePiece state. + * UC-ServerState-36 + */ + @Test + public void testSelectPieceToMovePiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in SelectPiece + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + + //TODO + } + + /** + * Tests that the system stays in the StartPiece state. + * UC-ServerState-37 + */ + @Test + public void testStayInStartPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + + //TODO + + //tests if the server is in StartPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + } + + /** + * Tests the transition from StartPiece state to MovePiece state. + * UC-ServerState-38 + */ + @Test + public void testStartPieceToMovePiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the server in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + + //TODO + } +}