fixed some tests
This commit is contained in:
		@@ -3,11 +3,13 @@
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import pp.mdga.game.card.PowerCard;
 | 
			
		||||
import pp.mdga.game.card.SwapCard;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestMoveMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestPlayCardMessage;
 | 
			
		||||
import pp.mdga.message.client.SelectCardMessage;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.ServerMessage;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
import pp.mdga.server.ServerSender;
 | 
			
		||||
@@ -152,24 +154,24 @@ public void shutdown() {
 | 
			
		||||
 | 
			
		||||
        //declare player-Client here
 | 
			
		||||
        playerClient = new Player(nameClient);
 | 
			
		||||
        playerClient.initialize();
 | 
			
		||||
        clientColor = Color.ARMY;
 | 
			
		||||
        playerClient.setColor(clientColor);
 | 
			
		||||
        playerClient.initialize();
 | 
			
		||||
        game.addPlayer(IDClient, playerClient);
 | 
			
		||||
 | 
			
		||||
        //declare player-host here
 | 
			
		||||
        playerHost = new Player(nameHost);
 | 
			
		||||
        playerHost.initialize();
 | 
			
		||||
        hostColor = Color.NAVY;
 | 
			
		||||
        playerHost.setColor(hostColor);
 | 
			
		||||
        playerHost.initialize();
 | 
			
		||||
        game.addPlayer(IDHost, playerHost);
 | 
			
		||||
 | 
			
		||||
        //declare playerCyber here
 | 
			
		||||
        nameCyber = "Cyber";
 | 
			
		||||
        playerCyber = new Player(nameCyber);
 | 
			
		||||
        playerCyber.initialize();
 | 
			
		||||
        cyberColor = Color.CYBER;
 | 
			
		||||
        playerCyber.setColor(cyberColor);
 | 
			
		||||
        playerCyber.initialize();
 | 
			
		||||
        game.addPlayer(IDCyber, playerCyber);
 | 
			
		||||
 | 
			
		||||
        //initialize the playerData
 | 
			
		||||
@@ -914,9 +916,11 @@ public void testActiveHomePiece() {
 | 
			
		||||
 | 
			
		||||
        //sends the request-Dice-message
 | 
			
		||||
        serverGameLogic.received(new RequestDieMessage(),IDClient);
 | 
			
		||||
        serverGameLogic.received(new AnimationEndMessage(),IDClient);
 | 
			
		||||
 | 
			
		||||
        //sends the requestMove-message for pieceClient1
 | 
			
		||||
        serverGameLogic.received(new RequestMoveMessage(pieceHost1),IDClient);
 | 
			
		||||
        serverGameLogic.received(new RequestMoveMessage(pieceClient1),IDClient);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //tests if clientPiece1 is in the home at idx 3
 | 
			
		||||
        assertTrue(game.getPlayerByColor(clientColor).getHomeNodes()[3].isOccupied());
 | 
			
		||||
@@ -929,8 +933,14 @@ public void testActiveHomePiece() {
 | 
			
		||||
     * Use Case UC-Piece-11: Ensure that a piece cannot jump over another piece in the house area.
 | 
			
		||||
     * </p>
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    @Test (expected = RuntimeException.class)
 | 
			
		||||
    public void testCantJumpOverFigureInHouse() {
 | 
			
		||||
        //set activePlayer to client
 | 
			
		||||
        game.setActiveColor(clientColor);
 | 
			
		||||
 | 
			
		||||
        pieceClient2.setState(PieceState.ACTIVE);
 | 
			
		||||
        pieceClient1.setState(PieceState.HOME);
 | 
			
		||||
 | 
			
		||||
        //sends the server in firstRoll
 | 
			
		||||
        serverGameLogic.setCurrentState(gameState);
 | 
			
		||||
        gameState.setCurrentState(turnState);
 | 
			
		||||
@@ -943,21 +953,29 @@ public void testCantJumpOverFigureInHouse() {
 | 
			
		||||
        assertEquals(turnState.getCurrentState(),rollDiceState);
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(),firstRollState);
 | 
			
		||||
 | 
			
		||||
        //set activePlayer to client
 | 
			
		||||
        game.setActiveColor(clientColor);
 | 
			
		||||
 | 
			
		||||
        //set the die in Game to 4
 | 
			
		||||
        game.setDie(die4);
 | 
			
		||||
 | 
			
		||||
        //send requestDice-Message
 | 
			
		||||
        serverGameLogic.received(new RequestDieMessage(),IDClient);
 | 
			
		||||
        serverGameLogic.received(new AnimationEndMessage(),IDClient);
 | 
			
		||||
 | 
			
		||||
        assertEquals(serverGameLogic.getCurrentState(),gameState);
 | 
			
		||||
        assertEquals(gameState.getCurrentState(), turnState);
 | 
			
		||||
        assertEquals(turnState.getCurrentState(),choosePieceState);
 | 
			
		||||
        assertEquals(choosePieceState.getCurrentState(),selectPieceState);
 | 
			
		||||
 | 
			
		||||
        selectPieceState.setMoveablePieces(new ArrayList<>(List.of()));
 | 
			
		||||
        System.out.println(selectPieceState);
 | 
			
		||||
 | 
			
		||||
        System.out.println(game.getBoard().getInfieldIndexOfPiece(pieceClient2));
 | 
			
		||||
        //sends requestMoveMessage with clientPiece 02
 | 
			
		||||
        serverGameLogic.received(new RequestMoveMessage(pieceHost2),IDHost);
 | 
			
		||||
        serverGameLogic.received(new RequestMoveMessage(pieceClient2),IDClient);
 | 
			
		||||
        System.out.println(game.getBoard().getInfieldIndexOfPiece(pieceClient2));
 | 
			
		||||
 | 
			
		||||
        //tests, if the clientPiece02 is at idx 19
 | 
			
		||||
        assertTrue(game.getBoard().getInfield()[19].isOccupied());
 | 
			
		||||
        assertEquals(game.getBoard().getInfield()[20].getOccupant(),pieceClient2);
 | 
			
		||||
        assertEquals(game.getBoard().getInfield()[19].getOccupant(),pieceClient2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -968,6 +986,9 @@ public void testCantJumpOverFigureInHouse() {
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testActiveHomePieceBlocked() {
 | 
			
		||||
 | 
			
		||||
        game.setActiveColor(clientColor);
 | 
			
		||||
        turnState.setPlayer(playerClient);
 | 
			
		||||
        //sends the server in firstRoll
 | 
			
		||||
        serverGameLogic.setCurrentState(gameState);
 | 
			
		||||
        gameState.setCurrentState(turnState);
 | 
			
		||||
@@ -1007,6 +1028,8 @@ public void testActiveHomePieceBlocked() {
 | 
			
		||||
    public void testOnStartingFieldWithShield() {
 | 
			
		||||
        //sets the color to host
 | 
			
		||||
        game.setActiveColor(hostColor);
 | 
			
		||||
        game.getBoard().setPieceOnBoard(28,pieceHost1);
 | 
			
		||||
        game.getBoard().setPieceOnBoard(18,null);
 | 
			
		||||
 | 
			
		||||
        //sets the dice to 2
 | 
			
		||||
        game.setDie(die2);
 | 
			
		||||
@@ -1028,13 +1051,15 @@ public void testOnStartingFieldWithShield() {
 | 
			
		||||
 | 
			
		||||
        //sends the requestDice-message
 | 
			
		||||
        serverGameLogic.received(new RequestDieMessage(),IDHost);
 | 
			
		||||
        serverGameLogic.received(new AnimationEndMessage(),IDHost);
 | 
			
		||||
 | 
			
		||||
        pieceHost1.setShield(ShieldState.ACTIVE);
 | 
			
		||||
        //sends the moveMessage
 | 
			
		||||
        serverGameLogic.received(new RequestMoveMessage(pieceHost1),IDHost);
 | 
			
		||||
 | 
			
		||||
        //tests the position of the hostPiece1 and that shield is suppressed
 | 
			
		||||
        assertTrue(game.getBoard().getInfield()[20].isOccupied());
 | 
			
		||||
        assertEquals(game.getBoard().getInfield()[20].getOccupant(),pieceClient1);
 | 
			
		||||
        assertTrue(game.getBoard().getInfield()[30].isOccupied());
 | 
			
		||||
        assertEquals(game.getBoard().getInfield()[30].getOccupant(),pieceHost1);
 | 
			
		||||
 | 
			
		||||
        assertEquals(pieceHost1.getShield(),ShieldState.SUPPRESSED);
 | 
			
		||||
    }
 | 
			
		||||
@@ -1092,24 +1117,40 @@ public void testThrowFigureWithShield() {
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testUseSwap() {
 | 
			
		||||
        //set activePlayer to Host
 | 
			
		||||
        game.setActiveColor(hostColor);
 | 
			
		||||
        PowerCard swap = new SwapCard();
 | 
			
		||||
        playerHost.addHandCard(swap);
 | 
			
		||||
        pieceClient0.setState(PieceState.ACTIVE);
 | 
			
		||||
        pieceHost0.setShield(ShieldState.ACTIVE);
 | 
			
		||||
 | 
			
		||||
        //send the server in choosePowerCard
 | 
			
		||||
        serverGameLogic.setCurrentState(gameState);
 | 
			
		||||
        serverGameLogic.getGameState().setCurrentState(turnState);
 | 
			
		||||
        serverGameLogic.getGameState().getTurnState().setCurrentState(powerCardState);
 | 
			
		||||
        powerCardState.setSelectedCard(swap);
 | 
			
		||||
        powerCardState.setCurrentState(powerCardState.getSwapCardState());
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in selectPieces
 | 
			
		||||
        assertEquals(serverGameLogic.getCurrentState(),gameState);
 | 
			
		||||
        assertEquals(gameState.getCurrentState(), turnState);
 | 
			
		||||
        assertEquals(turnState.getCurrentState(),powerCardState);
 | 
			
		||||
 | 
			
		||||
        //set activePlayer to Host
 | 
			
		||||
        game.setActiveColor(hostColor);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        assertTrue(game.getBoard().getInfield()[25].isOccupied());
 | 
			
		||||
        assertEquals(game.getBoard().getInfield()[25].getOccupant(),pieceClient0);
 | 
			
		||||
 | 
			
		||||
        assertTrue(game.getBoard().getInfield()[28].isOccupied());
 | 
			
		||||
        assertEquals(game.getBoard().getInfield()[28].getOccupant(),pieceHost0);
 | 
			
		||||
 | 
			
		||||
        //sends the requestPlayCard
 | 
			
		||||
        serverGameLogic.received(new SelectCardMessage(swapCard),IDHost);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //sends the selectedPiece-message
 | 
			
		||||
        serverGameLogic.received(RequestPlayCardMessage.requestPlaySwap(pieceHost0.getUuid(),pieceClient0.getUuid()),IDHost);
 | 
			
		||||
        serverGameLogic.received(new SelectedPiecesMessage(List.of(pieceHost0,pieceClient0)),IDHost);
 | 
			
		||||
        System.out.println(game.getBoard().getInfieldIndexOfPiece(pieceClient0));
 | 
			
		||||
 | 
			
		||||
        //tests if the piece at idx 25 is pieceHost0 and at idx 28 is pieceClient0
 | 
			
		||||
        assertTrue(game.getBoard().getInfield()[25].isOccupied());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user