diff --git a/Projekte/mdga/client/hs_err_pid112363.log b/Projekte/mdga/client/hs_err_pid112363.log new file mode 100644 index 00000000..7e7c369f --- /dev/null +++ b/Projekte/mdga/client/hs_err_pid112363.log @@ -0,0 +1,32 @@ +# +# A fatal error has been detected by the Java Runtime Environment: +# +# SIGSEGV (0xb) at pc=0x000076fb04e70b48, pid=112363, tid=112397 +# +# JRE version: OpenJDK Runtime Environment Temurin-20.0.2+9 (20.0.2+9) (build 20.0.2+9) +# Java VM: OpenJDK 64-Bit Server VM Temurin-20.0.2+9 (20.0.2+9, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64) +# Problematic frame: +# C [libLLVM.so.18.1+0x1070b48] llvm::EVT::isExtendedVector() const+0x8 +# +# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/cedric/ProgProjekt/Gruppe-01/Projekte/mdga/client/core.112363) +# +# If you would like to submit a bug report, please visit: +# https://github.com/adoptium/adoptium-support/issues +# The crash happened outside the Java Virtual Machine in native code. +# See problematic frame for where to report the bug. +# + +--------------- S U M M A R Y ------------ + +Command Line: -Ddebugger.agent.enable.coroutines=true -Djava.util.logging.config.file=logging.properties -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=127.0.0.1:37129 -javaagent:/usr/share/idea/plugins/java/lib/rt/debugger-agent.jar -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea pp.mdga.client.MdgaApp + +Host: AMD Ryzen 5 8640HS w/ Radeon 760M Graphics, 12 cores, 14G, Manjaro Linux +Time: Fri Nov 29 22:02:46 2024 CET elapsed time: 26.893420 seconds (0d 0h 0m 26s) + +--------------- T H R E A D --------------- + +Current thread (0x000076fbec5e6dd0): JavaThread "jME3 Main" [_thread_in_native, id=112397, stack(0x000076fbd00fe000,0x000076fbd01fe000)] + +Stack: [0x000076fbd00fe000,0x000076fbd01fe000], sp=0x000076fbd01f4ef8, free space=987k +Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) +C [libLLVM.so.18.1+0x1070b48] llvm::EVT::isExtendedVector() const+0x8 \ No newline at end of file diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java index 9af83440..895042a3 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java @@ -75,7 +75,7 @@ public void onAction(String name, boolean isPressed, float tpf) { } if(name.equals("Click") && isPressed) { if (app.getView() instanceof GameView gameView) { - CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayer().getRootNode(), CardControl.class); + CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class); OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class); if(cardLayerSelect != null) { @@ -100,9 +100,6 @@ else if(boardSelect != null) { } if(name.equals("Test") &&isPressed){ if(app.getView() instanceof GameView gameView){ - - gameView.getGuiHandler().showDice(); -// gameView.getBoardHandler().showDice(Color.AIRFORCE); } } } @@ -134,8 +131,8 @@ private T checkHover(Camera cam, Node root, Class CollisionResults results = new CollisionResults(); Ray ray = new Ray(cam.getLocation(), getMousePos(cam).subtract(cam.getLocation()).normalize()); root.collideWith(ray, results); - if (results.size() > 0) { - return results.getClosestCollision().getGeometry().getControl(controlType); + for(CollisionResult collisionResult : results){ + if(collisionResult.getGeometry().getControl(controlType) != null) return collisionResult.getGeometry().getControl(controlType); } return null; } @@ -188,7 +185,7 @@ private PieceControl checkPiece(){ } private CardControl checkCard(GameView gameView){ - return checkHoverOrtho(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayer().getRootNode(), CardControl.class); + return checkHoverOrtho(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class); } private void pieceOff(){ diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java index 8c3cd992..fc972ef0 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java @@ -12,7 +12,7 @@ public class MdgaApp extends SimpleApplication { private AcousticHandler acousticHandler; private NotificationSynchronizer notificationSynchronizer; private InputSynchronizer inputSynchronizer; - private ModelSyncronizer modelSyncronizer; + private ModelSynchronizer modelSynchronizer; MdgaView view = null; private MdgaState state = null; @@ -50,7 +50,7 @@ public void simpleInitApp() { acousticHandler = new AcousticHandler(this); notificationSynchronizer = new NotificationSynchronizer(this); inputSynchronizer = new InputSynchronizer(this); - modelSyncronizer = new ModelSyncronizer(this); + modelSynchronizer = new ModelSynchronizer(this); mainView = new MainView(this); lobbyView = new LobbyView(this); @@ -114,11 +114,11 @@ public MdgaView getView() { return view; } - public ModelSyncronizer getModelSyncronizer() { - return modelSyncronizer; + public ModelSynchronizer getModelSynchronize() { + return modelSynchronizer; } - public InputSynchronizer getInputSyncronizer() { return inputSynchronizer; } + public InputSynchronizer getInputSynchronize() { return inputSynchronizer; } public NotificationSynchronizer getNotificationSynchronizer() { return notificationSynchronizer; } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSyncronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java similarity index 92% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSyncronizer.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java index 0f7e980c..39b6ea7e 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSyncronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java @@ -14,15 +14,15 @@ import java.util.logging.Level; import java.util.logging.Logger; -public class ModelSyncronizer { - private static final Logger LOGGER = Logger.getLogger(ModelSyncronizer.class.getName()); +public class ModelSynchronizer { + private static final Logger LOGGER = Logger.getLogger(ModelSynchronizer.class.getName()); private MdgaApp app; private UUID a; private UUID b; private BonusCard card; - ModelSyncronizer(MdgaApp app) { + ModelSynchronizer(MdgaApp app) { this.app = app; } @@ -31,6 +31,7 @@ public void animationEnd() { } public void selectSwap(UUID a, UUID b) { + // TODO call from somewhere LOGGER.log(Level.INFO, "selectPiece"); this.a = a; this.b = b; @@ -44,6 +45,7 @@ public void selectSwap(UUID a, UUID b) { } public void selectPiece(UUID piece) { + // TODO call from somewhere LOGGER.log(Level.INFO, "selectPiece"); this.a = piece; @@ -57,6 +59,7 @@ public void selectPiece(UUID piece) { } public void selectCard(BonusCard card) { + // TODO call from somewhere LOGGER.log(Level.INFO, "selectCard"); this.card = card; @@ -91,20 +94,24 @@ public void confirm() { } public void selectTsk(Color color) { + // TODO call from somewhere LOGGER.log(Level.INFO, "selectTsk: {0}", color); LobbyView view = (LobbyView) app.getView(); view.setTaken(color, true, true, "OwnPlayerName"); } public void unselectTsk() { + // TODO call from somewhere LOGGER.log(Level.INFO, "unselectTsk"); } public void rolledDice() { + // TODO call from somewhere LOGGER.log(Level.INFO, "rolledDice"); } public void setName(String name) { + // TODO call from somewhere LOGGER.log(Level.INFO, "setName: {0}", name); } @@ -114,11 +121,13 @@ public void setReady() { } public void setHost(int port) { + // TODO call from somewhere LOGGER.log(Level.INFO, "setHost: {0}", port); enter(MdgaState.LOBBY); } public void setJoin(String ip, int port) { + // TODO call from somewhere LOGGER.log(Level.INFO, "setJoin with IP: {0}, Port: {1}", new Object[]{ip, port}); enter(MdgaState.LOBBY); } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java index 25cd9f56..70b0a2bd 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java @@ -57,11 +57,12 @@ private void handleMain(Notification notification) { private void handleLobby(Notification notification) { LobbyView lobbyView = (LobbyView) app.getView(); - if (notification instanceof TskSelectNotification tskSelectNotification) { - lobbyView.setTaken(tskSelectNotification.getColor(), true, tskSelectNotification.isSelf(), tskSelectNotification.getName()); - } else if (notification instanceof TskUnselectNotification tskUnselectNotification) { - lobbyView.setTaken(tskUnselectNotification.getColor(), false, false, null); - //} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) { + if (notification instanceof TskSelectNotification n) { + //lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName()); + lobbyView.setTaken(n.getColor(), true, true, n.getName()); + } else if (notification instanceof TskUnselectNotification n) { + lobbyView.setTaken(n.getColor(), false, false, null); + //} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) { // lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()): } else if (notification instanceof GameNotification) { app.enter(MdgaState.GAME); @@ -75,12 +76,12 @@ private void handleGame(Notification notification) { GuiHandler guiHandler = gameView.getGuiHandler(); BoardHandler boardHandler = gameView.getBoardHandler(); - if (notification instanceof AcquireCardNotification n) { - guiHandler.addCard(n.getBonusCard(), n.getCardId()); + if (notification instanceof AcquireCardNotification) { + // Handle AcquireCardNotification } else if (notification instanceof ActivePlayerNotification n) { gameView.getGuiHandler().setActivePlayer(n.getColor()); } else if (notification instanceof CeremonyNotification ceremonyNotification) { - app.enter(MdgaState.CEREMONY); + /*app.enter(MdgaState.CEREMONY); CeremonyView ceremonyView = (CeremonyView) app.getView(); int size = ceremonyNotification.getNames().size(); @@ -105,17 +106,18 @@ private void handleGame(Notification notification) { ceremonyView.addCeremonyParticipant(color, i, name); ceremonyView.addStatisticsRow(name, v1, v2, v3, v4, v5, v6); - } + }*/ } else if (notification instanceof DiceNowNotification) { guiHandler.showDice(); } else if (notification instanceof DicingNotification n) { - //TODO - } else if (notification instanceof DrawCardNotification n) { //TODO ??? + } else if (notification instanceof DrawCardNotification n) { + guiHandler.drawCard(n.getColor()); } else if (notification instanceof HomeMoveNotification home) { boardHandler.moveHomePiece(home.getPieceId(), home.getHomeIndex()); + guiHandler.hideText(); } else if (notification instanceof InterruptNotification) { - //TODO + //TODO ??? } else if (notification instanceof MovePieceNotification n) { if(n.isMoveStart()) { //StartMove @@ -138,11 +140,17 @@ private void handleGame(Notification notification) { } } else if (notification instanceof PlayerInGameNotification n) { boardHandler.addPlayer(n.getColor(),n.getPiecesList()); - guiHandler.addPlayer(n.getColor(),n.getName(), gameView.getOwnColor() == n.getColor()); + guiHandler.addPlayer(n.getColor(),n.getName()); } else if (notification instanceof ResumeNotification) { + //TODO } else if (notification instanceof RollDiceNotification n) { - guiHandler.rollDice(n.getEyes()); - //TODO multiplicator + if(n.getColor() == gameView.getOwnColor()){ + //guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1); + } + else { + //if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor()); + //else guiHandler.showRolledDice(n.getEyes(), n.getColor()); + } } else if (notification instanceof SelectableCardsNotification n) { guiHandler.setSelectableCards(n.getCards()); } else if (notification instanceof ShieldActiveNotification n) { @@ -153,12 +161,17 @@ private void handleGame(Notification notification) { app.enter(MdgaState.MAIN); } else if (notification instanceof SwapPieceNotification n) { boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece()); + guiHandler.swap(); } else if (notification instanceof WaitMoveNotification) { - //TODO disable all hover, highlight, etc + //TODO ??? } else if (notification instanceof SelectableMoveNotification n) { boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves()); } else if (notification instanceof SelectableSwapNotification n) { boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces()); + // } //else if (notification instanceof SelectableShieldNotification n) { + // boardHandler.outlineShield(n.getOwnPieces()); + //} else if (notification instanceof TurboActiveNotification){ + // guiHandler.turbo(); } else { throw new RuntimeException("notification not expected: " + notification.toString()); } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java index bca76696..475092c5 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java @@ -21,9 +21,6 @@ public class BoardHandler { private final MdgaApp app; - private final PileControl drawPile = null; - private final PileControl discardPile = null; - private ArrayList infield; private Map pieces; @@ -32,32 +29,46 @@ public class BoardHandler { private Map> waitingNodesMap; private Map> waitingPiecesMap; private Map pieceColor; - private Set outlineControls; private Node node = new Node(); - private Node rootNode; + private final Node rootNode; - private FilterPostProcessor fpp; + private final FilterPostProcessor fpp; private boolean isInitialised; - private List selectableOwnPieces = new ArrayList<>(); - private List selectableEnemyPieces = new ArrayList<>(); + private List selectableOwnPieces; + private List selectableEnemyPieces; + private List outlineNodes; private PieceControl selectedOwnPiece; private PieceControl selectedEnemyPiece; private DiceControl diceControl; - public BoardHandler(MdgaApp app, Node node3d, FilterPostProcessor fpp) { + public BoardHandler(MdgaApp app, Node rootNode, FilterPostProcessor fpp) { if(app == null) throw new RuntimeException("app is null"); - this.isInitialised = false; this.app = app; - this.rootNode = node3d; this.fpp = fpp; - selectedEnemyPiece = null; - selectedOwnPiece = null; + this.rootNode = rootNode; + isInitialised = false; + } + public void init() { + isInitialised = true; + selectableOwnPieces = new ArrayList<>(); + selectableEnemyPieces = new ArrayList<>(); + outlineNodes = new ArrayList<>(); + selectedOwnPiece = null; + selectedEnemyPiece = null; initMap(); + rootNode.attachChild(node); + } + + public void shutdown(){ + clearSelectable(); + isInitialised = false; + initMap(); + rootNode.detachChild(node); } private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) { @@ -66,21 +77,16 @@ private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) { } private void initMap() { - this.node = new Node("Asset Node"); - this.pieces = new HashMap<>(); - this.colorAssetsMap = new HashMap<>(); - this.infield = new ArrayList<>(40); - this.homeNodesMap = new HashMap<>(); - this.waitingNodesMap = new HashMap<>(); - this.waitingPiecesMap = new HashMap<>(); - this.pieceColor = new HashMap<>(); - this.outlineControls = new HashSet<>(); - - // Initialize dice + pieces = new HashMap<>(); + colorAssetsMap = new HashMap<>(); + infield = new ArrayList<>(40); + homeNodesMap = new HashMap<>(); + waitingNodesMap = new HashMap<>(); + waitingPiecesMap = new HashMap<>(); + pieceColor = new HashMap<>(); diceControl = new DiceControl(app.getAssetManager()); - diceControl.create(new Vector3f(0, 0, 0), 0.7f, true); + diceControl.create(new Vector3f(0,0,0), 0.7f, true); - // Load assets and populate the node List assetOnMaps = MapLoader.loadMap(MAP_NAME); for (AssetOnMap assetOnMap : assetOnMaps) { @@ -99,6 +105,7 @@ private void initMap() { case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap); case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap); case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap); + default -> displayAsset(assetOnMap); } } @@ -117,20 +124,14 @@ private Color assetToColor(Asset asset) { private Spatial createModel(Asset asset, Vector3f pos, float rot) { String modelName = asset.getModelPath(); String texName = asset.getDiffPath(); - - // Load the model Spatial model = app.getAssetManager().loadModel(modelName); model.scale(asset.getSize()); model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot)); model.setLocalTranslation(pos); model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); - - // Set material Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName)); model.setMaterial(mat); - - // Attach to the asset node node.attachChild(model); return model; @@ -169,7 +170,7 @@ private float getRotationMove(Vector3f prev, Vector3f next) { return newRot; } - private void movePiece_rek(UUID uuid, int curIndex, int moveIndex){ + private void movePieceRek(UUID uuid, int curIndex, int moveIndex){ if (curIndex == moveIndex) return; curIndex = (curIndex + 1) % infield.size(); @@ -181,7 +182,7 @@ private void movePiece_rek(UUID uuid, int curIndex, int moveIndex){ movePieceToNode(pieceControl, nodeControl); - movePiece_rek(uuid, curIndex, moveIndex); + movePieceRek(uuid, curIndex, moveIndex); } private List addItemToMapList(Map> map, E key, T item){ @@ -191,11 +192,10 @@ private List addItemToMapList(Map> map, E key, T item){ return list; } - private List removeItemFromMapList(Map> map, E key, T item){ + private void removeItemFromMapList(Map> map, E key, T item){ List list = map.getOrDefault(key, new ArrayList<>()); list.remove(item); map.put(key, list); - return list; } private Vector3f getWaitingPos(Color color){ @@ -274,7 +274,7 @@ public void movePieceStart(UUID uuid, int nodeIndex){ public void movePiece(UUID uuid, int curIndex, int moveIndex){ if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized"); - movePiece_rek(uuid, curIndex, moveIndex); + movePieceRek(uuid, curIndex, moveIndex); } public void throwPiece(UUID uuid){ @@ -313,70 +313,25 @@ public void suppressShield(UUID uuid){ public void swapPieces(UUID piece1, UUID piece2){ if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized"); - PieceControl piece1_control = pieces.get(piece1); - PieceControl piece2_control = pieces.get(piece2); + PieceControl piece1Control = pieces.get(piece1); + PieceControl piece2Control = pieces.get(piece2); - if(piece1_control == null) throw new RuntimeException("piece1 UUID is not valid"); - if(piece2_control == null) throw new RuntimeException("piece2 UUID is not valid"); + if(piece1Control == null) throw new RuntimeException("piece1 UUID is not valid"); + if(piece2Control == null) throw new RuntimeException("piece2 UUID is not valid"); - float rot1 = piece1_control.getRotation(); - float rot2 = piece2_control.getRotation(); + float rot1 = piece1Control.getRotation(); + float rot2 = piece2Control.getRotation(); - piece1_control.setRotation(rot2); - piece2_control.setRotation(rot1); + piece1Control.setRotation(rot2); + piece2Control.setRotation(rot1); - Vector3f pos1 = piece1_control.getLocation().clone(); - Vector3f pos2 = piece2_control.getLocation().clone(); + Vector3f pos1 = piece1Control.getLocation().clone(); + Vector3f pos2 = piece2Control.getLocation().clone(); - piece1_control.setLocation(pos2); - piece2_control.setLocation(pos1); + piece1Control.setLocation(pos2); + piece2Control.setLocation(pos1); } - public void init() { - if (isInitialised) return; - - rootNode.attachChild(node); - - app.getViewPort().addProcessor(fpp); - - isInitialised = true; - } - - public void shutdown() { - if (!isInitialised) return; - - outlineControls.forEach(OutlineControl::deOutline); - outlineControls.clear(); - - rootNode.detachChild(node); - - if (fpp != null) { - app.getViewPort().removeProcessor(fpp); - } - - pieces.clear(); - colorAssetsMap.clear(); - homeNodesMap.clear(); - waitingNodesMap.clear(); - waitingPiecesMap.clear(); - pieceColor.clear(); - - selectableOwnPieces.clear(); - selectableEnemyPieces.clear(); - selectedEnemyPiece = null; - selectedOwnPiece = null; - - if (diceControl != null) { - diceControl.hide(); - } - - isInitialised = false; - - System.gc(); - } - - //List - //List public void highlight(UUID uuid, boolean bool){ if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized"); @@ -385,20 +340,6 @@ public void highlight(UUID uuid, boolean bool){ } - public void deOutline(UUID uuid){ - if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized"); - - pieces.get(uuid).deOutline(); - - outlineControls.remove(pieces.get(uuid)); - } - - public void outline(int index){ -// infield.get(index).outline(); - - outlineControls.add(infield.get(index)); - } - //called when (dice) moveNum is received from server to display the movable pieces and corresponding moveNodes public void outlineMove(List pieces, List moveIndexe, List homeMoves) { if(pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size()) throw new RuntimeException("arrays are not the same size"); @@ -424,6 +365,7 @@ public void outlineMove(List pieces, List moveIndexe, List ownPieces, List enemyPieces){ } } + public void outlineShield(List pieces){ + selectableOwnPieces.clear(); + selectableEnemyPieces.clear(); + selectedOwnPiece = null; + selectedEnemyPiece = null; + + for (UUID uuid : pieces){ + PieceControl p = this.pieces.get(uuid); + p.highlight(false); + p.setHoverable(true); + p.setSelectable(true); + selectableOwnPieces.add(p); + } + } + //called from inputSynchronizer when a piece is selectable public void pieceSelect(PieceControl pieceSelected) { boolean isSelected = pieceSelected.isSelected(); @@ -496,18 +453,16 @@ public void clearSelectable(){ p.unHighlight(); p.setSelectable(false); } + for(NodeControl n : outlineNodes){ + n.deOutline(); + } + outlineNodes.clear(); selectableEnemyPieces.clear(); selectableOwnPieces.clear(); selectedEnemyPiece = null; selectedOwnPiece = null; } - public void deOutline(int index){ - infield.get(index).deOutline(); - - outlineControls.remove(infield.get(index)); - } - public void enableHover(UUID uuid){ pieces.get(uuid).setHoverable(true); } @@ -521,4 +476,6 @@ public void showDice(Color color){ public void hideDice(){ diceControl.hide(); } + + } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/CameraHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/CameraHandler.java index ae55a535..a1c6b8d6 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/CameraHandler.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/CameraHandler.java @@ -7,8 +7,11 @@ import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.post.FilterPostProcessor; +import com.jme3.scene.Spatial; import com.jme3.shadow.DirectionalLightShadowFilter; import com.jme3.shadow.EdgeFilteringMode; +import com.jme3.util.SkyFactory; +import com.jme3.util.SkyFactory.EnvMapType; import pp.mdga.client.MdgaApp; public class CameraHandler { @@ -25,6 +28,8 @@ public class CameraHandler { FilterPostProcessor fpp; DirectionalLightShadowFilter dlsf; + Spatial sky; + public CameraHandler(MdgaApp app, FilterPostProcessor fpp) { this.app = app; this.fpp = fpp; @@ -45,18 +50,24 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) { dlsf.setEnabled(true); dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON); dlsf.setShadowIntensity(0.7f); + fpp.addFilter(dlsf); + + sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f); + + } public void init() { app.getRootNode().addLight(sun); app.getRootNode().addLight(ambient); - + app.getRootNode().attachChild(sky); fpp.addFilter(dlsf); } public void shutdown() { app.getRootNode().removeLight(sun); app.getRootNode().removeLight(ambient); + app.getRootNode().detachChild(sky); // Reset the camera to its default state app.getCamera().setLocation(defaultCameraPosition); @@ -96,4 +107,5 @@ public void update(float scroll, float rotation) { app.getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Z); } + } 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/button/LobbyButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java index 5264327c..3867835f 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java @@ -214,5 +214,6 @@ public void setTaken(Taken taken, String name) { public void setReady(boolean isReady) { this.isReady = isReady; + onUnHover(); } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java index 261ce033..d21296d0 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java @@ -5,43 +5,20 @@ import com.jme3.scene.Node; import pp.mdga.client.MdgaApp; import pp.mdga.client.button.AbstractButton; -import pp.mdga.client.button.InputButton; import pp.mdga.client.button.LabelButton; import pp.mdga.client.button.MenuButton; -import pp.mdga.client.view.MainView; import java.util.ArrayList; public class CeremonyDialog extends Dialog { private ArrayList> labels; - float offsetX = 0.5f; + float offsetX; public CeremonyDialog(MdgaApp app, Node node) { super(app, node); - labels = new ArrayList<>(); - - ArrayList first = new ArrayList<>(); - Vector2f size = new Vector2f(4, 1.2f); - first.add(new LabelButton(app, node, "", size, new Vector2f())); - first.add(new LabelButton(app, node, "Figuren geworfen", size, new Vector2f())); - first.add(new LabelButton(app, node, "Figuren verloren", size, new Vector2f())); - first.add(new LabelButton(app, node, "Verwendete Bonuskarten", size, new Vector2f())); - first.add(new LabelButton(app, node, "Gewürfelte 6en", size, new Vector2f())); - first.add(new LabelButton(app, node, "Gelaufene Felder", size, new Vector2f())); - first.add(new LabelButton(app, node, "Bonusfeldern erreicht", size, new Vector2f())); - - float offsetY = 0.5f; - - for (LabelButton b : first) { - b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetY)); - offsetY += 0.8f; - } - - offsetX += 2.3f; - - labels.add(first); + prepare(); } @Override @@ -98,4 +75,31 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5 labels.add(row); } + + public void prepare() { + offsetX = 0.5f; + + labels = new ArrayList<>(); + + ArrayList first = new ArrayList<>(); + Vector2f size = new Vector2f(4, 1.2f); + first.add(new LabelButton(app, node, "", size, new Vector2f())); + first.add(new LabelButton(app, node, "Figuren geworfen", size, new Vector2f())); + first.add(new LabelButton(app, node, "Figuren verloren", size, new Vector2f())); + first.add(new LabelButton(app, node, "Verwendete Bonuskarten", size, new Vector2f())); + first.add(new LabelButton(app, node, "Gewürfelte 6en", size, new Vector2f())); + first.add(new LabelButton(app, node, "Gelaufene Felder", size, new Vector2f())); + first.add(new LabelButton(app, node, "Bonusfeldern erreicht", size, new Vector2f())); + + float offsetY = 0.5f; + + for (LabelButton b : first) { + b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetY)); + offsetY += 0.8f; + } + + offsetX += 2.3f; + + labels.add(first); + } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/ActionTextHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/ActionTextHandler.java index 1e643351..e27686c1 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/ActionTextHandler.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/ActionTextHandler.java @@ -8,54 +8,121 @@ import com.jme3.scene.Node; import com.jme3.system.AppSettings; import pp.mdga.client.Asset; +import pp.mdga.game.Color; public class ActionTextHandler { - private Node node; + private Node root; + private BitmapFont font; + private AppSettings appSettings; - private Node textWithSpacing; + public ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){ + root = new Node("actionTextRoot"); + guiNode.attachChild(root); - public ActionTextHandler(AppSettings appSettings, AssetManager assetManager, Node node){ - BitmapFont playerFont = assetManager.loadFont("Fonts/Gunplay.fnt"); + root.setLocalTranslation(center(appSettings.getWidth(), appSettings.getHeight(), Vector3f.ZERO)); + font = assetManager.loadFont("Fonts/Gunplay.fnt"); + this.appSettings = appSettings; - textWithSpacing = createTextWithSpacing(playerFont, "TEST", 20f, 250); - - textWithSpacing.setLocalTranslation(center(appSettings.getWidth(), appSettings.getHeight(), Vector3f.ZERO)); } - public void show () { - node.attachChild(textWithSpacing); - } + private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) { + if(textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length"); - public void hide() { - node.detachChild(textWithSpacing); - } - - private static Node createTextWithSpacing(BitmapFont font, String text, float spacing, float size) { Node textNode = new Node("TextWithSpacing"); Node center = new Node(); float xOffset = 0; + for(int i = 0; i < textArr.length; i++){ + String text = textArr[i]; + ColorRGBA color = colorArr[i]; + for (char c : text.toCharArray()) { + BitmapText letter = new BitmapText(font); + letter.setColor(color); + letter.setSize(size); + letter.setText(Character.toString(c)); + letter.setLocalTranslation(xOffset, letter.getHeight()/2, 0); + center.attachChild(letter); - for (char c : text.toCharArray()) { - BitmapText letter = new BitmapText(font); - letter.setSize(size); - letter.setText(Character.toString(c)); - letter.setLocalTranslation(xOffset, letter.getHeight()/2, 0); - center.attachChild(letter); - - xOffset += letter.getLineWidth() + spacing; + xOffset += letter.getLineWidth() + spacing; + } } + center.setLocalTranslation(new Vector3f(-xOffset/2,0,0)); textNode.attachChild(center); - return textNode; } + private Node createTextWithSpacing(String text, float spacing, float size, ColorRGBA color) { + return createTextWithSpacing(new String[]{text}, spacing, size, new ColorRGBA[]{color}); + } + private Vector3f center(float width, float height, Vector3f pos){ return new Vector3f(pos.x+width/2, pos.y+height/2,0); } + private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top){ + return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top); + } + + private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top){ + Node text = createTextWithSpacing(name, spacing, size, color); + text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0); + root.attachChild(text); + return text; + } + private Vector3f centerText(float width, float height, Vector3f pos){ return center(-width, height, pos); } + public void activePlayer(String name, Color color){ + createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); + } + + public void ownActive(Color color){ + createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); + } + + public void diceNum(int diceNum, String name, Color color){ + createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0); + + createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 100); + + } + + public void diceNumMult(int diceNum,int mult, String name, Color color){ + createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0); + + createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100); + } + + public void ownDice(int diceNum){ + createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0); + } + + public void ownDiceMult(int diceNum, int mult){ + createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 0); + } + + public void drawCard(String name, Color color){ + createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); + } + + public void drawCardOwn(Color color){ + createTopText(new String[]{"Du"," erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); + } + + private ColorRGBA playerColorToColorRGBA(Color color){ + return switch (color){ + case ARMY -> ColorRGBA.Green; + case NAVY -> ColorRGBA.Blue; + case CYBER -> ColorRGBA.Orange; + case AIRFORCE -> ColorRGBA.Black; + }; + } + + public void hide(){ + root.detachAllChildren(); + } + + } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/CardLayerHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/CardLayerHandler.java new file mode 100644 index 00000000..81df1da7 --- /dev/null +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/CardLayerHandler.java @@ -0,0 +1,214 @@ +package pp.mdga.client.gui; + +import com.jme3.material.Material; +import com.jme3.math.Vector3f; +import com.jme3.post.FilterPostProcessor; +import com.jme3.renderer.Camera; +import com.jme3.renderer.queue.RenderQueue; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.texture.Texture2D; +import pp.mdga.client.Asset; +import pp.mdga.client.MdgaApp; +import pp.mdga.game.BonusCard; + +import java.util.*; + +public class CardLayerHandler { + private static final Vector3f START = new Vector3f(-1.8f, -3.5f, 0); + private static final Vector3f MARGIN = new Vector3f(1.8f, 0, 0); + private static final float CARDLAYER_CAMERA_ZOOM = 4; + + private final MdgaApp app; + private final FilterPostProcessor fpp; + private final Texture2D backTexture; + + private Camera cardLayerCamera; + private CardLayer cardLayer; + private DiceControl diceControl; + + private final Map bonusCardControlMap = new HashMap<>(); + private final Map bonusCardIntegerMap = new HashMap<>(); + private final Set selectableCards = new HashSet<>(); + + private BonusCard cardSelect = null; + + public CardLayerHandler(MdgaApp app, Texture2D backTexture) { + this.app = app; + this.fpp = new FilterPostProcessor(app.getAssetManager()); + this.backTexture = backTexture; + } + + public void init() { + cardLayerCamera = createOverlayCam(); + cardLayer = new CardLayer(fpp, cardLayerCamera, backTexture); + app.getStateManager().attach(cardLayer); + diceControl = new DiceControl(app.getAssetManager()); + diceControl.create(new Vector3f(0, 0, 0), 1f, false); + } + + public void shutdown() { + if (cardLayer != null) { + cardLayer.shutdown(); + } + cardLayer = null; + } + + public void rollDice(int rollNum, Runnable actionAfter) { + if (!(1 <= rollNum && rollNum <= 6)) throw new RuntimeException("rollNum is not in the range [1,6]"); + diceControl.rollDice(rollNum, actionAfter); + } + + public void showDice() { + cardLayer.addSpatial(diceControl.getSpatial()); + diceControl.spin(); + } + + public void hideDice() { + diceControl.hide(); + } + + public void addCard(BonusCard card) { + if (card == BonusCard.HIDDEN) throw new RuntimeException("Can't add hidden card to GUI"); + + if (!bonusCardControlMap.containsKey(card)) { + CardControl control = createCard(bonusToAsset(card), nextPos()); + bonusCardControlMap.put(card, control); + cardLayer.addSpatial(control.getRoot()); + } + + int newNum = bonusCardIntegerMap.getOrDefault(card, 0) + 1; + bonusCardIntegerMap.put(card, newNum); + bonusCardControlMap.get(card).setNumCard(newNum); + } + + public void clearSelectableCards() { + for (CardControl control : selectableCards) { + control.setSelectable(false); + control.setHoverable(false); + control.unHighlight(); + control.unSelect(); + } + selectableCards.clear(); + cardSelect = null; + } + + public void setSelectableCards(List select) { + for (BonusCard card : select) { + selectableCards.add(bonusCardControlMap.get(card)); + } + for (CardControl control : selectableCards) { + control.setSelectable(true); + control.setHoverable(true); + control.setHighlight(); + } + } + + public void selectCard(CardControl cardControl) { + if (cardControl.isSelected()) { + cardControl.unSelect(); + cardSelect = null; + } else { + for (CardControl control : selectableCards) { + control.unSelect(); + } + cardControl.select(); + cardSelect = getKeyByValue(bonusCardControlMap, cardControl); + } + } + + public Camera getCardLayerCamera() { + return cardLayerCamera; + } + + public void shield(){ + SymbolControl control = createSymbol(Asset.shieldSymbol); + cardLayer.addSpatial(control.getSpatial()); + control.shield(); + } + + public void swap(){ + SymbolControl control = createSymbol(Asset.swapSymbol); + cardLayer.addSpatial(control.getSpatial()); + control.swap(); + } + + public void turbo(){ + SymbolControl control = createSymbol(Asset.turboSymbol); + cardLayer.addSpatial(control.getSpatial()); + control.turbo(); + } + + private Asset bonusToAsset(BonusCard card) { + return switch (card) { + case TURBO -> Asset.turboCard; + case SHIELD -> Asset.shieldCard; + case SWAP -> Asset.swapCard; + case HIDDEN -> throw new RuntimeException("HIDDEN is not allowed in GUI"); + }; + } + + private Vector3f nextPos() { + return START.add(MARGIN.mult(bonusCardControlMap.size())); + } + + private Camera createOverlayCam() { + Camera originalCam = app.getCamera(); + Camera overlayCam = new Camera(originalCam.getWidth(), originalCam.getHeight()); + overlayCam.setParallelProjection(true); + float aspect = (float) originalCam.getWidth() / originalCam.getHeight(); + float size = CARDLAYER_CAMERA_ZOOM; + overlayCam.setFrustum(-1000, 1000, -aspect * size, aspect * size, size, -size); + overlayCam.setLocation(new Vector3f(0, 0, 10)); + overlayCam.lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y); + return overlayCam; + } + + private K getKeyByValue(Map map, V value) { + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue().equals(value)) { + return entry.getKey(); + } + } + return null; + } + + public void test() { + addCard(BonusCard.SHIELD); + addCard(BonusCard.SHIELD); + addCard(BonusCard.TURBO); + addCard(BonusCard.SWAP); + } + + private CardControl createCard(Asset card, Vector3f pos){ + Node rootCard = new Node("Root Card"); + Spatial spatial = app.getAssetManager().loadModel(card.getModelPath()); + rootCard.attachChild(spatial); + Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); + mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(card.getDiffPath())); + spatial.setMaterial(mat); + spatial.setLocalScale(1f); + rootCard.setLocalTranslation(pos); + spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180)); + spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); + CardControl control = new CardControl(app, fpp, cardLayer.getOverlayCam(), rootCard); + spatial.addControl(control); + return control; + } + + private SymbolControl createSymbol(Asset asset){ + Spatial spatial = app.getAssetManager().loadModel(asset.getModelPath()); + Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + mat.setTexture("ColorMap", app.getAssetManager().loadTexture(asset.getDiffPath())); + spatial.setMaterial(mat); + spatial.setLocalScale(1f); + spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180)); + SymbolControl control = new SymbolControl(); + spatial.addControl(control); + return control; + } + + public CardLayer getCardLayer(){ + return cardLayer; + } +} diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/DiceControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/DiceControl.java index 538e840a..068460c6 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/DiceControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/DiceControl.java @@ -11,7 +11,6 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.AbstractControl; import pp.mdga.client.Asset; -import pp.mdga.message.server.Dice; import java.util.Random; @@ -23,7 +22,7 @@ public class DiceControl extends AbstractControl { private final Vector3f angularVelocity = new Vector3f(); private float deceleration = 0.5f; private float timeElapsed = 0.0f; - private float rollDuration = 0.0001f; + private float rollDuration = 1f; private static final int ANGULAR_MIN = 5; private static final int ANGULAR_MAX = 15; private static final int ANGULAR_SPIN = 10; @@ -31,6 +30,7 @@ public class DiceControl extends AbstractControl { private boolean slerp = false; private boolean spin = false; private final AssetManager assetManager; + private Runnable actionAfter; public DiceControl(AssetManager assetManager){ this.assetManager = assetManager; @@ -60,13 +60,14 @@ protected void controlUpdate(float tpf) { if (timeElapsed > 1.0f) timeElapsed = 1.0f; Quaternion interpolated = spatial.getLocalRotation().clone(); - interpolated.nlerp(targetRotation, lerp(timeElapsed)); + interpolated.slerp(targetRotation, timeElapsed); spatial.setLocalRotation(interpolated); // Stop rolling once duration is complete if (timeElapsed >= 1.0f) { isRolling = false; slerp = false; + actionAfter.run(); } } }else if(spin){ @@ -90,11 +91,11 @@ protected void controlRender(RenderManager rm, ViewPort vp) { } - public void rollDice(int diceNum) { + public void rollDice(int diceNum, Runnable actionAfter) { if (isRolling) return; spin = false; slerp = false; - + this.actionAfter = actionAfter; angularVelocity.set( FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX), FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX), @@ -166,4 +167,5 @@ public void create(Vector3f pos, float scale, boolean shadow){ public void setPos(Vector3f pos){ spatial.setLocalTranslation(pos); } + } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/GuiHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/GuiHandler.java index 3b08dad0..8393653f 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/GuiHandler.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/GuiHandler.java @@ -1,262 +1,130 @@ package pp.mdga.client.gui; -import com.jme3.font.BitmapFont; -import com.jme3.font.BitmapText; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector3f; -import com.jme3.post.FilterPostProcessor; import com.jme3.renderer.Camera; -import com.jme3.renderer.queue.RenderQueue; import com.jme3.scene.Node; -import com.jme3.scene.Spatial; import com.jme3.texture.FrameBuffer; import com.jme3.texture.Image; import com.jme3.texture.Texture2D; -import pp.mdga.client.Asset; import pp.mdga.client.MdgaApp; -import pp.mdga.game.BonusCard; import pp.mdga.game.Color; -import java.util.*; - -import static com.jme3.material.Materials.UNSHADED; - +import java.util.List; public class GuiHandler { + private final MdgaApp app; + private final CardLayerHandler cardLayerHandler; + private final PlayerNameHandler playerNameHandler; + private final ActionTextHandler actionTextHandler; + private final Color ownColor; - private MdgaApp app; - private CardLayer cardLayer; - private Map uuidBonusCardMap; - private Map bonusCardControlMap; - private Map bonusCardIntegerMap; + private FrameBuffer backFrameBuffer; - private static final Vector3f START = new Vector3f(-1.8f,-3.5f,0); - private static final Vector3f MARGIN = new Vector3f(1.8f,0,0); - - private final FilterPostProcessor fpp; - private Camera cardLayerCamera; - private DiceControl diceControl; - - private Set selectableCards = new HashSet<>(); - private BonusCard cardSelect = null; - private PlayerNameHandler playerNameHandler; - - private Node rootNode; - - public GuiHandler(MdgaApp app, Node node) { + public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) { this.app = app; - this.fpp = new FilterPostProcessor(app.getAssetManager()); - this.rootNode = node; + this.ownColor = ownColor; - cardLayerCamera = createOverlayCam(); - uuidBonusCardMap = new HashMap<>(); - bonusCardIntegerMap = new HashMap<>(); - bonusCardControlMap = new HashMap<>(); - } - - public void init(){ - FrameBuffer backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1); + backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1); Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8); backFrameBuffer.setDepthTarget(FrameBuffer.FrameBufferTarget.newTarget(Image.Format.Depth)); backFrameBuffer.addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(backTexture)); + cardLayerHandler = new CardLayerHandler(app, backTexture); + playerNameHandler = new PlayerNameHandler(guiNode, app.getAssetManager(), app.getContext().getSettings()); + actionTextHandler = new ActionTextHandler(guiNode, app.getAssetManager(), app.getContext().getSettings()); + } + + public void init() { + cardLayerHandler.init(); app.getViewPort().setOutputFrameBuffer(backFrameBuffer); - - cardLayer = new CardLayer(fpp, cardLayerCamera, backTexture); - app.getStateManager().attach(cardLayer); - diceControl = new DiceControl(app.getAssetManager()); - diceControl.create(new Vector3f(0,0,0), 1f, false); - - playerNameHandler = new PlayerNameHandler(rootNode, app.getAssetManager(), app.getContext().getSettings()); } - public void shutdown(){ - if(cardLayer != null){ - cardLayer.shutdown(); - } - - cardLayer = null; - - //app.getViewPort().setOutputFrameBuffer(null); + public void shutdown() { + cardLayerHandler.shutdown(); + app.getViewPort().setOutputFrameBuffer(null); } - private Asset bonusToAsset(BonusCard card){ - return switch (card){ - case TURBO -> Asset.turboCard; - case SHIELD -> Asset.shieldCard; - case SWAP -> Asset.swapCard; - case HIDDEN -> throw new RuntimeException("HIDDEN is not allowed in GUI"); - }; + public void rollDice(int rollNum, int mult) { + cardLayerHandler.rollDice(rollNum, ()->{ + if(mult == -1) actionTextHandler.ownDice(rollNum); + else actionTextHandler.ownDiceMult(rollNum, mult); + hideDice(); + //TODO send Model finished + }); } - public void addCard(BonusCard card, UUID uuid) { - if(card == BonusCard.HIDDEN) throw new RuntimeException("cant add hidden card to gui"); - - uuidBonusCardMap.put(uuid, card); - if(!bonusCardControlMap.containsKey(card)) { - CardControl control = createCard(bonusToAsset(card), nextPos()); - bonusCardControlMap.put(card, control); - cardLayer.addSpatial(control.getRoot()); - } - - int newNum = bonusCardIntegerMap.getOrDefault(card,0) + 1; - bonusCardIntegerMap.put(card, newNum); - bonusCardControlMap.get(card).setNumCard(newNum); + public void showRolledDiceMult(int rollNum, int mult, Color color) { + String name = playerNameHandler.getName(color); + if(mult == -1) actionTextHandler.diceNum(rollNum, name, color); + else actionTextHandler.diceNumMult(rollNum, mult, name, color); } - public void rollDice(int rollNum){ - if(!(1 <= rollNum && rollNum <= 6)) throw new RuntimeException("rollNum is not in the range [1,6]"); - diceControl.rollDice(rollNum); + public void showRolledDice(int rollNum, Color color) { + actionTextHandler.diceNum(rollNum, playerNameHandler.getName(color), color); } - public void showDice(){ - cardLayer.addSpatial(diceControl.getSpatial()); - diceControl.spin(); + public void showDice() { + cardLayerHandler.showDice(); } - public void hideDice(){ - diceControl.hide(); + public void hideDice() { + cardLayerHandler.hideDice(); } - private Vector3f nextPos() { - return START.add(MARGIN.mult(bonusCardControlMap.size())); + public void addCard(pp.mdga.game.BonusCard card) { + cardLayerHandler.addCard(card); } - public void addPlayer(Color color, String name, boolean own){ - playerNameHandler.addPlayer(color, name, own); + public void clearSelectableCards() { + cardLayerHandler.clearSelectableCards(); } - public void setActivePlayer(Color color){ - playerNameHandler.setActivePlayer(color); - } - - public Camera getCardLayerCamera() { - return cardLayerCamera; - } - - public CardLayer getCardLayer(){ - return cardLayer; - } - - public void setSelectableCards_UUID(List selectUuids) { - for(UUID uuid : selectUuids) { - selectableCards.add(bonusCardControlMap.get(uuidBonusCardMap.get(uuid))); - } - for(CardControl control : selectableCards){ - control.setSelectable(true); - control.setHoverable(true); - control.setHighlight(); - } - } - - public void setSelectableCards(List select) { - for(BonusCard uuid : select) { - selectableCards.add(bonusCardControlMap.get(uuid)); - } - for(CardControl control : selectableCards){ - control.setSelectable(true); - control.setHoverable(true); - control.setHighlight(); - } - } - - public void clearSelectableCards(){ - for(CardControl control : selectableCards){ - control.setSelectable(false); - control.setHoverable(false); - control.unHighlight(); - control.unSelect(); - } - selectableCards.clear(); - cardSelect = null; + public void setSelectableCards(List select) { + cardLayerHandler.setSelectableCards(select); } public void selectCard(CardControl cardControl) { - if(cardControl.isSelected()) { - cardControl.unSelect(); - cardSelect = null; - } - else { - for (CardControl control : selectableCards){ - control.unSelect(); - } - cardControl.select(); - cardSelect = getKeyByValue(bonusCardControlMap, cardControl); - } + cardLayerHandler.selectCard(cardControl); + } + + public Camera getCardLayerCamera() { + return cardLayerHandler.getCardLayerCamera(); + } + + public Node getCardLayerRootNode(){ + return cardLayerHandler.getCardLayer().getRootNode(); + } + + public void addPlayer(Color color, String name) { + playerNameHandler.addPlayer(color, name, color == ownColor); + } + + public void setActivePlayer(Color color) { + playerNameHandler.setActivePlayer(color); + + if (ownColor == color) actionTextHandler.ownActive(color); + else actionTextHandler.activePlayer(playerNameHandler.getName(color), color); } public void shield(){ - SymbolControl control = createSymbol(Asset.shieldSymbol); - cardLayer.addSpatial(control.getSpatial()); - control.shield(); + cardLayerHandler.shield(); } public void swap(){ - SymbolControl control = createSymbol(Asset.swapSymbol); - cardLayer.addSpatial(control.getSpatial()); - control.swap(); + cardLayerHandler.swap(); } public void turbo(){ - SymbolControl control = createSymbol(Asset.turboSymbol); - cardLayer.addSpatial(control.getSpatial()); - control.turbo(); - + cardLayerHandler.turbo(); } - private static K getKeyByValue(Map map, V value) { - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue().equals(value)) { - return entry.getKey(); - } - } - return null; // Key not found + public void hideText(){ + actionTextHandler.hide(); } - private SymbolControl createSymbol(Asset asset){ - Spatial spatial = app.getAssetManager().loadModel(asset.getModelPath()); - Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); - mat.setTexture("ColorMap", app.getAssetManager().loadTexture(asset.getDiffPath())); - spatial.setMaterial(mat); - spatial.setLocalScale(1f); - spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180)); - SymbolControl control = new SymbolControl(); - spatial.addControl(control); - return control; + public void drawCard(Color color) { + if (ownColor == color) actionTextHandler.drawCardOwn(color); + else actionTextHandler.drawCard(playerNameHandler.getName(color), color); } - private Camera createOverlayCam(){ - Camera originalCam = app.getCamera(); - Camera overlayCam = new Camera(originalCam.getWidth(), originalCam.getHeight()); - overlayCam.setParallelProjection(true); -// overlayCam.setFrustum(originalCam.getFrustumNear(), originalCam.getFrustumFar(), originalCam.getFrustumLeft(), originalCam.getFrustumRight(),originalCam.getFrustumTop(), originalCam.getFrustumBottom()); - float CAMERA_ZOOM = 4; - float aspect = (float) originalCam.getWidth() / originalCam.getHeight(); - float size = CAMERA_ZOOM; - overlayCam.setFrustum(-1000, 1000, -aspect * size, aspect * size, size, -size); -// overlayCam.setFov(originalCam.getFov()); - overlayCam.setLocation(new Vector3f(0, 0, 10)); - overlayCam.lookAt(new Vector3f(0,0,0), Vector3f.UNIT_Y); - return overlayCam; - } - private CardControl createCard(Asset card, Vector3f pos){ - Node rootCard = new Node("Root Card"); - Spatial spatial = app.getAssetManager().loadModel(card.getModelPath()); - rootCard.attachChild(spatial); -// Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); - Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); -// mat.setTexture("ColorMap", app.getAssetManager().loadTexture(card.getDiffPath())); - mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(card.getDiffPath())); - spatial.setMaterial(mat); - spatial.setLocalScale(1f); - rootCard.setLocalTranslation(pos); -// spatial.setLocalTranslation(pos); - spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180)); - spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); - CardControl control = new CardControl(app, fpp, cardLayer.getOverlayCam(), rootCard); - spatial.addControl(control); - return control; - } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/PlayerNameHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/PlayerNameHandler.java index 52e5a471..5a4456b9 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/PlayerNameHandler.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/PlayerNameHandler.java @@ -25,8 +25,7 @@ public class PlayerNameHandler { private final AssetManager assetManager; private Color ownColor; - - private static final float PADDING_TOP = 50; + private static final float PADDING_TOP = 35; private static final float PADDING_LEFT = 50; private static final float MARGIN_NAMES = 50; private static final float IMAGE_SIZE = 50; @@ -91,14 +90,7 @@ private Spatial createColor(Color color) { return pic; } - private ColorRGBA playerColorToColorRGBA(Color color){ - return switch (color){ - case ARMY -> ColorRGBA.Green; - case NAVY -> ColorRGBA.Blue; - case CYBER -> ColorRGBA.Orange; - case AIRFORCE -> ColorRGBA.Black; - }; - } + private Spatial createName(String name, boolean first, boolean own){ BitmapText hudText = new BitmapText(playerFont); @@ -126,5 +118,9 @@ public void setActivePlayer(Color color) { drawPlayers(); } + public String getName(Color color){ + return colorNameMap.get(color); + } + } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/ZoomControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/ZoomControl.java new file mode 100644 index 00000000..c628f1db --- /dev/null +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/ZoomControl.java @@ -0,0 +1,82 @@ +package pp.mdga.client.gui; + +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.ViewPort; +import com.jme3.scene.Spatial; +import com.jme3.scene.control.AbstractControl; + +public class ZoomControl extends AbstractControl { + private boolean zoomingIn = false; + private boolean zoomingOut = false; + private float progress = 0; + private float zoomSpeed = 1f; + private float zoomFactor = 1f; + + public ZoomControl(){} + + public ZoomControl(float speed) { + zoomSpeed = speed; + } + + @Override + public void setSpatial(Spatial spatial){ + if(this.spatial == null && spatial != null){ + super.setSpatial(spatial); + initSpatial(); + } + } + + private void initSpatial() { + zoomingIn = true; + } + + @Override + protected void controlUpdate(float tpf) { + if (zoomingIn) { + progress += tpf * zoomSpeed; + if (progress > 1) progress = 1; + spatial.setLocalScale(lerp(0, zoomFactor, easeOut(progress))); + if (progress >= 1) { + zoomingIn = false; + zoomingOut = true; + progress = 0; + } + } else if (zoomingOut) { + progress += tpf * zoomSpeed; + spatial.setLocalScale(lerp(zoomFactor, 0, easeIn(progress))); + if (progress > 1) { + zoomingOut = false; + end(); + } + } + } + + private void end(){ + spatial.removeFromParent(); + spatial.removeControl(this); + } + + @Override + protected void controlRender(RenderManager rm, ViewPort vp) { + + } + + private static float lerp(float start, float end, float t) { + return (1 - t) * start + t * end; + } + +// private static float easeOut(float t) { +// return (float) Math.sqrt(1 - Math.pow(t - 1, 2)); +// } +private float easeOut(float x) { + return x == 1 ? 1 : (float) (1 - Math.pow(2, -10 * x)); + + } +// private float easeIn(float t) { +// return t * t * t * t; +// } + private float easeIn(float x) { + return x == 0 ? 0 : (float) Math.pow(2, 10 * x - 10); + + } +} 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..150eb3b5 --- /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(AnimationEndMessage.class); + Serializer.registerClass(ClientStartGameMessage.class); + Serializer.registerClass(DeselectTSKMessage.class); + Serializer.registerClass(ForceContinueGameMessage.class); + Serializer.registerClass(StartGameMessage.class); + Serializer.registerClass(JoinServerMessage.class); + Serializer.registerClass(LeaveGameMessage.class); + Serializer.registerClass(LobbyNotReadyMessage.class); + Serializer.registerClass(LobbyReadyMessage.class); + Serializer.registerClass(NoPowerCardMessage.class); + Serializer.registerClass(RequestBriefingMessage.class); + Serializer.registerClass(RequestDieMessage.class); + Serializer.registerClass(RequestMoveMessage.class); + Serializer.registerClass(RequestPlayCardMessage.class); + Serializer.registerClass(SelectCardMessage.class); + Serializer.registerClass(SelectedPiecesMessage.class); + Serializer.registerClass(SelectTSKMessage.class); + + Serializer.registerClass(ActivePlayerMessage.class); + Serializer.registerClass(AnyPieceMessage.class); + Serializer.registerClass(BriefingMessage.class); + Serializer.registerClass(CeremonyMessage.class); + Serializer.registerClass(DieMessage.class); + Serializer.registerClass(DiceAgainMessage.class); + Serializer.registerClass(DiceNowMessage.class); + Serializer.registerClass(EndOfTurnMessage.class); + Serializer.registerClass(LobbyAcceptMessage.class); + Serializer.registerClass(LobbyDenyMessage.class); + Serializer.registerClass(LobbyPlayerJoinMessage.class); + Serializer.registerClass(LobbyPlayerLeaveMessage.class); + Serializer.registerClass(MoveMessage.class); + Serializer.registerClass(NoTurnMessage.class); + Serializer.registerClass(PauseGameMessage.class); + Serializer.registerClass(PlayCardMessage.class); + Serializer.registerClass(PossibleCardMessage.class); + Serializer.registerClass(PossiblePieceMessage.class); + Serializer.registerClass(RankingResponseMessage.class); + Serializer.registerClass(RankingRollAgainMessage.class); + Serializer.registerClass(ReconnectBriefingMessage.class); + Serializer.registerClass(ResumeGameMessage.class); + Serializer.registerClass(ServerStartGameMessage.class); + Serializer.registerClass(StartPieceMessage.class); + Serializer.registerClass(UpdateReadyMessage.class); + Serializer.registerClass(UpdateTSKMessage.class); + Serializer.registerClass(WaitPieceMessage.class); + } + + private void registerListeners() { + myServer.addMessageListener(this, AnimationEndMessage.class); + myServer.addMessageListener(this, ClientStartGameMessage.class); + myServer.addMessageListener(this, DeselectTSKMessage.class); + myServer.addMessageListener(this, ForceContinueGameMessage.class); + myServer.addMessageListener(this, StartGameMessage.class); + myServer.addMessageListener(this, JoinServerMessage.class); + myServer.addMessageListener(this, LeaveGameMessage.class); + myServer.addMessageListener(this, LobbyNotReadyMessage.class); + myServer.addMessageListener(this, LobbyReadyMessage.class); + myServer.addMessageListener(this, NoPowerCardMessage.class); + myServer.addMessageListener(this, RequestBriefingMessage.class); + myServer.addMessageListener(this, RequestDieMessage.class); + myServer.addMessageListener(this, RequestMoveMessage.class); + myServer.addMessageListener(this, RequestPlayCardMessage.class); + myServer.addMessageListener(this, SelectCardMessage.class); + myServer.addMessageListener(this, SelectedPiecesMessage.class); + myServer.addMessageListener(this, SelectTSKMessage.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 DisconnectedMessage(), 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/CeremonyView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java index dbdb9c22..d4cde73d 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java @@ -9,7 +9,6 @@ import pp.mdga.client.button.ButtonLeft; import pp.mdga.client.button.ButtonRight; import pp.mdga.client.button.CeremonyButton; -import pp.mdga.client.button.LobbyButton; import pp.mdga.client.dialog.CeremonyDialog; import pp.mdga.game.Color; @@ -68,6 +67,8 @@ public void onLeave() { ceremonyButtons.clear(); rootNode.removeLight(ambient); + + ceremonyDialog.prepare(); } @Override @@ -132,7 +133,7 @@ public void forward() { enterSub(SubState.STATISTICS); break; case STATISTICS: - app.getModelSyncronizer().enter(MdgaState.MAIN); + app.getModelSynchronize().enter(MdgaState.MAIN); break; } } 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 e2ca8886..963e0e64 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 @@ -45,16 +45,16 @@ public class GameView extends MdgaView { public GameView(MdgaApp app) { super(app); - cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().enter(MdgaState.CEREMONY), "CHEAT", 1); - leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSyncronizer().leave(), "Spiel verlassen", 1); + cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSynchronize().enter(MdgaState.CEREMONY), "CHEAT", 1); - confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSyncronizer().confirm(), "Bestätigen", 1); + leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1); + confirmButton = new ButtonRight(app, settingsNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1); fpp = new FilterPostProcessor(app.getAssetManager()); this.camera = new CameraHandler(app, fpp); this.boardHandler = new BoardHandler(app, rootNode, fpp); - guiHandler = new GuiHandler(app, guiNode); + guiHandler = new GuiHandler(app, guiNode, ownColor); } @Override @@ -79,7 +79,7 @@ public void onLeave() { @Override public void onUpdate(float tpf) { - camera.update(app.getInputSyncronizer().getScroll(), app.getInputSyncronizer().getRotation()); + camera.update(app.getInputSynchronize().getScroll(), app.getInputSynchronize().getRotation()); } @Override @@ -99,7 +99,7 @@ protected void onLeaveOverlay(Overlay overlay) { } private void leaveGame() { - app.getModelSyncronizer().leave(); + app.getModelSynchronize().leave(); } public BoardHandler getBoardHandler() { diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java index 83c968cc..3adb6dd3 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java @@ -179,10 +179,10 @@ private void toggleTsk(Color color) { switch (taken) { case NOT: - app.getModelSyncronizer().selectTsk(color); + app.getModelSynchronize().selectTsk(color); break; case SELF: - app.getModelSyncronizer().unselectTsk(); + app.getModelSynchronize().unselectTsk(); break; case OTHER: //nothing @@ -191,11 +191,11 @@ private void toggleTsk(Color color) { } private void ready() { - app.getModelSyncronizer().setReady(); + app.getModelSynchronize().setReady(); app.getAcousticHandler().playSound(MdgaSound.SELF_READY); } private void leaveLobby() { - app.getModelSyncronizer().leave(); + app.getModelSynchronize().leave(); } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java index b1997409..7b724bc9 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java @@ -2,11 +2,7 @@ import com.jme3.scene.Geometry; import pp.mdga.client.MdgaApp; -import pp.mdga.client.MdgaState; import pp.mdga.client.acoustic.MdgaSound; -import pp.mdga.client.button.ButtonRight; -import pp.mdga.client.button.MenuButton; -import pp.mdga.client.button.SettingsButton; import pp.mdga.client.dialog.HostDialog; import pp.mdga.client.dialog.JoinDialog; import pp.mdga.client.dialog.StartDialog; @@ -98,8 +94,8 @@ private void tryHost() { port = Integer.parseInt(text); if(port >= 1 && port <= 65535) { - app.getModelSyncronizer().setName(startDialog.getName()); - app.getModelSyncronizer().setHost(port); + app.getModelSynchronize().setName(startDialog.getName()); + app.getModelSynchronize().setHost(port); //app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); return; } @@ -125,8 +121,8 @@ private void tryJoin() { // Validate the IP address if (isValidIpAddress(ip)) { - app.getModelSyncronizer().setName(startDialog.getName()); - app.getModelSyncronizer().setJoin(ip, port); + app.getModelSynchronize().setName(startDialog.getName()); + app.getModelSynchronize().setJoin(ip, port); return; } } catch (IllegalArgumentException e) { diff --git a/Projekte/mdga/client/src/main/resources/Images/sky/sky.dds b/Projekte/mdga/client/src/main/resources/Images/sky/sky.dds new file mode 100644 index 00000000..2c08c965 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/sky/sky.dds differ 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/notification/CeremonyNotification.java b/Projekte/mdga/model/src/main/java/pp.mdga/notification/CeremonyNotification.java deleted file mode 100644 index f7210f69..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/CeremonyNotification.java +++ /dev/null @@ -1,156 +0,0 @@ -package pp.mdga.notification; - -import pp.mdga.game.Color; - -import java.util.ArrayList; - -/** - * Class CeremonyNotification - * Represents a notification for a ceremony in the game. - * - * Index mapping: - * index = 0 ==> winner - * index = 1 ==> 2nd - * index = 2 ==> third place - * index = 3 ==> loser - * index = 4 ==> total - */ -public class CeremonyNotification extends Notification { - private ArrayList colors; - private ArrayList names; - private ArrayList piecesThrown; - private ArrayList piecesLost; - private ArrayList bonusCardsPlayed; - private ArrayList sixes; - private ArrayList nodesMoved; - private ArrayList bonusNodes; - - /** - * Constructor - * Initializes all lists. - */ - public CeremonyNotification() { - this.colors = new ArrayList<>(); - this.names = new ArrayList<>(); - this.piecesThrown = new ArrayList<>(); - this.piecesLost = new ArrayList<>(); - this.bonusCardsPlayed = new ArrayList<>(); - this.sixes = new ArrayList<>(); - this.nodesMoved = new ArrayList<>(); - this.bonusNodes = new ArrayList<>(); - } - - // Getters and Setters - - /** - * @return the list of colors - */ - public ArrayList getColors() { - return colors; - } - - /** - * @param colors the list of colors to set - */ - public void setColors(ArrayList colors) { - this.colors = colors; - } - - /** - * @return the list of player names - */ - public ArrayList getNames() { - return names; - } - - /** - * @param names the list of player names to set - */ - public void setNames(ArrayList names) { - this.names = names; - } - - /** - * @return the list of pieces thrown - */ - public ArrayList getPiecesThrown() { - return piecesThrown; - } - - /** - * @param piecesThrown the list of pieces thrown to set - */ - public void setPiecesThrown(ArrayList piecesThrown) { - this.piecesThrown = piecesThrown; - } - - /** - * @return the list of pieces lost - */ - public ArrayList getPiecesLost() { - return piecesLost; - } - - /** - * @param piecesLost the list of pieces lost to set - */ - public void setPiecesLost(ArrayList piecesLost) { - this.piecesLost = piecesLost; - } - - /** - * @return the list of bonus cards played - */ - public ArrayList getBonusCardsPlayed() { - return bonusCardsPlayed; - } - - /** - * @param bonusCardsPlayed the list of bonus cards played to set - */ - public void setBonusCardsPlayed(ArrayList bonusCardsPlayed) { - this.bonusCardsPlayed = bonusCardsPlayed; - } - - /** - * @return the list of sixes rolled - */ - public ArrayList getSixes() { - return sixes; - } - - /** - * @param sixes the list of sixes rolled to set - */ - public void setSixes(ArrayList sixes) { - this.sixes = sixes; - } - - /** - * @return the list of nodes moved - */ - public ArrayList getNodesMoved() { - return nodesMoved; - } - - /** - * @param nodesMoved the list of nodes moved to set - */ - public void setNodesMoved(ArrayList nodesMoved) { - this.nodesMoved = nodesMoved; - } - - /** - * @return the list of bonus nodes - */ - public ArrayList getBonusNodes() { - return bonusNodes; - } - - /** - * @param bonusNodes the list of bonus nodes to set - */ - public void setBonusNodes(ArrayList bonusNodes) { - this.bonusNodes = bonusNodes; - } -} 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/Lobby.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java deleted file mode 100644 index 5da89e84..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java +++ /dev/null @@ -1,74 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.client.*; -import pp.mdga.message.server.ServerStartGame; -import pp.mdga.message.server.UpdateReady; -import pp.mdga.message.server.UpdateTSK; - -/** - * Represents the lobby state of the server. - */ -public class Lobby extends ServerState { - /** - * Constructs a new Lobby state. - * - * @param parent the parent state - * @param logic the server game logic - */ - public Lobby(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - /** - * Handles the DeselectTSK message. - * - * @param msg the DeselectTSK message - */ - @Override - public void receivedDeselectTSK(DeselectTSK msg, int from) { -// broadcastUpdate(new UpdateTSK()); - } - - /** - * Handles the LobbyNotReady message. - * - * @param msg the LobbyNotReady message - */ - @Override - public void receivedNotReady(LobbyNotReady msg, int from) { -// broadcastUpdate(new UpdateReady()); - } - - /** - * Handles the LobbyReady message. - * - * @param msg the LobbyReady message - */ - @Override - public void receivedReady(LobbyReady msg, int from) { -// broadcastUpdate(new UpdateReady()); - } - - /** - * Handles the SelectTSK message. - * - * @param msg the SelectTSK message - */ - @Override - public void receivedSelectTSK(SelectTSK msg, int from) { -// broadcastUpdate(new UpdateTSK()); - } - - /** - * Handles the ClientStartGame message. - * - * @param msg the ClientStartGame message - */ - @Override - public void receivedStartGame(ClientStartGame msg, int from) { - if (Boolean.TRUE.equals(logic.getGame().allRanked())) { - broadcastUpdate(new ServerStartGame()); - parent.gotoState(new GameState(parent, logic)); - } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java deleted file mode 100644 index 38d40399..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/MovePiece.java +++ /dev/null @@ -1,7 +0,0 @@ -package pp.mdga.server; - -public class MovePiece extends ServerState { - public MovePiece(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java deleted file mode 100644 index 6326bfb1..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoPiece.java +++ /dev/null @@ -1,55 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.game.Player; -import pp.mdga.message.server.WaitPiece; - -public class NoPiece extends ServerState { - public NoPiece(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - entry(); - } - - @Override - public void entry() { -// if (hasTurbo() || turbo == 0) { -// if (roll == 6 && -// logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces() && -// logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { -// parent.gotoState(new WaitingPiece(parent, logic)); -// } else { -// parent.gotoState(new NoTurn(parent, logic)); -// } -// } else { -// validateHasPieces(); -// } - } - - private void validateHasPieces() { -// if (logic.getGame().getBoard().getPlayerData().getWaitingArea().hasPieces()) { -// if (logic.getGame().getBoard().getNodes().getStartNode(Color).isOccupied()) { -// if (roll == 6) { -// logic.send(new Player(1), new WaitPiece()); -// } else { -// validateMove(); -// } -// } else { -// if (logic.getGame().getBoard().getNodes().getStartNode(Color).getPiece().canMove()) { -// logic.send(new Player(1), new WaitPiece()); -// parent.gotoState(new StartPiece(parent, logic)); -// } else { -// validateMove(); -// } -// } -// } else { -// validateMove(); -// } - } - - private void validateMove() { -// if (player.canMove()) { -// parent.gotoState(new NoTurn(parent, logic)); -// } else { -// logic.send(new Player(1), new SelectPiece()); -// } - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java b/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java deleted file mode 100644 index 388f50bf..00000000 --- a/Projekte/mdga/model/src/main/java/pp.mdga/server/NoTurn.java +++ /dev/null @@ -1,14 +0,0 @@ -package pp.mdga.server; - -import pp.mdga.message.server.EndOfTurn; - -public class NoTurn extends ServerState { - public NoTurn(ServerState parent, ServerGameLogic logic) { - super(parent, logic); - } - - @Override - public void sentEndOfTurn(EndOfTurn msg, int from) { - // todo: goto end of turn - } -} diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/server/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/CeremonyState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/CeremonyState.java new file mode 100644 index 00000000..dd83c91e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/CeremonyState.java @@ -0,0 +1,19 @@ +package pp.mdga.client; + +public class CeremonyState extends ClientState { + + + public CeremonyState(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..c40f7e02 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientGameLogic.java @@ -0,0 +1,278 @@ +package pp.mdga.client; + +import pp.mdga.game.Color; +import pp.mdga.game.Game; +import pp.mdga.game.Piece; +import pp.mdga.game.PlayerData; +import pp.mdga.message.client.ClientMessage; +import pp.mdga.message.server.*; +import pp.mdga.notification.*; + +import java.util.ArrayList; +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 final ArrayList notifications = new ArrayList<>(); + + private final DialogsState dialogsState = new DialogsState(null, this); + private final GameState gameState = new GameState(null, this); + private final CeremonyState ceremonyState = new CeremonyState(null, this); + private final InterruptState interruptState = new InterruptState(null, this); + + public ClientGameLogic(Game game, ClientSender clientSender) { + this.game = game; + this.clientSender = clientSender; + state = dialogsState; + } + + public void send(ClientMessage msg){ + LOGGER.log(System.Logger.Level.INFO, "send {0}", msg); + clientSender.send(msg); + } + + private Piece getPiece(UUID pieceId){ + for(Map.Entry entry : game.getBoard().getPlayerData().entrySet()){ + for(Piece piece : entry.getValue().getPieces()){ + if(piece.getUuid().equals(pieceId)){ + return piece; + } + } + } + return null; + } + + public ClientSender getClientSender(){ + return clientSender; + } + + public Game getGame(){ + return game; + } + + public ClientState getState(){ + return state; + } + + @Override + public void received(ActivePlayerMessage msg) { + state.received(msg); + } + + @Override + public void received(AnyPieceMessage msg) { + state.received(msg); + } + + @Override + public void received(BriefingMessage msg) { + state.received(msg); + } + + @Override + public void received(CeremonyMessage msg) { + state.received(msg); + } + + @Override + public void received(DieMessage msg) { + state.received(msg); + } + + @Override + public void received(DiceAgainMessage msg) { + state.received(msg); + } + + @Override + public void received(DiceNowMessage msg) { + state.received(msg); + } + + @Override + public void received(EndOfTurnMessage msg) { + state.received(msg); + } + + @Override + public void received(LobbyAcceptMessage msg) { + state.received(msg); + } + + @Override + public void received(LobbyDenyMessage msg) { + state.received(msg); + } + + @Override + public void received(LobbyPlayerJoinMessage msg) { + state.received(msg); + } + + @Override + public void received(LobbyPlayerLeaveMessage msg) { + state.received(msg); + } + + @Override + public void received(MoveMessage msg) { + state.received(msg); + } + + @Override + public void received(NoTurnMessage msg) { + state.received(msg); + } + + @Override + public void received(PauseGameMessage msg) { + state.received(msg); + } + + @Override + public void received(PlayCardMessage msg) { + state.received(msg); + } + + @Override + public void received(PossibleCardMessage msg) { + state.received(msg); + } + + @Override + public void received(PossiblePieceMessage msg) { + state.received(msg); + } + + @Override + public void received(RankingResponseMessage msg) { + state.received(msg); + } + + @Override + public void received(RankingRollAgainMessage msg) { + state.received(msg); + } + + @Override + public void received(ReconnectBriefingMessage msg) { + state.received(msg); + } + + @Override + public void received(ResumeGameMessage msg) { + state.received(msg); + } + + @Override + public void received(ServerStartGameMessage msg) { + state.received(msg); + } + + @Override + public void received(StartPieceMessage msg) { + state.received(msg); + } + + @Override + public void received(UpdateReadyMessage msg) { + state.received(msg); + } + + @Override + public void received(UpdateTSKMessage msg) { + state.received(msg); + } + + @Override + public void received(WaitPieceMessage msg) { + state.received(msg); + } + + @Override + public void received(SpectatorMessage msg) { + state.received(msg); + } + + @Override + public void received(SelectPieceMessage msg) { + + } + + public void selectPiece(UUID pieceId){ + state.selectPiece(getPiece(pieceId)); + } + + //TODO: implement + public void selectCard(UUID cardId){ + state.selectCard(null); + } + + 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(String name){ + state.selectHost(name); + } + + public void selectLeave(){ + state.selectLeave(); + } + + public void selectJoin(String name){ + state.selectJoin(name); + } + + public void selectAnimationEnd(){ + state.selectAnimationEnd(); + } + + public void selectStart(){ + state.selectStart(); + } + + public void setState(ClientState state){ + this.state.exit(); + state.enter(); + this.state = state; + } + + public GameState getGameState(){ + return gameState; + } + + public CeremonyState getCeremony(){ + return ceremonyState; + } + + public InterruptState getInterrupt(){ + return interruptState; + } + + public DialogsState getDialogs(){ + return dialogsState; + } + + public Notification getNotification(){ + return notifications.remove(0); + } + +} 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..a9accf58 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ClientState.java @@ -0,0 +1,233 @@ +package pp.mdga.client; + +import pp.mdga.game.BonusCard; +import pp.mdga.game.Color; +import pp.mdga.game.Piece; +import pp.mdga.message.server.*; + +import java.lang.System.Logger.Level; + +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(ActivePlayerMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(AnyPieceMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(BriefingMessage 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(DieMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(DiceAgainMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(DiceNowMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(EndOfTurnMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(LobbyAcceptMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(LobbyDenyMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(LobbyPlayerJoinMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(LobbyPlayerLeaveMessage 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(NoTurnMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(PauseGameMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(PlayCardMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(PossibleCardMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(PossiblePieceMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(RankingResponseMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(RankingRollAgainMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(ReconnectBriefingMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(ResumeGameMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(ServerStartGameMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(StartPieceMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(UpdateReadyMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(UpdateTSKMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(SpectatorMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(SelectPieceMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + @Override + public void received(WaitPieceMessage msg) { + LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg); + } + + public void selectPiece(Piece piece) { + LOGGER.log(Level.DEBUG, "Selecting piece not allowed."); + } + + public void selectCard(BonusCard card) { + 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(String name) { + LOGGER.log(Level.DEBUG, "Selecting host not allowed."); + } + + public void selectJoin(String name) { + 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"); + } + + public void selectAnimationEnd(){ + LOGGER.log(Level.DEBUG, "Animation end not allowed"); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogsState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogsState.java new file mode 100644 index 00000000..7f30a8c4 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/DialogsState.java @@ -0,0 +1,72 @@ +package pp.mdga.client; + +import pp.mdga.client.dialogState.DialogStates; +import pp.mdga.client.dialogState.LobbyState; +import pp.mdga.client.dialogState.NetworkDialogState; +import pp.mdga.client.dialogState.StartDialogState; +import pp.mdga.game.Player; +import pp.mdga.message.server.LobbyPlayerJoinMessage; +import pp.mdga.message.server.LobbyPlayerLeaveMessage; + +public class DialogsState extends ClientState { + + private DialogStates currentState; + + private Player ownPlayer; + + private final LobbyState lobbyState = new LobbyState(this, logic); + private final NetworkDialogState networkDialogState = new NetworkDialogState(this, logic); + private final StartDialogState startDialogState = new StartDialogState(this, logic); + + + public DialogsState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void exit(){ + currentState.exit(); + } + + @Override + public void enter(){ + currentState = startDialogState; + } + + public void setState(DialogStates newState){ + currentState.exit(); + currentState.enter(); + currentState = newState; + } + + public Player getOwnPlayer() { + return ownPlayer; + } + + public LobbyState getLobby() { + return lobbyState; + } + + public NetworkDialogState getNetworkDialog() { + return networkDialogState; + } + + public StartDialogState getStartDialog() { + return startDialogState; + } + + public void startGame(){ + exit(); + logic.setState(logic.getGameState()); + } + + @Override + public void received(LobbyPlayerJoinMessage msg){ + currentState.received(msg); + } + + @Override + public void received(LobbyPlayerLeaveMessage msg){ + currentState.received(msg); + } +} 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..56901970 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/GameState.java @@ -0,0 +1,60 @@ +package pp.mdga.client; + +import pp.mdga.client.gameState.*; + +public class GameState extends ClientState { + + private GameStates state; + + private final AnimationState animationState = new AnimationState(this, logic); + private final DetermineStartPlayerState determineStartPlayerState = new DetermineStartPlayerState(this, logic); + private final SpectatorState spectatorState = new SpectatorState(this, logic); + private final TurnState turnState = new TurnState(this, logic); + private final WaitingState waitingState = new WaitingState(this, logic); + + public GameState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + state = determineStartPlayerState; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + public void setState(GameStates newState){ + state.exit(); + state.enter(); + state = newState; + } + + @Override + public void selectAnimationEnd(){ + state.selectAnimationEnd(); + } + + public AnimationState getAnimation() { + return animationState; + } + + public DetermineStartPlayerState getDetermineStartPlayer() { + return determineStartPlayerState; + } + + public SpectatorState getSpectator() { + return spectatorState; + } + + public TurnState getTurn() { + return turnState; + } + + public WaitingState getWaiting() { + return waitingState; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/InterruptState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/InterruptState.java new file mode 100644 index 00000000..f58e2fe7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/InterruptState.java @@ -0,0 +1,18 @@ +package pp.mdga.client; + +public class InterruptState extends ClientState { + + public InterruptState(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/SettingsState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/SettingsState.java new file mode 100644 index 00000000..88800cc8 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/SettingsState.java @@ -0,0 +1,18 @@ +package pp.mdga.client; + +public class SettingsState extends ClientState { + + public SettingsState(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/PodiumState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/PodiumState.java new file mode 100644 index 00000000..b6a5c535 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/PodiumState.java @@ -0,0 +1,20 @@ +package pp.mdga.client.ceremonyState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class PodiumState extends CeremonyStates { + public PodiumState(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/StatisticsState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/StatisticsState.java new file mode 100644 index 00000000..fdc5de34 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/ceremonyState/StatisticsState.java @@ -0,0 +1,20 @@ +package pp.mdga.client.ceremonyState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class StatisticsState extends CeremonyStates { + public StatisticsState(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/LobbyState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/LobbyState.java new file mode 100644 index 00000000..5f09da11 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/LobbyState.java @@ -0,0 +1,76 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.DialogsState; +import pp.mdga.game.Color; +import pp.mdga.game.Player; +import pp.mdga.message.client.*; +import pp.mdga.message.server.LobbyPlayerJoinMessage; +import pp.mdga.message.server.LobbyPlayerLeaveMessage; +import pp.mdga.message.server.ServerStartGameMessage; + +public class LobbyState extends DialogStates { + + private final DialogsState parent; + + public LobbyState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (DialogsState) 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 SelectTSKMessage(color)); + } + + @Override + public void deselectTSK(Color color) { + logic.send(new DeselectTSKMessage(color)); + } + + @Override + public void selectReady() { + logic.send(new LobbyReadyMessage()); + } + + @Override + public void selectUnready(){ + logic.send(new LobbyNotReadyMessage()); + } + + @Override + public void selectStart(){ + logic.send(new StartGameMessage()); + } + + @Override + public void received(ServerStartGameMessage msg){ + parent.startGame(); + } + + @Override + public void received(LobbyPlayerJoinMessage msg){ + logic.getGame().getPlayers().put(msg.getId(), new Player(msg.getName())); + } + + @Override + public void received(LobbyPlayerLeaveMessage msg){ + logic.getGame().getPlayers().remove(msg.getId()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/NetworkDialogState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/NetworkDialogState.java new file mode 100644 index 00000000..f23abd9d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/NetworkDialogState.java @@ -0,0 +1,63 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.DialogsState; + +public class NetworkDialogState extends DialogStates { + + private final DialogsState parent; + + public NetworkDialogState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (DialogsState) 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() { + } + + @Override + public void selectLeave() { + 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/StartDialogState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/StartDialogState.java new file mode 100644 index 00000000..7e2bcc86 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/dialogState/StartDialogState.java @@ -0,0 +1,39 @@ +package pp.mdga.client.dialogState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.DialogsState; + +public class StartDialogState extends DialogStates { + + private final DialogsState parent; + + public StartDialogState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (DialogsState) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + public void selectJoin(String name) { + parent.getOwnPlayer().setName(name); + parent.setState(parent.getNetworkDialog()); + } + + public void selectHost(String name) { + parent.getOwnPlayer().setName(name); + parent.setState(parent.getLobby()); + } + + public void selectLeave() { + parent.exit(); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/AnimationState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/AnimationState.java new file mode 100644 index 00000000..a7aaf745 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/AnimationState.java @@ -0,0 +1,32 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.GameState; +import pp.mdga.message.client.AnimationEndMessage; + +public class AnimationState extends GameStates { + + private final GameState parent; + + public AnimationState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (GameState) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + @Override + public void selectAnimationEnd(){ + logic.send(new AnimationEndMessage()); + parent.setState(parent.getWaiting()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayerState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayerState.java new file mode 100644 index 00000000..0413ad9b --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/DetermineStartPlayerState.java @@ -0,0 +1,46 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.GameState; +import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates; +import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState; +import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState; + +public class DetermineStartPlayerState extends GameStates { + + private final GameState parent; + private DetermineStartPlayerStates state; + + private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic); + private final WaitRankingState waitRankingState = new WaitRankingState(this, logic); + + public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (GameState) parent; + } + + @Override + public void enter() { + state = rollRankingDiceState; + } + + @Override + public void exit() { + state = null; + } + + public void setState(DetermineStartPlayerStates state) { + this.state.exit(); + state.enter(); + this.state = state; + } + + public RollRankingDiceState getRollRankingDice() { + return rollRankingDiceState; + } + + public WaitRankingState getWaitRanking() { + return waitRankingState; + } +} 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/SpectatorState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/SpectatorState.java new file mode 100644 index 00000000..001454bc --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/SpectatorState.java @@ -0,0 +1,26 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.message.server.CeremonyMessage; + +public class SpectatorState extends GameStates { + public SpectatorState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + @Override + public void received(CeremonyMessage msg){ + logic.setState(logic.getCeremony()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/TurnState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/TurnState.java new file mode 100644 index 00000000..c0af142d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/TurnState.java @@ -0,0 +1,92 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.GameState; +import pp.mdga.client.gameState.turnState.ChoosePieceState; +import pp.mdga.client.gameState.turnState.MovePieceState; +import pp.mdga.client.gameState.turnState.PlayPowerCardState; +import pp.mdga.client.gameState.turnState.PowerCardState; +import pp.mdga.client.gameState.turnState.RollDiceState; +import pp.mdga.client.gameState.turnState.TurnStates; +import pp.mdga.message.server.CeremonyMessage; +import pp.mdga.message.server.EndOfTurnMessage; +import pp.mdga.message.server.NoTurnMessage; +import pp.mdga.message.server.SpectatorMessage; + +public class TurnState extends GameStates { + + private GameState parent; + private TurnStates state; + + private final ChoosePieceState choosePieceState = new ChoosePieceState(this, logic); + private final MovePieceState movePieceState = new MovePieceState(this, logic); + private final PlayPowerCardState playPowerCardState = new PlayPowerCardState(this, logic); + private final PowerCardState powerCardState = new PowerCardState(this, logic); + private final RollDiceState rollDiceState = new RollDiceState(this, logic); + + public TurnState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (GameState) parent; + } + + @Override + public void enter() { + state = powerCardState; + } + + @Override + public void exit() { + state = null; + } + + public void setState(TurnStates state){ + this.state.exit(); + state.enter(); + this.state = state; + } + + @Override + public void received(NoTurnMessage msg){ + parent.setState(parent.getWaiting()); + } + + @Override + public void received(EndOfTurnMessage msg){ + parent.setState(parent.getWaiting()); + } + + @Override + public void received(CeremonyMessage msg){ + logic.setState(logic.getCeremony()); + } + + @Override + public void received(SpectatorMessage msg){ + parent.setState(parent.getSpectator()); + } + + public ChoosePieceState getChoosePiece() { + return choosePieceState; + } + + public MovePieceState getMovePiece() { + return movePieceState; + } + + public PlayPowerCardState getPlayPowerCard() { + return playPowerCardState; + } + + public PowerCardState getPowerCard() { + return powerCardState; + } + + public RollDiceState getRollDice() { + return rollDiceState; + } + + public GameState getParent(){ + return parent; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/WaitingState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/WaitingState.java new file mode 100644 index 00000000..4b6f3f87 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/WaitingState.java @@ -0,0 +1,43 @@ +package pp.mdga.client.gameState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.GameState; +import pp.mdga.message.server.CeremonyMessage; +import pp.mdga.message.server.DiceNowMessage; +import pp.mdga.message.server.EndOfTurnMessage; + +public class WaitingState extends GameStates { + + private final GameState parent; + + public WaitingState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (GameState) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + @Override + public void received(CeremonyMessage msg){ + logic.setState(logic.getCeremony()); + } + + @Override + public void received(DiceNowMessage msg){ + parent.setState(parent.getTurn()); + } + + @Override + public void received(EndOfTurnMessage msg){ + parent.setState(parent.getWaiting()); + } +} 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/RollRankingDiceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/RollRankingDiceState.java new file mode 100644 index 00000000..43796e7a --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/RollRankingDiceState.java @@ -0,0 +1,37 @@ +package pp.mdga.client.gameState.determineStartPlayerState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.DetermineStartPlayerState; +import pp.mdga.message.client.RequestDieMessage; +import pp.mdga.message.server.DieMessage; + +public class RollRankingDiceState extends DetermineStartPlayerStates { + + private final DetermineStartPlayerState parent; + + public RollRankingDiceState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (DetermineStartPlayerState) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + @Override + public void selectDice(){ + logic.send(new RequestDieMessage()); + } + + @Override + public void received(DieMessage msg){ + parent.setState(parent.getWaitRanking()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/WaitRankingState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/WaitRankingState.java new file mode 100644 index 00000000..6f470ba3 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/determineStartPlayerState/WaitRankingState.java @@ -0,0 +1,37 @@ +package pp.mdga.client.gameState.determineStartPlayerState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.DetermineStartPlayerState; +import pp.mdga.message.server.RankingResponseMessage; +import pp.mdga.message.server.RankingRollAgainMessage; + +public class WaitRankingState extends DetermineStartPlayerStates { + + private final DetermineStartPlayerState parent; + + public WaitRankingState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (DetermineStartPlayerState) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + @Override + public void received(RankingRollAgainMessage msg){ + parent.setState(parent.getRollRankingDice()); + } + + @Override + public void received(RankingResponseMessage msg){ + //TODO: implement + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePieceState.java new file mode 100644 index 00000000..d5d86ffd --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/ChoosePieceState.java @@ -0,0 +1,58 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.TurnState; +import pp.mdga.client.gameState.turnState.choosePieceState.*; + +public class ChoosePieceState extends TurnStates { + + private TurnState parent; + private ChoosePieceStates currentState; + + private final NoPieceState noPieceState = new NoPieceState(this, logic); + private final SelectPieceState selectPieceState = new SelectPieceState(this, logic); + private final StartPieceState startPieceState = new StartPieceState(this, logic); + private final WaitingPieceState waitingPieceState = new WaitingPieceState(this, logic); + + public ChoosePieceState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (TurnState) parent; + } + + @Override + public void enter() { + currentState = noPieceState; + } + + @Override + public void exit() { + + } + + public void setState(ChoosePieceStates state){ + currentState.exit(); + currentState = state; + currentState.enter(); + } + + public NoPieceState getNoPiece(){ + return noPieceState; + } + + public SelectPieceState getSelectPiece(){ + return selectPieceState; + } + + public StartPieceState getStartPiece(){ + return startPieceState; + } + + public WaitingPieceState getWaitingPiece(){ + return waitingPieceState; + } + + public TurnState getParent(){ + return parent; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/MovePieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/MovePieceState.java new file mode 100644 index 00000000..9747e656 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/MovePieceState.java @@ -0,0 +1,20 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class MovePieceState extends TurnStates { + public MovePieceState(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/PlayPowerCardState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PlayPowerCardState.java new file mode 100644 index 00000000..4457dd72 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PlayPowerCardState.java @@ -0,0 +1,32 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.TurnState; +import pp.mdga.message.server.PlayCardMessage; + +public class PlayPowerCardState extends TurnStates { + + private final TurnState parent; + + private PlayCardMessage playCardMessage; + + public PlayPowerCardState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (TurnState) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + playCardMessage = null; + } + + public void setPlayCard(PlayCardMessage playCardMessage) { + this.playCardMessage = playCardMessage; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCardState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCardState.java new file mode 100644 index 00000000..1a880df4 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/PowerCardState.java @@ -0,0 +1,57 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.TurnState; +import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCardState; +import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStates; +import pp.mdga.client.gameState.turnState.powerCardState.ShieldState; +import pp.mdga.client.gameState.turnState.powerCardState.SwapState; + +public class PowerCardState extends TurnStates { + + private final TurnState parent; + private PowerCardStates state; + + private final ChoosePowerCardState choosePowerCardState = new ChoosePowerCardState(this, logic); + private final ShieldState shieldState = new ShieldState(this, logic); + private final SwapState swapState = new SwapState(this, logic); + + + public PowerCardState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (TurnState) parent; + } + + @Override + public void enter() { + state = choosePowerCardState; + } + + @Override + public void exit() { + state = null; + } + + public void setState(PowerCardStates state) { + this.state.exit(); + state.enter(); + this.state = state; + } + + public ChoosePowerCardState getChoosePowerCard() { + return choosePowerCardState; + } + + public ShieldState getShield() { + return shieldState; + } + + public SwapState getSwap() { + return swapState; + } + + public TurnState getParent() { + return parent; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/RollDiceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/RollDiceState.java new file mode 100644 index 00000000..f83ba268 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/RollDiceState.java @@ -0,0 +1,20 @@ +package pp.mdga.client.gameState.turnState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class RollDiceState extends TurnStates { + public RollDiceState(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/NoPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/NoPieceState.java new file mode 100644 index 00000000..187fb4e5 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/NoPieceState.java @@ -0,0 +1,51 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.ChoosePieceState; +import pp.mdga.message.server.*; +import pp.mdga.message.server.StartPieceMessage; + +import java.util.ArrayList; +import java.util.stream.Collectors; + +public class NoPieceState extends ChoosePieceStates { + + private final ChoosePieceState parent; + + public NoPieceState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (ChoosePieceState) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + @Override + public void received(SelectPieceMessage msg) { + parent.setState(parent.getSelectPiece()); + parent.getSelectPiece().setPossiblePieces(msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new))); + } + + @Override + public void received(WaitPieceMessage msg){ + parent.setState(parent.getWaitingPiece()); + } + + @Override + public void received(StartPieceMessage msg){ + parent.setState(parent.getStartPiece()); + } + + @Override + public void received(NoTurnMessage msg){ + parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/SelectPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/SelectPieceState.java new file mode 100644 index 00000000..9b7e7513 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/SelectPieceState.java @@ -0,0 +1,47 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.ChoosePieceState; +import pp.mdga.game.Piece; +import pp.mdga.message.client.SelectedPiecesMessage; +import pp.mdga.message.server.MoveMessage; + +import java.util.ArrayList; + +public class SelectPieceState extends ChoosePieceStates { + + private final ChoosePieceState parent; + private ArrayList possiblePieces; + + public SelectPieceState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (ChoosePieceState) parent; + } + + @Override + public void enter() { + possiblePieces = new ArrayList<>(); + } + + @Override + public void exit() { + + } + + public void setPossiblePieces(ArrayList possiblePieces){ + this.possiblePieces = possiblePieces; + } + + @Override + public void selectPiece(Piece piece){ + if(possiblePieces.contains(piece)){ + logic.send(new SelectedPiecesMessage(piece.getIdentifier())); + } + } + + @Override + public void received(MoveMessage msg){ + parent.getParent().setState(parent.getParent().getMovePiece()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/StartPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/StartPieceState.java new file mode 100644 index 00000000..a4d3c34c --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/StartPieceState.java @@ -0,0 +1,42 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.ChoosePieceState; +import pp.mdga.game.Piece; +import pp.mdga.message.client.SelectedPiecesMessage; +import pp.mdga.message.server.MoveMessage; + +public class StartPieceState extends ChoosePieceStates { + + private final ChoosePieceState parent; + private Piece moveablePiece; + + + public StartPieceState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (ChoosePieceState) parent; + } + + @Override + public void enter() { + + } + + @Override + public void exit() { + + } + + @Override + public void selectPiece(Piece piece){ + if(moveablePiece.equals(piece)){ + logic.send(new SelectedPiecesMessage(piece.getIdentifier())); + } + } + + @Override + public void received(MoveMessage msg){ + parent.getParent().setState(parent.getParent().getMovePiece()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/WaitingPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/WaitingPieceState.java new file mode 100644 index 00000000..9ac3dff2 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/choosePieceState/WaitingPieceState.java @@ -0,0 +1,40 @@ +package pp.mdga.client.gameState.turnState.choosePieceState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.ChoosePieceState; +import pp.mdga.game.Piece; +import pp.mdga.message.client.SelectedPiecesMessage; +import pp.mdga.message.server.MoveMessage; + +public class WaitingPieceState extends ChoosePieceStates { + + private final ChoosePieceState parent; + private Piece moveablePiece; + + public WaitingPieceState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (ChoosePieceState) parent; + } + + @Override + public void enter() { + moveablePiece = null; + } + + @Override + public void exit() { + } + + @Override + public void selectPiece(Piece piece){ + if(moveablePiece.equals(piece)){ + logic.send(new SelectedPiecesMessage(piece.getIdentifier())); + } + } + + @Override + public void received(MoveMessage msg){ + parent.getParent().setState(parent.getParent().getMovePiece()); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ChoosePowerCardState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ChoosePowerCardState.java new file mode 100644 index 00000000..3ebb3107 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ChoosePowerCardState.java @@ -0,0 +1,66 @@ +package pp.mdga.client.gameState.turnState.powerCardState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.PowerCardState; +import pp.mdga.game.BonusCard; +import pp.mdga.message.client.NoPowerCardMessage; +import pp.mdga.message.client.SelectCardMessage; +import pp.mdga.message.server.DiceNowMessage; +import pp.mdga.message.server.PossibleCardMessage; +import pp.mdga.message.server.PossiblePieceMessage; + +import java.util.ArrayList; +import java.util.stream.Collectors; + +public class ChoosePowerCardState extends PowerCardStates { + + private final PowerCardState parent; + private ArrayList possibleCards; + + public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (PowerCardState) parent; + } + + @Override + public void enter() { + possibleCards = new ArrayList<>(); + } + + @Override + public void exit() { + possibleCards = null; + } + + @Override + public void received(PossibleCardMessage msg){ + possibleCards = (ArrayList) msg.getPossibleCards(); + } + + @Override + public void selectCard(BonusCard card){ + if(card != null){ + logic.send(new SelectCardMessage(card)); + } else { + logic.send(new NoPowerCardMessage()); + } + } + + @Override + public void received(DiceNowMessage msg){ + parent.getParent().setState(parent.getParent().getRollDice()); + } + + @Override + public void received(PossiblePieceMessage msg){ + if (msg.getEnemyPossiblePieces().isEmpty()){ + parent.setState(parent.getShield()); + parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new))); + } else { + parent.setState(parent.getSwap()); + parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new))); + parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new))); + } + } +} 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/ShieldState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ShieldState.java new file mode 100644 index 00000000..dfe1fc04 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/ShieldState.java @@ -0,0 +1,52 @@ +package pp.mdga.client.gameState.turnState.powerCardState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.PowerCardState; +import pp.mdga.game.Piece; +import pp.mdga.message.client.RequestPlayCardMessage; +import pp.mdga.message.server.PlayCardMessage; + +import java.lang.System.Logger.Level; +import java.util.ArrayList; + +public class ShieldState extends PowerCardStates { + + private final PowerCardState parent; + + private ArrayList possiblePieces; + + public ShieldState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (PowerCardState) parent; + } + + @Override + public void enter() { + possiblePieces = new ArrayList<>(); + } + + @Override + public void exit() { + possiblePieces = null; + } + + public void setPossiblePieces(ArrayList possiblePieces) { + this.possiblePieces = possiblePieces; + } + + public void selectPiece(Piece piece) { + if (possiblePieces.contains(piece)) { + logic.send(RequestPlayCardMessage.requestPlayShield(piece.getIdentifier())); + } else { + LOGGER.log(Level.DEBUG, "Invalid piece selected"); + } + } + + + @Override + public void received(PlayCardMessage msg) { + parent.getParent().setState(parent.getParent().getPlayPowerCard()); + parent.getParent().getPlayPowerCard().setPlayCard(msg); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/SwapState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/SwapState.java new file mode 100644 index 00000000..cce1556e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/turnState/powerCardState/SwapState.java @@ -0,0 +1,63 @@ +package pp.mdga.client.gameState.turnState.powerCardState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; +import pp.mdga.client.gameState.turnState.PowerCardState; +import pp.mdga.game.Piece; +import pp.mdga.message.client.RequestPlayCardMessage; +import pp.mdga.message.server.PlayCardMessage; + +import java.util.ArrayList; + +public class SwapState extends PowerCardStates { + + private final PowerCardState parent; + + private ArrayList possibleOwnPieces; + private ArrayList possibleEnemyPieces; + private Piece selectedOwnPiece; + private Piece selectedEnemyPiece; + + public SwapState(ClientState parent, ClientGameLogic logic) { + super(parent, logic); + this.parent = (PowerCardState) parent; + } + + @Override + public void enter() { + possibleOwnPieces = new ArrayList<>(); + possibleEnemyPieces = new ArrayList<>(); + } + + @Override + public void exit() { + possibleOwnPieces = null; + possibleEnemyPieces = null; + } + + public void setPossibleOwnPieces(ArrayList possibleOwnPieces) { + this.possibleOwnPieces = possibleOwnPieces; + } + + public void setPossibleEnemyPieces(ArrayList possibleEnemyPieces) { + this.possibleEnemyPieces = possibleEnemyPieces; + } + + @Override + public void selectPiece(Piece piece){ + if (possibleOwnPieces.contains(piece)){ + selectedOwnPiece = piece; + } else if (possibleEnemyPieces.contains(piece)){ + selectedEnemyPiece = piece; + } + if (selectedOwnPiece != null && selectedEnemyPiece != null){ + logic.send(RequestPlayCardMessage.requestPlaySwap(selectedOwnPiece.getIdentifier(), selectedEnemyPiece.getIdentifier())); + } + } + + @Override + public void received(PlayCardMessage msg) { + parent.getParent().setState(parent.getParent().getPlayPowerCard()); + parent.getParent().getPlayPowerCard().setPlayCard(msg); + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/AudioSettingsState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/AudioSettingsState.java new file mode 100644 index 00000000..63fa3fff --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/AudioSettingsState.java @@ -0,0 +1,20 @@ +package pp.mdga.client.settingsState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class AudioSettingsState extends SettingStates { + public AudioSettingsState(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/MainSettingsState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/MainSettingsState.java new file mode 100644 index 00000000..8e1b3f25 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/MainSettingsState.java @@ -0,0 +1,20 @@ +package pp.mdga.client.settingsState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class MainSettingsState extends ClientState { + public MainSettingsState(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/VideoSettingsState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/VideoSettingsState.java new file mode 100644 index 00000000..78b72f48 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/settingsState/VideoSettingsState.java @@ -0,0 +1,20 @@ +package pp.mdga.client.settingsState; + +import pp.mdga.client.ClientGameLogic; +import pp.mdga.client.ClientState; + +public class VideoSettingsState extends SettingStates { + public VideoSettingsState(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..b90fa4fe 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,145 @@ 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. + * This method will be used to return a piece based on the identifier. * - * @return true if the game is interrupted, false otherwise + * @return the piece specified by the identifier */ - public Boolean gameIsInterrupted() { - return gameIsInterrupted; + public Piece getPieceThroughIdentifier(String identifier){ + String[] parts = identifier.split("-"); + return board.getPlayerData().get(Color.valueOf(parts[0])).getPieces()[Integer.parseInt(parts[1])]; + } + + /** + * This method notifies the observers. + */ + 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 +234,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 +313,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 +332,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 89% 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 index 96d4419b..02939661 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/game/Piece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Piece.java @@ -1,5 +1,7 @@ package pp.mdga.game; +import java.util.UUID; + /** * This class will be used to hold all Piece relevant data. */ @@ -8,6 +10,7 @@ public class Piece { private PieceState state; private final Color color; private final int id; + private final UUID uuid = UUID.randomUUID(); /** * This constructor is used to create a new Piece @@ -93,4 +96,13 @@ public Color getColor() { public String getIdentifier() { return color.toString() + "-" + id; } + + /** + * This method is used to get the color of the piece + * + * @return the color of the piece + */ + public UUID getUuid() { + return uuid; + } } 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/AnimationEndMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/AnimationEndMessage.java new file mode 100644 index 00000000..ce605771 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/AnimationEndMessage.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 AnimationEndMessage extends ClientMessage { + /** + * Constructs an AnimationEnd message. + */ + public AnimationEndMessage() { + 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..073e307e --- /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(AnimationEndMessage 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(DeselectTSKMessage 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(StartGameMessage 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(JoinServerMessage 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(LeaveGameMessage 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(LobbyNotReadyMessage 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(LobbyReadyMessage 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(DisconnectedMessage 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(RequestBriefingMessage 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(RequestDieMessage 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(RequestMoveMessage 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(RequestPlayCardMessage 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(SelectCardMessage 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(SelectTSKMessage 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(ForceContinueGameMessage 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(ClientStartGameMessage 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(NoPowerCardMessage 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(SelectedPiecesMessage 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/ClientStartGameMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientStartGameMessage.java new file mode 100644 index 00000000..3839a139 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ClientStartGameMessage.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 ClientStartGameMessage extends ClientMessage { + /** + * Constructs a new ClientStartGame instance. + */ + public ClientStartGameMessage() { + 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/DeselectTSKMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/DeselectTSKMessage.java new file mode 100644 index 00000000..658227e2 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/DeselectTSKMessage.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 DeselectTSKMessage 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 DeselectTSKMessage(Color color) { + super(); + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private DeselectTSKMessage() { + 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/DisconnectedMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/DisconnectedMessage.java new file mode 100644 index 00000000..ee85fae3 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/DisconnectedMessage.java @@ -0,0 +1,34 @@ +package pp.mdga.message.client; + +import com.jme3.network.serializing.Serializable; + +/** + * + */ +@Serializable +public class DisconnectedMessage extends ClientMessage { + public DisconnectedMessage() { + 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/ForceContinueGameMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ForceContinueGameMessage.java new file mode 100644 index 00000000..e654ea77 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/ForceContinueGameMessage.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 ForceContinueGameMessage extends ClientMessage { + /** + * Constructs a new ForceContinueGame message. + */ + public ForceContinueGameMessage() { + 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/JoinServerMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/JoinServerMessage.java new file mode 100644 index 00000000..84f33051 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/JoinServerMessage.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 JoinServerMessage extends ClientMessage { + + private final String name; + + /** + * Constructs a new JoinServer instance. + */ + public JoinServerMessage(String name) { + super(); + this.name = name; + } + + /** + * Constructs a new JoinServer instance. + */ + public JoinServerMessage() { + 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/LeaveGameMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LeaveGameMessage.java new file mode 100644 index 00000000..48b2d324 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LeaveGameMessage.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 LeaveGameMessage extends ClientMessage { + /** + * Constructs a new LeaveGame instance. + */ + public LeaveGameMessage() { + 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/LobbyNotReadyMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyNotReadyMessage.java new file mode 100644 index 00000000..d0b966c8 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyNotReadyMessage.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 LobbyNotReadyMessage extends ClientMessage { + /** + * Constructs a new LobbyNotReady instance. + */ + public LobbyNotReadyMessage() { + 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/LobbyReadyMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyReadyMessage.java new file mode 100644 index 00000000..47da4de6 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/LobbyReadyMessage.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 LobbyReadyMessage extends ClientMessage { + /** + * Constructs a new LobbyReady instance. + */ + public LobbyReadyMessage() { + 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/NoPowerCardMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/NoPowerCardMessage.java new file mode 100644 index 00000000..c37f5787 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/NoPowerCardMessage.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 NoPowerCardMessage extends ClientMessage { + /** + * Constructs a new NoPowerCard instance. + */ + public NoPowerCardMessage() { + 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/RequestBriefingMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestBriefingMessage.java new file mode 100644 index 00000000..b47694ba --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestBriefingMessage.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 RequestBriefingMessage extends ClientMessage { + /** + * Constructs a new RequestBriefing instance. + */ + public RequestBriefingMessage() { + 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/RequestDieMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestDieMessage.java new file mode 100644 index 00000000..52e09924 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestDieMessage.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 RequestDieMessage extends ClientMessage { + /** + * Constructs a new RequestDie instance. + */ + public RequestDieMessage() { + 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/RequestMoveMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestMoveMessage.java new file mode 100644 index 00000000..17ab5a8b --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestMoveMessage.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 RequestMoveMessage extends ClientMessage { + /** + * The identifier for the piece. + */ + private final String pieceIdentifier; + + /** + * Constructor for RequestMove + * + * @param pieceIdentifier the piece identifier + */ + public RequestMoveMessage(String pieceIdentifier) { + this.pieceIdentifier = pieceIdentifier; + } + + /** + * Default constructor for serialization purposes. + */ + private RequestMoveMessage() { + 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/RequestPlayCardMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestPlayCardMessage.java new file mode 100644 index 00000000..d058e67e --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/RequestPlayCardMessage.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 RequestPlayCardMessage 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 RequestPlayCardMessage(BonusCard card, String ownPieceIdentifier, String enemyPieceIdentifier) { + this.ownPieceIdentifier = ownPieceIdentifier; + this.card = card; + this.enemyPieceIdentifier = enemyPieceIdentifier; + } + + /** + * Default constructor for serialization purposes. + */ + private RequestPlayCardMessage() { + 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 RequestPlayCardMessage requestPlaySwap(String ownPieceIdentifier, String enemyPieceIdentifier){ + return new RequestPlayCardMessage(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier); + } + + public static RequestPlayCardMessage requestPlayShield(String ownPieceIdentifier){ + return new RequestPlayCardMessage(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/SelectCardMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectCardMessage.java new file mode 100644 index 00000000..edf6804d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectCardMessage.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 SelectCardMessage 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 SelectCardMessage(BonusCard card) { + this.card = card; + } + + /** + * Default constructor for serialization purposes. + */ + private SelectCardMessage() { + 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/SelectTSKMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectTSKMessage.java new file mode 100644 index 00000000..846d8c4f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectTSKMessage.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 SelectTSKMessage 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 SelectTSKMessage(Color color) { + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private SelectTSKMessage() { + 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/SelectedPiecesMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectedPiecesMessage.java new file mode 100644 index 00000000..8b7150a9 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/SelectedPiecesMessage.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 SelectedPiecesMessage extends ClientMessage { + /** + * The piece identifier. + */ + private String pieceIdentifier; + + /** + * Constructor for SelectedPieces + * + * @param pieceIdentifier the piece identifier + */ + public SelectedPiecesMessage(String pieceIdentifier) { + this.pieceIdentifier = pieceIdentifier; + } + + /** + * Default constructor for serialization purposes. + */ + private SelectedPiecesMessage() { + 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/StartGameMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/StartGameMessage.java new file mode 100644 index 00000000..c2ff2ffb --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/client/StartGameMessage.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 StartGameMessage extends ClientMessage { + + private final boolean forceStartGame; + + public StartGameMessage(boolean forceStartGame){ + super(); + this.forceStartGame = forceStartGame; + } + + /** + * Constructs a new ForceStartGame message. + */ + public StartGameMessage() { + 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/ActivePlayerMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ActivePlayerMessage.java new file mode 100644 index 00000000..3c7e8961 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ActivePlayerMessage.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 ActivePlayerMessage extends ServerMessage { + /** + * The color of the active player. + */ + private final Color color; + + /** + * Constructor for ActivePlayer + * + * @param color the color of the active player + */ + public ActivePlayerMessage(Color color) { + super(); + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private ActivePlayerMessage() { + 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/AnyPieceMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/AnyPieceMessage.java new file mode 100644 index 00000000..56ff40e7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/AnyPieceMessage.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 AnyPieceMessage extends ServerMessage { + /** + * The list of pieces + */ + private final ArrayList piece; + + /** + * Constructor for AnyPiece + */ + public AnyPieceMessage() { + 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/BriefingMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/BriefingMessage.java new file mode 100644 index 00000000..1f077d61 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/BriefingMessage.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 BriefingMessage extends ServerMessage { + /** + * Constructs a new Briefing instance. + */ + public BriefingMessage() { + 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/DiceAgainMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/DiceAgainMessage.java new file mode 100644 index 00000000..09d57ffb --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/DiceAgainMessage.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 DiceAgainMessage extends ServerMessage { + /** + * Constructs a new DiceAgain instance. + */ + public DiceAgainMessage() { + 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/DiceNowMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/DiceNowMessage.java new file mode 100644 index 00000000..7a31fa38 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/DiceNowMessage.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 DiceNowMessage extends ServerMessage { + /** + * Constructs a new DiceNow instance. + */ + public DiceNowMessage() { + 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/DieMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/DieMessage.java new file mode 100644 index 00000000..d4d8c896 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/DieMessage.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 DieMessage 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 DieMessage(int diceEye, List moveablePieces) { + super(); + this.diceEye = diceEye; + this.moveablePieces = moveablePieces; + } + + /** + * Default constructor for serialization purposes. + */ + private DieMessage() { + diceEye = 0; + moveablePieces = null; + } + + /** + * Constructor for inactivePlayer + * + * @param diceEye the eye of the dice + * @return a new Dice object + */ + public static DieMessage inactivePlayer(int diceEye) { + return new DieMessage(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 DieMessage activePlayer(int diceEye, List moveablePieces) { + return new DieMessage(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/EndOfTurnMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/EndOfTurnMessage.java new file mode 100644 index 00000000..10dabd02 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/EndOfTurnMessage.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 EndOfTurnMessage extends ServerMessage { + /** + * Constructs a new EndOfTurn instance. + */ + public EndOfTurnMessage() { + 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/LobbyAcceptMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyAcceptMessage.java new file mode 100644 index 00000000..f3e16386 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyAcceptMessage.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 LobbyAcceptMessage extends ServerMessage { + /** + * Constructs a new LobbyAccept instance. + */ + public LobbyAcceptMessage() { + 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/LobbyDenyMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyDenyMessage.java new file mode 100644 index 00000000..e49057b7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyDenyMessage.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 LobbyDenyMessage extends ServerMessage { + /** + * Constructs a new LobbyDeny instance. + */ + public LobbyDenyMessage() { + 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/LobbyPlayerJoinMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerJoinMessage.java new file mode 100644 index 00000000..3bbb7640 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerJoinMessage.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 LobbyPlayerJoinMessage 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 LobbyPlayerJoinMessage(int id, String name) { + super(); + this.name = name; + this.id = id; + } + + /** + * Default constructor for serialization purposes. + */ + private LobbyPlayerJoinMessage() { + 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/LobbyPlayerLeaveMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerLeaveMessage.java new file mode 100644 index 00000000..75627e21 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/LobbyPlayerLeaveMessage.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 LobbyPlayerLeaveMessage 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 LobbyPlayerLeaveMessage(int id, Color color) { + super(); + this.id = id; + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private LobbyPlayerLeaveMessage() { + 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/NoTurnMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/NoTurnMessage.java new file mode 100644 index 00000000..8240b2b7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/NoTurnMessage.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 NoTurnMessage extends ServerMessage { + /** + * Constructs a new NoTurn instance. + */ + public NoTurnMessage() { + 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/PauseGameMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PauseGameMessage.java new file mode 100644 index 00000000..de9c6a8f --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PauseGameMessage.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 PauseGameMessage extends ServerMessage { + /** + * Constructs a new PauseGame instance. + */ + public PauseGameMessage() { + 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/PlayCardMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PlayCardMessage.java new file mode 100644 index 00000000..8c5717cf --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PlayCardMessage.java @@ -0,0 +1,122 @@ +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 PlayCardMessage 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 PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) { + super(); + this.card = card; + this.pieceIdentifier = pieceIdentifier; + this.pieceIdentifierEnemy = pieceIdentifierEnemy; + } + + /** + * Default constructor for serialization purposes. + */ + private PlayCardMessage() { + 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 PlayCardMessage swap(String pieceIdentifier, String pieceIdentifierEnemy) { + return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy); + } + + /** + * 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 PlayCardMessage shield(String pieceIdentifier) { + return new PlayCardMessage(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/PossibleCardMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PossibleCardMessage.java new file mode 100644 index 00000000..bceea4d7 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PossibleCardMessage.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 PossibleCardMessage extends ServerMessage { + /** + * The list of possible cards. + */ + private final List possibleCards; + + /** + * Constructor for a PossibleCard instance. + */ + public PossibleCardMessage() { + 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/PossiblePieceMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PossiblePieceMessage.java new file mode 100644 index 00000000..8e47498a --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/PossiblePieceMessage.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 PossiblePieceMessage 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 PossiblePieceMessage() { + 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 PossiblePieceMessage swapPossiblePieces(ArrayList possibleOwnPieces, ArrayList possibleEnemyPieces) { + PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage(); + possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces); + possiblePieceMessage.possibleEnemyPieces.addAll(possibleEnemyPieces); + return possiblePieceMessage; + } + + /** + * Get the possible pieces for the shield + * + * @param possibleOwnPieces the list of possible own pieces + * @return the possible pieces for the shield + */ + public static PossiblePieceMessage shieldPossiblePieces(ArrayList possibleOwnPieces){ + PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage(); + possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces); + return possiblePieceMessage; + } + + /** + * 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/RankingResponseMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/RankingResponseMessage.java new file mode 100644 index 00000000..397ddcb1 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/RankingResponseMessage.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 RankingResponseMessage extends ServerMessage { + /** + * Constructs a new RankingResponse instance. + */ + public RankingResponseMessage() { + 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/RankingRollAgainMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/RankingRollAgainMessage.java new file mode 100644 index 00000000..f89df585 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/RankingRollAgainMessage.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 RankingRollAgainMessage extends ServerMessage { + /** + * Constructs a new RankingRollAgain instance. + */ + public RankingRollAgainMessage() { + 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/ReconnectBriefingMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ReconnectBriefingMessage.java new file mode 100644 index 00000000..4a1495e6 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ReconnectBriefingMessage.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 ReconnectBriefingMessage extends ServerMessage { + /** + * The game. + */ + private final Game game; + + /** + * Constructs a new ReconnectBriefing message. + */ + public ReconnectBriefingMessage(Game game) { + super(); + this.game = game; + } + + /** + * Default constructor for serialization purposes. + */ + private ReconnectBriefingMessage() { + 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/ResumeGameMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ResumeGameMessage.java new file mode 100644 index 00000000..c95541c0 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ResumeGameMessage.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 ResumeGameMessage extends ServerMessage { + /** + * Constructs a new ResumeGame instance. + */ + public ResumeGameMessage() { + 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/SelectPieceMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/SelectPieceMessage.java new file mode 100644 index 00000000..b1220d8d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/SelectPieceMessage.java @@ -0,0 +1,56 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +import java.util.List; + +@Serializable +public class SelectPieceMessage extends ServerMessage{ + + private final List pieces; + + /** + * Constructs a new SelectPiece instance. + * + * @param pieces the pieces to be selected + */ + public SelectPieceMessage(List pieces){ + this.pieces = pieces; + } + + /** + * Default constructor for serialization purposes. + */ + public SelectPieceMessage(){ + pieces = null; + } + + /** + * Getter for the pieces + * + * @return the pieces + */ + public List getPieces(){ + return pieces; + } + + /** + * Accepts a visitor to process this message. + * + * @param interpreter the visitor to process this message + */ + @Override + public void accept(ServerInterpreter interpreter) { + + } + + /** + * Returns a string representation of this message. + * + * @return a string representation 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..9af7d6d9 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerInterpreter.java @@ -0,0 +1,210 @@ +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(ActivePlayerMessage msg); + + /** + * Handles an AnyPiece message received from the server. + * + * @param msg the AnyPiece message received + */ + void received(AnyPieceMessage msg); + + /** + * Handles a Briefing message received from the server. + * + * @param msg the Briefing message received + */ + void received(BriefingMessage 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(DieMessage msg); + + /** + * Handles a DiceAgain message received from the server. + * + * @param msg the DiceAgain message received + */ + void received(DiceAgainMessage msg); + + /** + * Handles a DiceNow message received from the server. + * + * @param msg the DiceNow message received + */ + void received(DiceNowMessage msg); + + /** + * Handles an EndOfGame message received from the server. + * + * @param msg the EndOfGame message received + */ + void received(EndOfTurnMessage msg); + + /** + * Handles a GameOver message received from the server. + * + * @param msg the GameOver message received + */ + void received(LobbyAcceptMessage msg); + + /** + * Handles a LobbyDeny message received from the server. + * + * @param msg the LobbyDeny message received + */ + void received(LobbyDenyMessage msg); + + /** + * Handles a LobbyPlayerJoin message received from the server. + * + * @param msg the LobbyPlayerJoin message received + */ + void received(LobbyPlayerJoinMessage msg); + + /** + * Handles a LobbyPlayerLeave message received from the server. + * + * @param msg the LobbyPlayerLeave message received + */ + void received(LobbyPlayerLeaveMessage 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(NoTurnMessage msg); + + /** + * Handles a PauseGame message received from the server. + * + * @param msg the PauseGame message received + */ + void received(PauseGameMessage msg); + + /** + * Handles a PlayCard message received from the server. + * + * @param msg the PlayCard message received + */ + void received(PlayCardMessage msg); + + /** + * Handles a PossibleCard message received from the server. + * + * @param msg the PossibleCard message received + */ + void received(PossibleCardMessage msg); + + /** + * Handles a PossiblePiece message received from the server. + * + * @param msg the PossiblePiece message received + */ + void received(PossiblePieceMessage msg); + + /** + * Handles a RankingResponce message received from the server. + * + * @param msg the RankingResponce message received + */ + void received(RankingResponseMessage msg); + + /** + * Handles a RankingRollAgain message received from the server. + * + * @param msg the RankingRollAgain message received + */ + void received(RankingRollAgainMessage msg); + + /** + * Handles a ReconnectBriefing message received from the server. + * + * @param msg the ReconnectBriefing message received + */ + void received(ReconnectBriefingMessage msg); + + /** + * Handles a ResumeGame message received from the server. + * + * @param msg the ResumeGame message received + */ + void received(ResumeGameMessage msg); + + /** + * Handles a ServerStartGame message received from the server. + * + * @param msg the ServerStartGame message received + */ + void received(ServerStartGameMessage msg); + + /** + * Handles a StartPiece message received from the server. + * + * @param msg the StartPiece message received + */ + void received(StartPieceMessage msg); + + /** + * Handles a UpdateReady message received from the server. + * + * @param msg the UpdateReady message received + */ + void received(UpdateReadyMessage msg); + + /** + * Handles a UpdateTSK message received from the server. + * + * @param msg the UpdateTSK message received + */ + void received(UpdateTSKMessage msg); + + /** + * Handles a WaitPiece message received from the server. + * + * @param msg the WaitPiece message received + */ + void received(WaitPieceMessage msg); + + /** + * Handles a Spectator message received from the server. + * + * @param msg the Spectator message received. + */ + void received(SpectatorMessage msg); + + /** + * Handles a SelectPiece message received from the server. + * + * @param msg the SelectPiece message received. + */ + void received(SelectPieceMessage 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/ServerStartGameMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerStartGameMessage.java new file mode 100644 index 00000000..ac448825 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/ServerStartGameMessage.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 ServerStartGameMessage extends ServerMessage { + /** + * Constructs a new ServerStartGame instance. + */ + public ServerStartGameMessage() { + 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/SpectatorMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/SpectatorMessage.java new file mode 100644 index 00000000..6ebc7b23 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/SpectatorMessage.java @@ -0,0 +1,32 @@ +package pp.mdga.message.server; + +/** + * + */ +public class SpectatorMessage extends ServerMessage { + /** + * Construc + */ + public SpectatorMessage() { + 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/StartPieceMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/StartPieceMessage.java new file mode 100644 index 00000000..51910961 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/StartPieceMessage.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 StartPieceMessage 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 StartPieceMessage(String pieceIdentifier) { + super(); + this.pieceIdentifier = pieceIdentifier; + } + + /** + * Default constructor for serialization purposes. + */ + private StartPieceMessage() { + 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/UpdateReadyMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/UpdateReadyMessage.java new file mode 100644 index 00000000..d8d53313 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/UpdateReadyMessage.java @@ -0,0 +1,88 @@ +package pp.mdga.message.server; + +import com.jme3.network.serializing.Serializable; + +/** + * A message sent by the server to every client to update the readiness status of a player. + */ +@Serializable +public class UpdateReadyMessage 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 UpdateReadyMessage(int playerId, boolean ready) { + super(); + this.playerId = playerId; + this.ready = ready; + } + + /** + * Default constructor for serialization purposes. + */ + private UpdateReadyMessage() { + 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/UpdateTSKMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/UpdateTSKMessage.java new file mode 100644 index 00000000..8597a1e2 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/UpdateTSKMessage.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 UpdateTSKMessage 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 UpdateTSKMessage(int id, Color color) { + super(); + this.id = id; + this.color = color; + } + + /** + * Default constructor for serialization purposes. + */ + private UpdateTSKMessage() { + 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/WaitPieceMessage.java b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/WaitPieceMessage.java new file mode 100644 index 00000000..42743ece --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/message/server/WaitPieceMessage.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 WaitPieceMessage extends ServerMessage { + /** + * Constructs a new WaitPiece instance. + */ + public WaitPieceMessage() { + 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 89% 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 index e557e8ce..4efdb343 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/ActivePlayerNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/ActivePlayerNotification.java @@ -12,7 +12,7 @@ public class ActivePlayerNotification extends Notification { */ private Color color; - ActivePlayerNotification(Color color) { + public ActivePlayerNotification(Color color) { this.color = color; } 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 new file mode 100644 index 00000000..20a270dc --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/CeremonyNotification.java @@ -0,0 +1,12 @@ +package pp.mdga.notification; + +/** + * Class CeremonyNotification + */ +public class CeremonyNotification extends Notification{ + /** + * Constructor + */ + public CeremonyNotification() { + } +} 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 83% 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 index fce8c9b1..68064cfe 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/DiceNowNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/DiceNowNotification.java @@ -8,6 +8,6 @@ public class DiceNowNotification extends Notification { /** * Constructor. */ - DiceNowNotification() { + public DiceNowNotification() { } } 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 91% 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 index 5c1c7ecf..4e9f3145 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/DicingNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/DicingNotification.java @@ -13,7 +13,7 @@ public class DicingNotification extends Notification{ * Constructor. * @param color The color of the player that diced. */ - DicingNotification(Color color) { + public DicingNotification(Color color) { this.color = color; } 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 91% 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 index 2de500c0..5114fd15 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/DrawCardNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/DrawCardNotification.java @@ -15,7 +15,7 @@ public class DrawCardNotification extends Notification { * @param color the color of the player who drew the card * @param card the card that was drawn */ - DrawCardNotification(Color color, BonusCard card) { + public DrawCardNotification(Color color, BonusCard card) { this.color = color; this.card = card; } 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 83% 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 index 90c60694..d1864bbd 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/GameNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/GameNotification.java @@ -7,6 +7,6 @@ public class GameNotification extends Notification{ /** * Constructor */ - GameNotification() { + public GameNotification() { } } 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 91% 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 index 48cecc52..ffa7d2e1 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/HomeMoveNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/HomeMoveNotification.java @@ -16,7 +16,7 @@ public class HomeMoveNotification extends Notification { * @param pieceId the piece id * @param homeIndex the home index */ - HomeMoveNotification(UUID pieceId, int homeIndex) { + public HomeMoveNotification(UUID pieceId, int homeIndex) { this.pieceId = pieceId; this.homeIndex = homeIndex; } 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 66% 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 index e9a61de6..bb8fb784 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/InterruptNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/InterruptNotification.java @@ -10,14 +10,14 @@ public class InterruptNotification extends Notification { private Color color; /** - * @param color the color of the player who drew the card + * @param color the color of the player who disconnected */ - InterruptNotification(Color color) { + public InterruptNotification(Color color) { this.color = color; } /** - * @return the color of the player who drew the card + * @return the color of the player who disconnected */ public Color getColor() { return color; 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 82% 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 index 7c1a4adf..dcea5094 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/LobbyDialogNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/LobbyDialogNotification.java @@ -7,6 +7,6 @@ public class LobbyDialogNotification extends Notification{ /** * Constructor */ - LobbyDialogNotification() { + public LobbyDialogNotification() { } } 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/NoShieldNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/NoShieldNotification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/NoShieldNotification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/NoShieldNotification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/Notification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/Notification.java similarity index 100% rename from Projekte/mdga/model/src/main/java/pp.mdga/notification/Notification.java rename to Projekte/mdga/model/src/main/java/pp/mdga/notification/Notification.java diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/PlayCardNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/PlayCardNotification.java similarity index 92% 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 index d554a0e6..dd9cf9d4 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/PlayCardNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/PlayCardNotification.java @@ -16,7 +16,7 @@ public class PlayCardNotification extends Notification { * @param color the color of the player that played the card. * @param card the card that was played. */ - PlayCardNotification(Color color, BonusCard card) { + public PlayCardNotification(Color color, BonusCard card) { this.color = color; this.card = card; } 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 92% 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 index 98533e06..5ef4bd34 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/ResumeNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/ResumeNotification.java @@ -13,7 +13,7 @@ public class ResumeNotification extends Notification { * Constructor. * @param color the color of the player that is in the game. */ - ResumeNotification(Color color) { + public ResumeNotification(Color color) { this.color = color; } 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 93% 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 index b6bd27c3..3f778d3f 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/RollDiceNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/RollDiceNotification.java @@ -17,7 +17,7 @@ public class RollDiceNotification extends Notification{ * @param eyes the number of eyes that were rolled. * @param moveNumber the number of the move that was made. */ - RollDiceNotification(Color color, int eyes, int moveNumber) { + public RollDiceNotification(Color color, int eyes, int moveNumber) { this.color = color; this.eyes = eyes; this.moveNumber = moveNumber; 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 90% 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 index 925bde75..308edce2 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/SelectableCardsNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableCardsNotification.java @@ -14,7 +14,7 @@ public class SelectableCardsNotification extends Notification { * Constructor. * @param cards The list of cards that the player can choose from. */ - SelectableCardsNotification(List cards) { + public SelectableCardsNotification(List cards) { this.cards = cards; } 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 82% 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 index f2458c14..3e72cc29 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/StartDialogNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/StartDialogNotification.java @@ -7,6 +7,6 @@ public class StartDialogNotification extends Notification{ /** * Constructor */ - StartDialogNotification() { + public StartDialogNotification() { } } 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 63% 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 index 7fe09660..ad81f2f8 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/ThrowPieceNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/ThrowPieceNotification.java @@ -4,14 +4,17 @@ import java.util.UUID; -public class ThrowPieceNotification extends Notification { +public class ThrowPieceNotification extends Notification{ private UUID pieceId; /** * This constructor is used to create a new ThrowPieceNotification * - * @param pieceId the pieceId + * @param pieceId1 the pieceId1 + * @param pieceId2 the pieceId2 + * @param nodeIndex the nodeIndex + * @param colorPiece2 the color */ public ThrowPieceNotification(UUID pieceId) { this.pieceId = pieceId; 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 93% 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 index 826bb7a5..5b99f0e7 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/TskSelectNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/TskSelectNotification.java @@ -17,7 +17,7 @@ public class TskSelectNotification extends Notification{ * @param name the name of the player that is in the game. * @param self true if it was the local player selecting the tsk, false otherwise */ - public TskSelectNotification(Color color, String name, boolean self) { + TskSelectNotification(Color color, String name, boolean self) { this.color = color; this.name = name; this.self = self; 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 87% 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 index 0f96beb1..4a036d46 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/TskUnselectNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/TskUnselectNotification.java @@ -10,7 +10,7 @@ public class TskUnselectNotification extends Notification{ * Constructor * @param color */ - TskUnselectNotification(Color color){ + public TskUnselectNotification(Color color){ this.color = color; } 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..ac2b048c --- /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(AnimationEndMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(DeselectTSKMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(StartGameMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(JoinServerMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(LeaveGameMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(LobbyReadyMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(LobbyNotReadyMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(DisconnectedMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(RequestBriefingMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(RequestDieMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(RequestMoveMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(RequestPlayCardMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(SelectCardMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(SelectTSKMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(ForceContinueGameMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(ClientStartGameMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(NoPowerCardMessage msg, int from) { + this.currentState.received(msg, from); + } + + @Override + public void received(SelectedPiecesMessage 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..a95ebdb7 --- /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.DisconnectedMessage; +import pp.mdga.message.client.LeaveGameMessage; +import pp.mdga.message.server.PauseGameMessage; +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(DisconnectedMessage msg, int from) { + this.logic.getServerSender().broadcast(new PauseGameMessage()); + 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(LeaveGameMessage 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..59dfb299 --- /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.ForceContinueGameMessage; +import pp.mdga.message.server.ResumeGameMessage; +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(ForceContinueGameMessage msg, int from) { + this.logic.getServerSender().broadcast(new ResumeGameMessage()); + 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..a1bfaacf --- /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.ServerStartGameMessage; +import pp.mdga.message.server.UpdateReadyMessage; +import pp.mdga.message.server.UpdateTSKMessage; +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(SelectTSKMessage msg, int from) { + this.logic.getServerSender().broadcast(new UpdateTSKMessage(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(DeselectTSKMessage msg, int from) { + this.logic.getServerSender().broadcast(new UpdateTSKMessage(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(LobbyReadyMessage msg, int from) { + this.logic.getServerSender().broadcast(new UpdateReadyMessage(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(LobbyNotReadyMessage msg, int from) { + this.logic.getServerSender().broadcast(new UpdateReadyMessage(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(StartGameMessage msg, int from) { + this.logic.getServerSender().broadcast(new ServerStartGameMessage()); + 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..7eac2f52 --- /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(AnimationEndMessage 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(DeselectTSKMessage 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(StartGameMessage 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(JoinServerMessage 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(LeaveGameMessage 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(LobbyReadyMessage 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(LobbyNotReadyMessage 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(DisconnectedMessage 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(RequestBriefingMessage 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(RequestDieMessage 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(RequestMoveMessage 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(RequestPlayCardMessage 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(SelectCardMessage 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(SelectTSKMessage 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(ForceContinueGameMessage 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(ClientStartGameMessage 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(NoPowerCardMessage 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(SelectedPiecesMessage 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..c5c84b68 --- /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.CeremonyState; +import pp.mdga.client.ceremonyState.PodiumState; +import pp.mdga.client.ceremonyState.StatisticsState; +import pp.mdga.client.dialogState.LobbyState; +import pp.mdga.client.dialogState.NetworkDialogState; +import pp.mdga.client.dialogState.StartDialogState; +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.ChoosePowerCardState; +import pp.mdga.client.gameState.turnState.powerCardState.ShieldState; +import pp.mdga.client.gameState.turnState.powerCardState.SwapState; +import pp.mdga.client.SettingsState; +import pp.mdga.client.settingsState.AudioSettingsState; +import pp.mdga.client.settingsState.MainSettingsState; +import pp.mdga.client.settingsState.VideoSettingsState; +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 AnimationState animationState; + private AudioSettingsState audioSettingsState; + private CeremonyState ceremonyState; + private CeremonyStateMachine ceremonyStateMachine; + private ChoosePieceState choosePieceState; + private ChoosePieceStateMachine choosePieceStateMachine; + private ChoosePowerCardState choosePowerCardState; + private ClientAutomaton clientAutomaton; + private ClientGameLogic clientGameLogic; + private DetermineStartPlayerState determineStartPlayerState; + private DetermineStartPlayerStateMachine determineStartPlayerStateMachine; + private DialogsState dialogsState; + private DialogsStateMachine dialogsStateMachine; + private GameState gameState; + private GameStateMachine gameStateMachine; + private InterruptState interruptState; + private LobbyState lobbyState; + private MainSettingsState mainSettingsState; + private MovePieceState movePieceState; + private NetworkDialogState networkDialogState; + private NoPieceState noPieceState; + private PlayPowerCardState playPowerCardState; + private PodiumState podium; + private PowerCardState powerCardState; + private PowerCardStateMachine powerCardStateMachine; + private RollDiceState rollDiceState; + private RollRankingDice rollRankingDice; + private SelectPieceState selectPieceState; + private SettingsState settingsState; + private SettingsStateMachine settingsStateMachine; + private ShieldState shieldState; + private SpectatorState spectatorState; + private StartDialogState startDialogState; + private StartPieceState startPieceState; + private StatisticsState statistics; + private SwapState swapState; + private TurnState turnState; + private TurnStateMachine turnStateMachine; + private VideoSettingsState videoSettingsState; + private WaitingState waitingState; + private WaitingPieceState waitingPieceState; + 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 StartPieceState startPieceStateMessage; + 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(); + startPieceStateMessage = new StartPieceState(); //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 + mainSettingsState = new MainSettingsState(settingsStateMachine,clientGameLogic); + videoSettingsState = new VideoSettingsState(settingsStateMachine,clientGameLogic); + audioSettingsState = new AudioSettingsState(settingsStateMachine,clientGameLogic); + settingsState = new SettingsState(clientAutomaton,clientGameLogic); + + + //initialize the stateMachines + ceremonyStateMachine = ceremonyState.getCeremonyStateMachine(); + choosePieceStateMachine = choosePieceState.getChoosePieceStateMachine(); + determineStartPlayerStateMachine = determineStartPlayerState.getDetermineStartPlayerStateMachine(); + dialogsStateMachine = dialogsState.getDialogsStateMachine(); + gameStateMachine = gameState.getGameStateMachine(); + powerCardStateMachine = powerCardState.getPowerCardStateMachine(); + settingsStateMachine = settingsState.getSettingsStateMachine(); + turnStateMachine = turnState.getTurnStateMachine(); + + + //initialize the states + dialogsState = new DialogsState(clientAutomaton,clientGameLogic); + gameState = new GameState(clientAutomaton,clientGameLogic); + ceremonyState = new CeremonyState(clientAutomaton,clientGameLogic); + interruptState = new InterruptState(clientAutomaton,clientGameLogic,gameState); + + startDialogState = new StartDialogState(dialogsStateMachine,clientGameLogic); + networkDialogState = new NetworkDialogState(dialogsStateMachine,clientGameLogic); + lobbyState = new LobbyState(dialogsStateMachine,clientGameLogic); + + podium = new PodiumState(ceremonyStateMachine,clientGameLogic); + statistics = new StatisticsState(ceremonyStateMachine,clientGameLogic); + + determineStartPlayerState = new DetermineStartPlayerState(gameStateMachine,clientGameLogic); + waitingState = new WaitingState(gameStateMachine,clientGameLogic); + animationState = new AnimationState(gameStateMachine,clientGameLogic); + turnState = new TurnState(gameStateMachine,clientGameLogic); + spectatorState = new SpectatorState(gameStateMachine,clientGameLogic); + + rollRankingDice = new RollRankingDice(determineStartPlayerStateMachine,clientGameLogic); + waitRanking = new WaitRanking(determineStartPlayerStateMachine,clientGameLogic); + + powerCardState = new PowerCardState(turnStateMachine,clientGameLogic); + playPowerCardState = new PlayPowerCardState(turnStateMachine,clientGameLogic); + rollDiceState = new RollDiceState(turnStateMachine,clientGameLogic); + choosePieceState = new ChoosePieceState(turnStateMachine,clientGameLogic); + movePieceState = new MovePieceState(turnStateMachine,clientGameLogic); + + choosePowerCardState = new ChoosePowerCardState(powerCardStateMachine,clientGameLogic); + shieldState =new ShieldState(powerCardStateMachine,clientGameLogic); + swapState = new SwapState(powerCardStateMachine,clientGameLogic); + + noPieceState = new NoPieceState(choosePieceStateMachine,clientGameLogic); + waitingPieceState = new WaitingPieceState(choosePieceStateMachine,clientGameLogic); + selectPieceState = new SelectPieceState(choosePieceStateMachine,clientGameLogic); + startPieceState = new StartPieceState(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 DialogsState); + DialogsState dialogsState = (DialogsState) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = dialogsState.getDialogsStateMachine(); + //tests if the statemachine is in StartDialog + assertNotEquals(dialogsStateMachine1.getState(), null); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialogState); + } + + /** + * 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(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //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 DetermineStartPlayerState); + + //tests if the new State of DetermineStartPlayer is RollRankingDice + DetermineStartPlayerState determineStartPlayerState1 =(DetermineStartPlayerState) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayerState1.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 CeremonyState); + + //tests if the state of ceremony is Podium + CeremonyState ceremonyState1 = (CeremonyState) clientAutomaton.getState(); + CeremonyStateMachine ceremonyStateMachine1 = ceremonyState1.getCeremonyStateMachine(); + assertTrue(ceremonyStateMachine1.getState() instanceof PodiumState); + } + + /** + * 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(interruptState); + + //tests if the client-automaton is in the interrupt state + assertTrue(clientAutomaton.getState() instanceof InterruptState); + } + + /** + * 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(interruptState); + assertTrue(clientAutomaton.getState() instanceof InterruptState); + + //Todo send all messages except the continue-message + + assertTrue(clientAutomaton.getState() instanceof InterruptState); + } + + /** + * UC-ClientState-08: Test the transition from ClientInterrupt to the game state. + */ + @Test + public void testClientInterruptToGame() { + //sends the ClientAutomaton in Interrupt + clientAutomaton.gotoState(interruptState); + assertTrue(clientAutomaton.getState() instanceof InterruptState); + + //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(interruptState); + assertTrue(clientAutomaton.getState() instanceof InterruptState); + + //Todo send the server-closed message and the leave option + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + DialogsState dialogsState1 = (DialogsState) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = dialogsState1.getDialogsStateMachine(); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialogState); + } + + /** + * UC-ClientState-10: Test the transition from Ceremony to dialogs. + */ + @Test + public void testCeremonyToDialogs() { + //send the client in the ceremony + clientAutomaton.gotoState(ceremonyState); + assertTrue(clientAutomaton.getState() instanceof CeremonyState); + + //sends the ceremony machine in the statistics + ceremonyStateMachine.gotoState(statistics); + assertTrue(ceremonyStateMachine.getState() instanceof StatisticsState); + + //Todo simulate the button next + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + DialogsState dialogsState1 = (DialogsState) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = dialogsState1.getDialogsStateMachine(); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialogState); + } + + /** + * UC-ClientState-11: Test the transition from StartDialog to NetworkDialog1. + */ + @Test + public void testStartDialogToNetworkDialog1() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the DialogsStateMachine in StartDialog + dialogsStateMachine.gotoState(startDialogState); + assertTrue(dialogsStateMachine.getState() instanceof StartDialogState); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + } + + /** + * UC-ClientState-12: Test the transition from StartDialog to NetworkDialog2. + */ + @Test + public void testStartDialogToNetworkDialog2() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the DialogsStateMachine in StartDialog + dialogsStateMachine.gotoState(startDialogState); + assertTrue(dialogsStateMachine.getState() instanceof StartDialogState); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + } + + /** + * 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(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialogState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + + //todo simulate pushBtn + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof StartDialogState); + } + + /** + * UC-ClientState-15: Test the transition from NetworkDialog to NetworkDialog1. + */ + @Test + public void testNetworkDialogToNetworkDialog1() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialogState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + + //todo test receiving all messages and making input + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + } + + /** + * UC-ClientState-16: Test the transition from NetworkDialog to NetworkDialog2. + */ + @Test + public void testNetworkDialogToNetworkDialog2() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialogState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + + //todo simulate try connect to server ith wrong variables + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + + //todo simulate try connect to server with send: join-lobby and receive lobby-refuse-message + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + } + + /** + * UC-ClientState-17: Test the transition from NetworkDialog to Lobby. + */ + @Test + public void testNetworkDialogToLobby() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialogState); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialogState); + + //todo simulate connect to server with send lobby request + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof LobbyState); + } + + /** + * UC-ClientState-18: Test the transition from Lobby to StartDialog. + */ + @Test + public void testLobbyToStartDialog() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the DialogsStateMachine in Lobby + dialogsStateMachine.gotoState(lobbyState); + assertTrue(dialogsStateMachine.getState() instanceof LobbyState); + + //todo simulate leave the lobby + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof StartDialogState); + } + + /** + * UC-ClientState-19: Test remaining in the Lobby state. + */ + @Test + public void testStayInLobby() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the DialogsStateMachine in Lobby + dialogsStateMachine.gotoState(lobbyState); + assertTrue(dialogsStateMachine.getState() instanceof LobbyState); + + //todo send all messages that dont indicate a change-state + + assertTrue(clientAutomaton.getState() instanceof DialogsState); + assertTrue(dialogsStateMachine.getState() instanceof LobbyState); + } + + /** + * UC-ClientState-20: Test the transition from Lobby to RollRankingDice. + */ + @Test + public void testLobbyToRollRankingDice() { + //sends the clientStatemachine in Dialogs + clientAutomaton.gotoState(dialogsState); + assertTrue(clientAutomaton.getState() instanceof DialogsState); + + //sends the clientStatemachine in Lobby + dialogsStateMachine.gotoState(lobbyState); + assertTrue(dialogsStateMachine.getState() instanceof LobbyState); + + //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 DetermineStartPlayerState); + + //tests if the clientStateMachine is in the RollRankingDice + DetermineStartPlayerState determineStartPlayerState1 = (DetermineStartPlayerState) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayerState1.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(waitingState); + assertTrue(gameStateMachine.getState() instanceof WaitingState); + + //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 AnimationState); + + //sends the client in WaitState + gameStateMachine.gotoState(waitingState); + assertTrue(gameStateMachine.getState() instanceof WaitingState); + + //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 AnimationState); + + //sends the client in WaitState + gameStateMachine.gotoState(waitingState); + assertTrue(gameStateMachine.getState() instanceof WaitingState); + + //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 AnimationState); + } + + /** + * 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(waitingState); + assertTrue(gameStateMachine.getState() instanceof WaitingState); + + //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 TurnState); + + //tests if Client is in PowerCard + TurnStateMachine turnStateMachine1 = turnState.getTurnStateMachine(); + assertTrue(turnStateMachine1.getState() instanceof PowerCardState); + + //tests if Client is in ChoosePowerCard + PowerCardStateMachine powerCardStateMachine1 = powerCardState.getPowerCardStateMachine(); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCardState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in PlayPowerCard + turnStateMachine.gotoState(playPowerCardState); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCardState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCardState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in PlayPowerCard + turnStateMachine.gotoState(playPowerCardState); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCardState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCardState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + + //sends the turnStatemachine in ChoosePiece + powerCardStateMachine.gotoState(choosePowerCardState); + assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCardState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof RollDiceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCardState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + + //sends the turnStatemachine in ChoosePiece + powerCardStateMachine.gotoState(choosePowerCardState); + assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCardState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + assertTrue(powerCardStateMachine.getState() instanceof SwapState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCardState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + + //sends the turnStatemachine in ChoosePiece + powerCardStateMachine.gotoState(choosePowerCardState); + assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCardState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + assertTrue(powerCardStateMachine.getState() instanceof ShieldState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCardState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + + //sends the turnStatemachine in Shield + powerCardStateMachine.gotoState(shieldState); + assertTrue(powerCardStateMachine.getState() instanceof ShieldState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + assertTrue(powerCardStateMachine.getState() instanceof PlayPowerCardState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCardState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + + //sends the turnStatemachine in Shield + PowerCardStateMachine powerCardStateMachine1 = powerCardState.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(shieldState); + assertTrue(powerCardStateMachine1.getState() instanceof ShieldState); + + //todo send the message to force the statechange + + //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCardState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCardState); + assertTrue(turnStateMachine.getState() instanceof PowerCardState); + + //sends the turnStatemachine in Swap + powerCardStateMachine.gotoState(swapState); + assertTrue(powerCardStateMachine.getState() instanceof SwapState); + + //todo send the message to force the statechange + + //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCardState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in NoPiece + turnStateMachine.gotoState(noPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message SelectPiece + clientGameLogic.receive(selectPieceState); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message StartPiece + clientGameLogic.receive(startPieceState); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof WaitingState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in WaitingPiece + choosePieceStateMachine.gotoState(waitingPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + + //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 TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in WaitingPiece + choosePieceStateMachine.gotoState(waitingPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + + //Todo send the message to the clientGameLogic to force a state change + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof MovePieceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in SelectPiece; + choosePieceStateMachine.gotoState(selectPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + + //Todo send all server messages which dont force a state change here + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in SelectPiece + choosePieceStateMachine.gotoState(selectPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + + //Todo send the message which force a state change + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof MovePieceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in StartPiece + choosePieceStateMachine.gotoState(startPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + + //todo send all messages which dont force a state change + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + } + + /** + * 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(turnState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePieceState); + assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + + //sends the choosePieceStatemachine in StartPiece + choosePieceStateMachine.gotoState(startPieceState); + assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + + //Todo send the message which force a state change + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof TurnState); + assertTrue(turnStateMachine.getState() instanceof MovePieceState); + } + + /** + * 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 + } +}