minor changes

This commit is contained in:
Benjamin Feyer
2024-12-01 23:08:56 +01:00
parent 9718ad111f
commit a1934e30cb
3 changed files with 292 additions and 288 deletions

View File

@@ -17,6 +17,7 @@
import pp.mdga.message.client.ClientMessage;
import java.util.ArrayList;
import java.util.UUID;
import static org.junit.Assert.*;
@@ -349,7 +350,7 @@ public void testClientGameToCeremony() {
}
/**
* UC-ClientState-05: Test the transition from ClientGame sub-states to Interrupt.
* UC-ClientState-05: Test the transition from ClientGame substates to Interrupt.
*/
@Test
public void testClientGameSubStatesToInterrupt() {
@@ -374,7 +375,7 @@ public void testGameToDialogs() {
assertEquals(clientGameLogic.getState(), gameState);
//receives a GameClosedMessage
clientGameLogic.received();//TODO
//clientGameLogic.received();//TODO
assertEquals(clientGameLogic.getState(), dialogs);
assertEquals(dialogs.getState(), startDialog);
@@ -452,7 +453,7 @@ public void testInterruptToDialogs() {
assertEquals(clientGameLogic.getState(), interrupt);
//Todo send the server-closed
clientGameLogic.received();
//clientGameLogic.received();
//tests if the client is in the startDialog
assertEquals(clientGameLogic.getState(), dialogs);
@@ -881,7 +882,7 @@ public void testWaitToGameEndState() {
}
/**
* UC-ClientState-25: Test the transition from Turn sub-states to GameEndState.
* UC-ClientState-25: Test the transition from Turn substates to GameEndState.
*/
@Test
public void testTurnSubStatesToGameEndState() {
@@ -944,7 +945,7 @@ public void testTurnSubStatesToGameEndState() {
}
/**
* UC-ClientState-26: Test the transition from Turn sub-states to Wait.
* UC-ClientState-26: Test the transition from Turn substates to Wait.
*/
@Test
public void testTurnSubStatesToWait() {
@@ -1134,7 +1135,7 @@ public void testTurnSubStatesToWait() {
}
/**
* UC-ClientState-27: Test the transition from Turn sub-states to Spectator.
* UC-ClientState-27: Test the transition from Turn substates to Spectator.
*/
@Test
public void testTurnSubStatesToSpectator() {
@@ -1255,7 +1256,7 @@ public void testSpectatorToGameEndState() {
}
/**
* UC-ClientState-29: Test the transition from PowerCard sub-states to PlayPowerCard.
* UC-ClientState-29: Test the transition from PowerCard substates to PlayPowerCard.
*/
@Test
public void testPowerCardSubStatesToPlayPowerCard() {
@@ -1315,7 +1316,7 @@ public void testPowerCardSubStatesToPlayPowerCard() {
}
/**
* UC-ClientState-30: Test the transition from PowerCard sub-states to RollDice.
* UC-ClientState-30: Test the transition from PowerCard substates to RollDice.
* <p>
* tests the transition from ChoosePowerCard from PowerCard to RollDice
*/

View File

@@ -149,6 +149,17 @@ public void testMove() {
@Test
public void testCantMove() {
// TODO: Implement test logic for when a piece can't move
//send server in selectPiece-state
//set active player
//set die-class
//send request Die-message
//send ..........
//test
}
/**

View File

@@ -1,14 +1,7 @@
package pp.mdga.server.serverState;
import org.junit.*;
import pp.mdga.client.gameState.AnimationState;
import pp.mdga.client.gameState.turnState.PlayPowerCardState;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.game.Game;
import pp.mdga.game.Piece;
import pp.mdga.game.PieceState;
import pp.mdga.game.Player;
import pp.mdga.game.*;
import pp.mdga.message.server.ServerMessage;
import pp.mdga.message.client.*;
import pp.mdga.server.*;
@@ -50,7 +43,6 @@ public class ServerStateTest {
private SelectTSKMessage selectTSK;
private StartGameMessage startGame;
//TODO declare two players
private Player playerHost;
@@ -78,9 +70,8 @@ public class ServerStateTest {
//todo declare a card for client
private BonusCard bonusCardClient;
//TODO declare the states here
private AnimationState animation;
private AnimationState animationState;
private CeremonyState ceremonyState;
private ChoosePieceState choosePieceState;
private DetermineStartPlayerState determineStartPlayerState;
@@ -89,17 +80,17 @@ public class ServerStateTest {
private InterruptState interruptState;
private LobbyState lobbyState;
private MovePieceState movePieceState;
private NoPieceState noPiece;
private NoPieceState noPieceState;
private NoTurnState noTurnState;
private PlayPowerCardState playPowerCard;
private PlayPowerCardState playPowerCardState;
private PowerCardState powerCardState;
private RollDiceState rollDiceState;
private SecondRollState secondRoll;
private SelectPieceState selectPiece;
private SecondRollState secondRollState;
private SelectPieceState selectPieceState;
private StartPieceState startPieceState;
private ThirdRollState thirdRoll;
private ThirdRollState thirdRollState;
private TurnState turnState;
private WaitingPieceState waitingPiece;
private WaitingPieceState waitingPieceState;
/**
* this method is used to initialize the attributes of this test-class
@@ -120,6 +111,11 @@ public void send(int id, ServerMessage message) {
public void broadcast(ServerMessage message) {
}
@Override
public void disconnectClient(int id) {
}
}, game);
animationEnd = new AnimationEndMessage();
@@ -140,27 +136,26 @@ public void broadcast(ServerMessage message) {
selectTSK = new SelectTSKMessage();
startGame = new StartGameMessage();
//initialize the states here
thirdRoll = rollDiceState.getThirdRollState();
secondRoll = rollDiceState.getSecondRollState();
thirdRollState = rollDiceState.getThirdRollState();
secondRollState = rollDiceState.getSecondRollState();
firstRollState = rollDiceState.getThirdRollState();
noPiece = choosePieceState.getNoPieceState();
noPieceState = choosePieceState.getNoPieceState();
noTurnState = choosePieceState.getNoTurnState();
waitingPiece = choosePieceState.getWaitingPieceState();
waitingPieceState = choosePieceState.getWaitingPieceState();
startPieceState = choosePieceState.getStartPieceState();
selectPiece =choosePieceState.getSelectPieceState();
selectPieceState = choosePieceState.getSelectPieceState();
powerCardState = turnState.getPowerCardState();
playPowerCard = turnState.getPlayPowerCardState();
playPowerCardState = turnState.getPlayPowerCardState();
rollDiceState = turnState.getRollDiceState();
choosePieceState = turnState.getChoosePieceState();
movePieceState = turnState.getMovePieceState();
determineStartPlayerState = gameState.getDetermineStartPlayerState();
turnState = gameState.getTurnState();
animation = gameState.getAnimationState();
animationState = gameState.getAnimationState();
lobbyState = (LobbyState) serverGameLogic.getLobbyState();
gameState = (GameState) serverGameLogic.getGameState();
@@ -178,7 +173,7 @@ public void broadcast(ServerMessage message) {
IDPlayerClient = 2;
playerClientColor = Color.ARMY;
playerClient.setColor(playerClientColor);
playerClient.addHandCards(bonusCardClient);
playerClient.addHandCard(bonusCardClient);
game.addPlayer(IDPlayerClient, playerClient); //TODO random uuid
//initialize a piece for client
@@ -200,7 +195,6 @@ public void broadcast(ServerMessage message) {
//initialize the powerCard
bonusCardClient = BonusCard.SHIELD;
}
/**
@@ -222,7 +216,7 @@ public void testLobbyToDetermineStartPlayer() {
serverGameLogic.setCurrentState(lobbyState);
assertEquals(serverGameLogic.getCurrentState(), lobbyState);
//send all other messages, which dont indicate a state change
//send all other messages, which don't indicate a state change
serverGameLogic.received(animationEnd, IDPlayerClient);
serverGameLogic.received(deselectTSK, IDPlayerClient);
serverGameLogic.received(disconnected, IDPlayerClient);
@@ -241,7 +235,6 @@ public void testLobbyToDetermineStartPlayer() {
serverGameLogic.received(selectTSK, IDPlayerClient);
//serverGameLogic.received(startGame, IDPlayerClient);
//tests if the server is still in the lobby-state
assertEquals(serverGameLogic.getLobbyState(), lobbyState);
@@ -271,7 +264,7 @@ public void testStayInLobby() {
serverGameLogic.setCurrentState(lobbyState);
assertEquals(serverGameLogic.getCurrentState(), lobbyState);
//serverGameLogic gets all messages, which dont indicate a state change
//serverGameLogic gets all messages, which don't indicate a state change
serverGameLogic.received(animationEnd, IDPlayerClient);
serverGameLogic.received(deselectTSK, IDPlayerClient);
//serverGameLogic.received(disconnected, IDPlayerClient);
@@ -489,7 +482,7 @@ public void testDetermineStartPlayerToAnimation() {
//tests if the Server is in animationState
assertEquals(serverGameLogic.getCurrentState(), gameState);
assertEquals(gameState.getCurrentState() ,animation);
assertEquals(gameState.getCurrentState(), animationState);
}
/**
@@ -503,13 +496,13 @@ public void testAnimationToPowerCard() {
assertEquals(serverGameLogic.getCurrentState(), gameState);
//sends the gameState in Animation
gameState.setCurrentState(animation);
assertEquals(gameState.getCurrentState() ,animation);
gameState.setCurrentState(animationState);
assertEquals(gameState.getCurrentState(), animationState);
//receives one animation endMessage and tests if the server is still in the Animation-state
serverGameLogic.received(animationEnd, IDPlayerClient);
assertEquals(serverGameLogic.getCurrentState(), gameState);
assertEquals(gameState.getCurrentState() ,animation);
assertEquals(gameState.getCurrentState(), animationState);
//receives another animation endMessage
serverGameLogic.received(animationEnd, IDPlayerClient);
@@ -535,8 +528,8 @@ public void testTurnToAnimation() {
assertEquals(gameState.getCurrentState(), turnState);
//sends the server in Animation
turnState.setCurrentState(animation);
assertEquals(turnState.getState(),animation);
turnState.setCurrentState(movePieceState);
assertEquals(turnState.getCurrentState(), movePieceState);
//set dices-eyes in game !=6
game.setDiceEyes(4);
@@ -544,17 +537,17 @@ public void testTurnToAnimation() {
//serverGameLogic receives animationEndMessages
serverGameLogic.received(animationEnd, IDPlayerClient);
//tests if the server is still in Animation-State
//tests if the server is still in movePieceState
assertEquals(serverGameLogic.getCurrentState(), gameState);
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getState(),animation);
assertEquals(turnState.getCurrentState(), movePieceState);
//sends the second animationEndMessage
serverGameLogic.received(animationEnd, IDPlayerHost);
//tests if the server is in the AnimationState
assertEquals(serverGameLogic.getCurrentState(), gameState);
assertEquals(gameState.getCurrentState() ,animation);
assertEquals(gameState.getCurrentState(), animationState);
}
/**
@@ -643,7 +636,7 @@ public void testPowerCardToPlayPowerCard() {
//tests if the server is in PlayPowerCard
assertEquals(serverGameLogic.getCurrentState(), gameState);
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getCurrentState() ,playPowerCard);
assertEquals(turnState.getCurrentState(), playPowerCardState);
}
/**
@@ -661,14 +654,14 @@ public void testPlayPowerCardToRollDice() {
assertEquals(gameState.getCurrentState(), turnState);
//sends the TurnState in PowerCard
turnState.setCurrentState(playPowerCard);
assertEquals(turnState.getCurrentState() ,playPowerCard);
turnState.setCurrentState(playPowerCardState);
assertEquals(turnState.getCurrentState(), playPowerCardState);
//receive first AnimationEndMessage IDPlayerClient the host
serverGameLogic.received(animationEnd, IDPlayerClient);
assertEquals(serverGameLogic.getCurrentState(), gameState);
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getCurrentState() ,playPowerCard);
assertEquals(turnState.getCurrentState(), playPowerCardState);
//receive second AnimationEndMessage
serverGameLogic.received(animationEnd, IDPlayerClient);
@@ -835,7 +828,7 @@ public void testSecondRollToRollDiceEndState() {
assertEquals(turnState.getCurrentState(), rollDiceState);
//sends the RollDiceState in SecondRoll
rollDiceState.setCurrentState(secondRoll);
rollDiceState.setCurrentState(secondRollState);
assertEquals(rollDiceState.getCurrentState(), secondRollState);
//Todo
@@ -866,7 +859,7 @@ public void testSecondRollToThirdRoll() {
assertEquals(turnState.getCurrentState(), rollDiceState);
//sends the RollDiceState in SecondRoll
rollDiceState.setCurrentState(secondRoll);
rollDiceState.setCurrentState(secondRollState);
assertEquals(rollDiceState.getCurrentState(), secondRollState);
//Todo player has no figures to move and had no 6
@@ -897,7 +890,7 @@ public void testThirdRollToRollDiceEndState() {
assertEquals(turnState.getCurrentState(), rollDiceState);
//sends the RollDiceState in ThirdRoll
rollDiceState.setCurrentState(thirdRoll);
rollDiceState.setCurrentState(thirdRollState);
assertEquals(rollDiceState.getCurrentState(), thirdRollState);
//Todo
@@ -928,7 +921,7 @@ public void testThirdRollToTurnEndState() {
assertEquals(turnState.getCurrentState(), rollDiceState);
//sends the RollDiceState in ThirdRoll
rollDiceState.setCurrentState(thirdRoll);
rollDiceState.setCurrentState(thirdRollState);
assertEquals(rollDiceState.getCurrentState(), thirdRollState);
//Todo
@@ -953,7 +946,7 @@ public void testNoPieceToWaitingPiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in NoPiece
choosePieceState.setCurrentState(noPiece);
choosePieceState.setCurrentState(noPieceState);
assertEquals(choosePieceState.getCurrentState(), noPieceState);
//TODO
@@ -963,7 +956,6 @@ public void testNoPieceToWaitingPiece() {
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getCurrentState(), choosePieceState);
assertEquals(choosePieceState.getCurrentState(), waitingPieceState);
}
/**
@@ -985,7 +977,7 @@ public void testNoPieceToNoTurn() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in NoPiece
choosePieceState.setCurrentState(noPiece);
choosePieceState.setCurrentState(noPieceState);
assertEquals(choosePieceState.getCurrentState(), noPieceState);
//TODO
@@ -1041,7 +1033,7 @@ public void testStayInWaitingPiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in WaitingPiece
choosePieceState.setCurrentState(waitingPiece);
choosePieceState.setCurrentState(waitingPieceState);
assertEquals(choosePieceState.getCurrentState(), waitingPieceState);
//TODO
@@ -1072,7 +1064,7 @@ public void testWaitingPieceToMovePiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in WaitingPiece
choosePieceState.setCurrentState(waitingPiece);
choosePieceState.setCurrentState(waitingPieceState);
assertEquals(choosePieceState.getCurrentState(), waitingPieceState);
//TODO
@@ -1097,7 +1089,7 @@ public void testNoPieceToSelectPiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in NoPiece
choosePieceState.setCurrentState(noPiece);
choosePieceState.setCurrentState(noPieceState);
assertEquals(choosePieceState.getCurrentState(), noPieceState);
//TODO
@@ -1128,7 +1120,7 @@ public void testNoPieceToStartPiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in NoPiece
choosePieceState.setCurrentState(noPiece);
choosePieceState.setCurrentState(noPieceState);
assertEquals(choosePieceState.getCurrentState(), noPieceState);
//TODO
@@ -1159,7 +1151,7 @@ public void testStayInSelectPiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in SelectPiece
choosePieceState.setCurrentState(selectPiece);
choosePieceState.setCurrentState(selectPieceState);
assertEquals(choosePieceState.getCurrentState(), selectPieceState);
//TODO
@@ -1190,7 +1182,7 @@ public void testSelectPieceToMovePiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in SelectPiece
choosePieceState.setCurrentState(selectPiece);
choosePieceState.setCurrentState(selectPieceState);
assertEquals(choosePieceState.getCurrentState(), selectPieceState);
//TODO
@@ -1220,7 +1212,7 @@ public void testStayInStartPiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in StartPiece
choosePieceState.setCurrentState(startPiece);
choosePieceState.setCurrentState(startPieceState);
assertEquals(choosePieceState.getCurrentState(), startPieceState);
//TODO
@@ -1251,7 +1243,7 @@ public void testStartPieceToMovePiece() {
assertEquals(turnState.getCurrentState(), choosePieceState);
//sends the server in StartPiece
choosePieceState.setCurrentState(startPiece);
choosePieceState.setCurrentState(startPieceState);
assertEquals(choosePieceState.getCurrentState(), startPieceState);
//TODO