diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/ActionControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/ActionControl.java index eb741e9e..542a1f9c 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/ActionControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/ActionControl.java @@ -12,7 +12,8 @@ public ActionControl(Runnable runnable){ protected void action(){ - if(runnable == null) throw new RuntimeException("runnable is null"); - else runnable.run(); + if(null != runnable) { + runnable.run(); + } } } 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 4cdbb3af..08ee128c 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 @@ -831,7 +831,7 @@ private void throwBomb(UUID uuid) { } private void throwMatrix(UUID uuid) { - //app.getAcousticHandler().playSound(MdgaSound.MATRIX); + app.getAcousticHandler().playSound(MdgaSound.MATRIX); Spatial piece = pieces.get(uuid).getSpatial(); piece.addControl(new MatrixAnimation(app, radarPos,()-> { piece.addControl(new FadeControl(1,1,0, 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 index fa3a2239..c840e997 100644 --- 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 @@ -4,11 +4,9 @@ import pp.mdga.client.ClientState; import pp.mdga.client.GameState; import pp.mdga.game.Piece; +import pp.mdga.game.PieceState; import pp.mdga.message.server.*; -import pp.mdga.notification.ActivePlayerNotification; -import pp.mdga.notification.HomeMoveNotification; -import pp.mdga.notification.MovePieceNotification; -import pp.mdga.notification.PlayCardNotification; +import pp.mdga.notification.*; public class SpectatorState extends GameStates { @@ -62,24 +60,32 @@ public void received(ActivePlayerMessage msg) { @Override public void received(MoveMessage msg) { - Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); + Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); if (msg.isHomeMove()) { - logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex())); - logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant(); - logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove); + logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex())); + logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); + logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece); } else { - if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) { - throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant()); - logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown(); - logic.getGame().getGameStatistics().increasePiecesThrown(); + int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); + + Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant(); + if (occ != null) { + //TODO: MoveThrowNotification + logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor())); + //set occ to waiting + logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ); } - if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) { - logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true)); - logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove); + if(msg.getPiece().getState().equals(PieceState.WAITING)){ + logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true)); + logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece); + piece.setState(PieceState.ACTIVE); } else { - logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex())); - logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove); + logic.addNotification(new MovePieceNotification(piece.getUuid(), oldIndex, msg.getTargetIndex())); + //clear old node + logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); } + //set new node + logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece); } parent.setState(parent.getAnimation()); } 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 index 6c0ab752..002ce1cd 100644 --- 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 @@ -70,25 +70,28 @@ public void received(ActivePlayerMessage msg) { @Override public void received(MoveMessage msg) { Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); - //logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); if (msg.isHomeMove()) { logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex())); logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece); } else { int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); - Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant(); - //logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece); if (occ != null) { //TODO: MoveThrowNotification logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor())); //set occ to waiting logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ); } - logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), oldIndex, msg.getTargetIndex())); - //clear old node - logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); + if(oldIndex == -1){ + logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true)); + logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece); + piece.setState(PieceState.ACTIVE); + } else { + logic.addNotification(new MovePieceNotification(piece.getUuid(), oldIndex, msg.getTargetIndex())); + //clear old node + logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); + } //set new node logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece); } 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 index 6f88dfd5..86bcc509 100644 --- 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 @@ -27,7 +27,6 @@ public WaitingPieceState(ClientState parent, ClientGameLogic logic) { @Override public void enter() { moveablePiece = null; - } @Override diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java index c72d7e14..b5ac8ff3 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 @@ -85,7 +85,7 @@ public Game() { gameStatistics = new Statistic(); initializeDrawPile(); board = new Board(); - die = new Die(2,1,2,2,1,3); + die = new Die(2,5,6,3,6); } /** diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Player.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Player.java index c9f1f1c7..3203770b 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 @@ -178,7 +178,7 @@ public boolean hasPieceInWaitingArea(){ public int getHomeIndexOfPiece(Piece piece) { for (int i = 0; i < Resources.MAX_PIECES; i++) { - if (this.homeNodes[i].getOccupant().equals(piece)) { + if (piece.equals(this.homeNodes[i].getOccupant())) { return i; } } @@ -348,4 +348,13 @@ public void setPieceInHome(int index, Piece piece) { public String toString() { return "Player: " + name + " Color: " + color; } + + public void removeWaitingPiece(Piece piece) { + for (int i = 0; i < Resources.MAX_PIECES; i++) { + if (piece.equals(this.waitingArea[i])) { + this.waitingArea[i] = null; + return; + } + } + } } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/choosepiece/WaitingPieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/choosepiece/WaitingPieceState.java index bac3f7e8..89a7a46a 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/choosepiece/WaitingPieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/choosepiece/WaitingPieceState.java @@ -40,6 +40,7 @@ public void enter() { @Override public void received(RequestMoveMessage msg, int from){ if (msg.getPiece().equals(this.piece)) { + logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeWaitingPiece(this.piece); piece.setState(PieceState.ACTIVE); Piece thrownOcc = logic.getGame().getBoard().getInfield()[logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex()].getOccupant(); if (thrownOcc != null) { diff --git a/Projekte/mdga/model/src/main/resources/mdga.properties b/Projekte/mdga/model/src/main/resources/mdga.properties index ea216f91..0495f73c 100644 --- a/Projekte/mdga/model/src/main/resources/mdga.properties +++ b/Projekte/mdga/model/src/main/resources/mdga.properties @@ -1,8 +1,11 @@ lobby.deny.join=The lobby is already full. server.shutdown=The server has shut down. - incorrect.request.0=The selected TSK is already occupied. incorrect.request.1=No TSK is available for selection. +incorrect.request.2=Test +incorrect.request.3=Test +incorrect.request.4=Test +incorrect.request.5=Test diff --git a/Projekte/mdga/model/src/main/resources/mdga_de.properties b/Projekte/mdga/model/src/main/resources/mdga_de.properties index 81cc4ad2..c2103b99 100644 --- a/Projekte/mdga/model/src/main/resources/mdga_de.properties +++ b/Projekte/mdga/model/src/main/resources/mdga_de.properties @@ -1,5 +1,8 @@ lobby.deny.join=Die Lobby ist bereits voll. server.shutdown=Der Server wurde heruntergefahren. - -incorrect.request.1=Die ausgewählte TSK ist bereits belegt. -incorrect.request.2=Es gibt keine freie TSK mehr, welche ausgewählt werden kann. +incorrect.request.0=Die ausgewählte TSK ist bereits belegt. +incorrect.request.1=Es gibt keine freie TSK mehr, welche ausgewählt werden kann. +incorrect.request.2=Test +incorrect.request.3=Test +incorrect.request.4=Test +incorrect.request.5=Test