added one testmethod for pieceTest

This commit is contained in:
Benjamin Feyer
2024-12-02 16:47:34 +01:00
parent 9b9b5e6781
commit af38224483

View File

@@ -169,13 +169,6 @@ public void disconnectClient(int id) {
game.getBoard().getPlayerData().get(hostColor).addWaitingPiece(pieceClient2); //set in waitingArea fur uc 5
game.getBoard().setPieceOnBoard(0, pieceHost3); //for uc 9
//declare messages here todo
//send the serverGameTurn in todo
//set the active color todo necessary?
game.setActiveColor(clientColor);
//initializes the states
gameState= serverGameLogic.getGameState();
turnState= gameState.getTurnState();
@@ -738,7 +731,33 @@ public void testCantJumpOverFigureInHouse() {
*/
@Test
public void testActiveHomePieceBlocked() {
// TODO: Implement test logic for when an active home piece is blocked
//sends the server in firstRoll
serverGameLogic.setCurrentState(gameState);
gameState.setCurrentState(turnState);
turnState.setCurrentState(rollDiceState);
rollDiceState.setCurrentState(firstRollState);
//tests if the server is in firstRoll
assertEquals(serverGameLogic.getCurrentState(),gameState);
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getCurrentState(),rollDiceState);
assertEquals(rollDiceState.getCurrentState(),firstRollState);
//set active player to client
game.setActiveColor(clientColor);
//set Dice to 3
game.setDie(die3);
//sends the requestDice-message
serverGameLogic.received(new RequestDieMessage(),IDClient);
//sends the request MoveMessage
serverGameLogic.received(new RequestMoveMessage(pieceClient1.getUuid()),IDClient);
//tests if the piece is still at idx 2 in home
assertTrue(game.getBoard().getPlayerData().get(clientColor).getHomeNodes()[1].isOccupied());
assertEquals(game.getBoard().getPlayerData().get(clientColor).getHomeNodes()[1].getOccupant(),pieceClient1);
}
/**
@@ -750,6 +769,7 @@ public void testActiveHomePieceBlocked() {
@Test
public void testOnStartingFieldWithShield() {
//sets the color to host
game.setActiveColor(hostColor);
//sets the dice to 2
game.setDie(die2);