fixed some tests

This commit is contained in:
Benjamin Feyer
2024-12-12 02:02:29 +01:00
parent e6453b2f1b
commit 4dda9229b3
3 changed files with 39 additions and 7 deletions

View File

@@ -376,4 +376,8 @@ public void removeWaitingPiece(Piece piece) {
}
}
}
public void setHandCards(ArrayList<PowerCard> handCards) {
this.handCards = handCards;
}
}

View File

@@ -214,4 +214,8 @@ public void setCurrentState(TurnAutomatonState state) {
this.currentState = state;
this.currentState.enter();
}
public void setPlayer(Player playe) {
this.player = player;
}
}

View File

@@ -27,6 +27,7 @@
import pp.mdga.server.automaton.game.turn.rolldice.ThirdRollState;
import pp.mdga.visitor.Visitor;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
@@ -128,6 +129,8 @@ public void setUp() {
game = new Game();
//initialize two players
playerHost = new Player("Host");
playerHostColor = Color.CYBER;
playerHost.setColor(playerHostColor);
PowerCard shield= new ShieldCard();
selectCard = new SelectCardMessage(shield);
@@ -137,8 +140,6 @@ public void setUp() {
playerHost.addHandCard(new TurboCard());
playerHost.initialize();
IDPlayerHost = 1;
playerHostColor = Color.CYBER;
playerHost.setColor(playerHostColor);
game.addPlayer(IDPlayerHost, playerHost);
hostPiece1 = playerHost.getWaitingArea()[0];
hostPiece2 = playerHost.getWaitingArea()[1];
@@ -158,10 +159,10 @@ public void setUp() {
playerClient.addHandCard(new ShieldCard());
playerClient.addHandCard(new SwapCard());
playerClient.addHandCard(new TurboCard());
playerClient.initialize();
IDPlayerClient = 2;
playerClientColor = Color.ARMY;
playerClient.setColor(playerClientColor);
playerClient.initialize();
playerClient.addHandCard(bonusCardClient);
game.addPlayer(IDPlayerClient, playerClient);
pieceClient4 = playerHost.getWaitingArea()[3];
@@ -899,6 +900,11 @@ public void testFirstRollToRollDiceEndState() {
*/
@Test
public void testFirstRollToSecondRoll() {
playerClient.addWaitingPiece(pieceClient4);
playerClient.setHandCards(new ArrayList<>());
pieceClient4.setState(PieceState.WAITING);
game.setActiveColor(playerClientColor);
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertEquals(serverGameLogic.getCurrentState(), gameState);
@@ -926,6 +932,7 @@ public void testFirstRollToSecondRoll() {
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getCurrentState(), rollDiceState);
assertEquals(rollDiceState.getCurrentState(), secondRollState);
}
/**
@@ -934,10 +941,16 @@ public void testFirstRollToSecondRoll() {
*/
@Test
public void testSecondRollToRollDiceEndState() {
playerClient.addWaitingPiece(pieceClient4);
pieceClient4.setState(PieceState.WAITING);
game.setActiveColor(playerClientColor);
serverGameLogic.setCurrentState(gameState);
assertEquals(serverGameLogic.getCurrentState(), gameState);
//sends the gameState in Turn
turnState.setPlayer(playerClient);
playerClient.setHandCards(new ArrayList<>());
gameState.setCurrentState(turnState);
assertEquals(gameState.getCurrentState(), turnState);
@@ -949,13 +962,17 @@ public void testSecondRollToRollDiceEndState() {
rollDiceState.setCurrentState(secondRollState);
assertEquals(rollDiceState.getCurrentState(), secondRollState);
//TODO
game.setDie(new Die(6));
//
serverGameLogic.received(requestDie,IDPlayerClient);
serverGameLogic.received(animationEnd, IDPlayerClient);
//tests if the server is in NoPiece of ChoosePiece
assertEquals(serverGameLogic.getCurrentState(), gameState);
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getCurrentState(), choosePieceState);
assertEquals(choosePieceState.getCurrentState(), noPieceState);
}
/**
@@ -999,6 +1016,9 @@ public void testSecondRollToThirdRoll() {
*/
@Test
public void testThirdRollToRollDiceEndState() {
game.setActiveColor(playerClientColor);
turnState.setPlayer(playerClient);
playerClient.setHandCards(new ArrayList<>());
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertEquals(serverGameLogic.getCurrentState(), gameState);
@@ -1015,13 +1035,17 @@ public void testThirdRollToRollDiceEndState() {
rollDiceState.setCurrentState(thirdRollState);
assertEquals(rollDiceState.getCurrentState(), thirdRollState);
//Todo
//die =6
game.setDie(new Die(6));
serverGameLogic.received(requestDie,IDPlayerClient);
System.out.println(game.getActivePlayer());
System.out.println(game.getActivePlayer().getStartNodeIndex());
serverGameLogic.received(animationEnd, IDPlayerClient);
//tests if the server is in NoPiece of ChoosePiece
assertEquals(serverGameLogic.getCurrentState(), gameState);
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getCurrentState(), choosePieceState);
assertEquals(choosePieceState.getCurrentState(), noPieceState);
}
/**