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 25319ac4..6ab1e04e 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 @@ -17,7 +17,7 @@ public class MdgaApp extends SimpleApplication { MdgaView view = null; private MdgaState state = MdgaState.MAIN; - private static float resolutionFactor = 1.8f; + private static float resolutionFactor = 1.0f; public static void main(String[] args) { AppSettings settings = new AppSettings(true); 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 a936fb79..2af5c94a 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 @@ -3,7 +3,12 @@ import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientState; import pp.mdga.client.GameState; +import pp.mdga.game.BonusCard; +import pp.mdga.game.Piece; +import pp.mdga.game.Player; +import pp.mdga.game.ShieldState; import pp.mdga.message.server.*; +import pp.mdga.notification.*; public class WaitingState extends GameStates { @@ -14,6 +19,30 @@ public WaitingState(ClientState parent, ClientGameLogic logic) { this.parent = (GameState) parent; } + private CeremonyNotification createCeremonyNotification(){ + CeremonyNotification notification = new CeremonyNotification(); + for (var player : logic.getGame().getPlayers().entrySet()){ + notification.getColors().add(player.getValue().getColor()); + notification.getNames().add(player.getValue().getName()); + notification.getSixes().add(player.getValue().getPlayerStatistic().getDiced6()); + notification.getBonusNodes().add(player.getValue().getPlayerStatistic().getActivatedBonusNodes()); + notification.getPiecesLost().add(player.getValue().getPlayerStatistic().getPiecesBeingThrown()); + notification.getPiecesThrown().add(player.getValue().getPlayerStatistic().getPiecesThrown()); + notification.getNodesMoved().add(player.getValue().getPlayerStatistic().getTraveledNodes()); + notification.getBonusCardsPlayed().add(player.getValue().getPlayerStatistic().getCardsPlayed()); + } + + notification.getNames().add("GAME OVERALL"); + notification.getNodesMoved().add(logic.getGame().getGameStatistics().getTraveledNodes()); + notification.getSixes().add(logic.getGame().getGameStatistics().getDiced6()); + notification.getPiecesThrown().add(logic.getGame().getGameStatistics().getPiecesThrown()); + notification.getPiecesLost().add(logic.getGame().getGameStatistics().getPiecesBeingThrown()); + notification.getBonusNodes().add(logic.getGame().getGameStatistics().getActivatedBonusNodes()); + notification.getBonusCardsPlayed().add(logic.getGame().getGameStatistics().getCardsPlayed()); + + return notification; + } + @Override public void enter() { @@ -26,31 +55,67 @@ public void exit() { @Override public void received(CeremonyMessage msg){ + logic.addNotification(createCeremonyNotification()); logic.setState(logic.getCeremony()); } @Override public void received(DiceNowMessage msg){ + logic.addNotification(new DiceNowNotification()); parent.setState(parent.getTurn()); } @Override public void received(DieMessage msg){ + logic.getGame().setDiceEyes(msg.getDiceEye()); + logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); parent.setState(parent.getAnimation()); } @Override public void received(PlayCardMessage msg){ + logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard())); + if (msg.getCard().equals(BonusCard.TURBO)){ + logic.getGame().setDiceModifier(msg.getDiceModifier()); + } else if (msg.getCard().equals(BonusCard.SHIELD)){ + if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier())) % 10 != 0) { + logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED); + logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid())); + } else { + logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE); + logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid())); + } + } else { + Piece ownPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()); + Piece enemyPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifierEnemy()); + int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece); + logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid())); + logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece); + logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece); + } parent.setState(parent.getAnimation()); } @Override public void received(ActivePlayerMessage msg){ + logic.addNotification(new ActivePlayerNotification(msg.getColor())); + logic.getGame().setActiveColor(msg.getColor()); parent.setState(parent.getAnimation()); } @Override public void received(MoveMessage msg){ + Piece pieceToMove = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier()); + if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){ + logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true)); + } else if (msg.isHomeMove()){ + logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex())); + } else { + if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) { + logic.addNotification(new ThrowPieceNotification(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant().getUuid())); + } + logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex())); + } parent.setState(parent.getAnimation()); } } 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 index 8c5717cf..3e1f2076 100644 --- 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 @@ -20,17 +20,20 @@ public class PlayCardMessage extends ServerMessage { private final String pieceIdentifierEnemy; + private final int diceModifier; + /** * 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) { + public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy, int diceModifier) { super(); this.card = card; this.pieceIdentifier = pieceIdentifier; this.pieceIdentifierEnemy = pieceIdentifierEnemy; + this.diceModifier = diceModifier; } /** @@ -40,6 +43,7 @@ private PlayCardMessage() { this.pieceIdentifierEnemy = null; card = null; pieceIdentifier = null; + diceModifier = 1; } /** @@ -50,7 +54,7 @@ private PlayCardMessage() { * @return a new PlayCard message */ public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifierEnemy) { - return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy); + return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy, 1); } /** @@ -60,7 +64,17 @@ public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifie * @return a new PlayCard message */ public static PlayCardMessage shield(String pieceIdentifier) { - return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null); + return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null, 1); + } + + /** + * creates a new PlayCardMessage for a turbo card + * + * @param diceModifier the new modifier of the dice + * @return newly constructed message + */ + public static PlayCardMessage turbo(int diceModifier){ + return new PlayCardMessage(BonusCard.TURBO, null, null, diceModifier); } /** @@ -90,6 +104,16 @@ public String getPieceIdentifierEnemy() { return pieceIdentifierEnemy; } + + /** + * this method returns the dice modifier + * + * @return the dice modifier as int + */ + public int getDiceModifier(){ + return diceModifier; + } + /** * Accepts a visitor to process this message. * 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 index ad81f2f8..c99b079e 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 @@ -10,11 +10,6 @@ public class ThrowPieceNotification extends Notification{ /** * This constructor is used to create a new ThrowPieceNotification - * - * @param pieceId1 the pieceId1 - * @param pieceId2 the pieceId2 - * @param nodeIndex the nodeIndex - * @param colorPiece2 the color */ public ThrowPieceNotification(UUID pieceId) { this.pieceId = pieceId;