From 1e5c5bd5eba6f6733ffc02fff2dbd428376360b0 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Fri, 13 Dec 2024 05:58:22 +0100 Subject: [PATCH] added T016 --- .../src/test/java/pp/mdga/game/GameTest.java | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) 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 index e29939b2..9b0db6b7 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java @@ -761,6 +761,70 @@ public void testStatistics() { // UC-Game-12 @Test public void testRefillPowerCardDeck() { - // TODO: Implement test logic for refilling the power card deck + //tests if both player have no color and are not ready + assertFalse(playerClient.isReady()); + assertFalse(playerHost.isReady()); + assertEquals(playerClient.getColor(), Color.NONE); + assertEquals(playerHost.getColor(), Color.NONE); + + //send the selectTSK-message + logic.received(new SelectTSKMessage(Color.CYBER), IDClient); + logic.received(new SelectTSKMessage(Color.ARMY), IDHost); + + //sends and tests the readyMessage for the client + logic.received(new LobbyReadyMessage(), IDClient); + logic.received(new LobbyReadyMessage(), IDHost); + assertTrue(playerClient.isReady()); + assertTrue(playerHost.isReady()); + + //tests if the game has started after the determineStartPlayerState + logic.received(new StartGameMessage(), IDHost); + assertEquals(logic.getCurrentState(), logic.getGameState()); + assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getDetermineStartPlayerState()); + + //roll the order + game.setDie(new Die(4)); + logic.received(new RequestDieMessage(), IDHost); + game.setDie(new Die(3)); + logic.received(new RequestDieMessage(), IDClient); + logic.received(new AnimationEndMessage(), IDClient); + logic.received(new AnimationEndMessage(), IDHost); + + //tests that the server is in the animation-state + assertEquals(logic.getCurrentState(), logic.getGameState()); + assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getAnimationState()); + + logic.received(new AnimationEndMessage(), IDClient); + logic.received(new AnimationEndMessage(), IDHost); + + assertEquals(logic.getCurrentState(), logic.getGameState()); + assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState()); + + //tests if the host is the active player + assertEquals(game.getActiveColor(), playerHost.getColor()); + + //hosts plays no power-card + logic.received(new NoPowerCardMessage(), IDHost); + + game.setDie(new Die(4)); + game.setDiscardPile(game.getDrawPile()); + game.setDrawPile(new ArrayList<>()); + + //tests if the draw-pile is empty + assertTrue(game.getDrawPile().isEmpty()); + + //simulates a roll and the move of a piece for the host + logic.received(new RequestDieMessage(), IDHost); + logic.received(new AnimationEndMessage(), IDHost); + logic.received(new RequestMoveMessage(game.getBoard().getInfield()[playerHost.getStartNodeIndex()].getOccupant()), IDHost); + + //tests if the server is in movePiece + assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState()); + assertEquals(logic.getGameState().getTurnState().getCurrentState(), logic.getGameState().getTurnState().getMovePieceState()); + + //tests if the draw-pile is not empty, the discard pile is empty and the host-player has drawn a card + assertFalse(game.getDrawPile().isEmpty()); + assertTrue(game.getDiscardPile().isEmpty()); + assertEquals(2, playerHost.getHandCards().size()); } }