diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 9be143a4..43e30ac5 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -6,6 +6,10 @@ import pp.mdga.client.dialogState.*; import pp.mdga.client.ceremonyState.*; import pp.mdga.client.gameState.*; +import pp.mdga.client.gameState.turnState.choosePieceState.NoPieceState; +import pp.mdga.client.gameState.turnState.choosePieceState.SelectPieceState; +import pp.mdga.client.gameState.turnState.choosePieceState.StartPieceState; +import pp.mdga.client.gameState.turnState.choosePieceState.WaitingPieceState; import pp.mdga.client.settingsState.*; import pp.mdga.client.gameState.turnState.*; import pp.mdga.client.gameState.determineStartPlayerState.*; @@ -33,78 +37,72 @@ public class ClientStateTest { private Game game; //declare states here - private Animation animation; - private AudioSettings audioSettings; - private Ceremony ceremony; - private ChoosePiece choosePiece; - private ChoosePowerCard choosePowerCard; + private AnimationState animation; + private AudioSettingsState audioSettings; + private CeremonyState ceremony; + private ChoosePieceState choosePiece; + private ChoosePowerCardState choosePowerCard; private ClientGameLogic clientGameLogic; - private DetermineStartPlayer determineStartPlayer; - private Dialogs dialogs; + private DetermineStartPlayerState determineStartPlayer; + private DialogsState dialogs; private GameState gameState; - private Interrupt interrupt; - private Lobby lobby; - private MainSettings mainSettings; - private MovePiece movePiece; - private NetworkDialog networkDialog; - private NoPiece noPiece; - private PlayPowerCard playPowerCard; - private Podium podium; - private PowerCard powerCard; - private RollDice rollDice; - private RollRankingDice rollRankingDice; - private SelectPiece selectPiece; - private Settings settings; - private Shield shield; - private Spectator spectator; - private StartDialog startDialog; - private StartPiece startPiece; - private Statistics statistics; - private Swap swap; - private Turn turnState; - private VideoSettings videoSettings; - private Waiting waiting; - private WaitingPiece waitingPiece; - private WaitRanking waitRanking; + private InterruptState interrupt; + private LobbyState lobby; + private MainSettingsState mainSettings; + private MovePieceState movePiece; + private NetworkDialogState networkDialog; + private NoPieceState noPiece; + private PlayPowerCardState playPowerCard; + private PodiumState podium; + private PowerCardState powerCard; + private RollDiceState rollDice; + private RollRankingDiceState rollRankingDice; + private SelectPieceState selectPiece; + private SettingsState settings; + private ShieldState shield; + private SpectatorState spectator; + private StartDialogState startDialog; + private StartPieceState startPiece; + private StatisticsState statistics; + private SwapState swap; + private TurnState turnState; + private VideoSettingsState videoSettings; + private WaitingState waiting; + private WaitingPieceState waitingPiece; + private WaitRankingState waitRanking; //declare server-messages here - private ActivePlayer activePlayer; - private AnyPiece anyPiece; - private Briefing briefing; + private ActivePlayerMessage activePlayer; + private AnyPieceMessage anyPiece; + private BriefingMessage briefing; private CeremonyMessage ceremonyMessage; - private Die die; - private DiceAgain diceAgain; - private DiceNow diceNow; - private EndOfTurn endOfTurn; - private LobbyAccept lobbyAccept; - private LobbyDeny lobbyDeny; - private LobbyPlayerJoin lobbyPlayerJoin; - private LobbyPlayerLeave lobbyPlayerLeave; + private DieMessage die; + private DiceAgainMessage diceAgain; + private DiceNowMessage diceNow; + private EndOfTurnMessage endOfTurn; + private LobbyAcceptMessage lobbyAccept; + private LobbyDenyMessage lobbyDeny; + private LobbyPlayerJoinMessage lobbyPlayerJoin; + private LobbyPlayerLeaveMessage lobbyPlayerLeave; private MoveMessage moveMessage; - private NoTurn noTurn; - private PauseGame pauseGame; - - private PlayCard playCardSwap; - private PlayCard playCardShield; - private PlayCard playCardTurbo; - - private PossibleCard possibleCard; - private PossiblePiece possiblePiece; - private RankingResponse rankingResponce; - private RankingRollAgain rankingRollAgain; - private ReconnectBriefing reconnectBriefing; - private ResumeGame resumeGame; - private ServerStartGame startGame; - private StartPiece startPieceMessage; - private UpdateReady updateReady; - private UpdateTSK updateTSK; - private WaitPiece waitPiece; - - - - + private NoTurnMessage noTurn; + private PauseGameMessage interruptMessage; + private PlayCardMessage playCardSwap; + private PlayCardMessage playCardShield; + private PlayCardMessage playCardTurbo; + private PossibleCardMessage possibleCard; + private PossiblePieceMessage possiblePiece; + private RankingResponseMessage rankingResponce; + private RankingRollAgainMessage rankingRollAgain; + private ReconnectBriefingMessage reconnectBriefing; + private ResumeGameMessage resumeGame; + private ServerStartGameMessage startGame; + private StartPieceMessage startPieceMessage; + private UpdateReadyMessage updateReady; + private UpdateTSKMessage updateTSK; + private WaitPieceMessage waitPiece; private int from; @@ -115,7 +113,6 @@ public class ClientStateTest { private BonusCard turboCard; - @Before public void setUp() { //initialize the game @@ -138,92 +135,83 @@ public void send(ClientMessage msg) { turboCard = BonusCard.TURBO; //initialize the messages from the server - activePlayer = new ActivePlayer(color); - anyPiece = new AnyPiece(); - briefing = new Briefing(); + activePlayer = new ActivePlayerMessage(color); + anyPiece = new AnyPieceMessage(); + briefing = new BriefingMessage(); ceremonyMessage = new CeremonyMessage(); - die = new Dice(6, new ArrayList<>()); - diceAgain = new DiceAgain(); - diceNow = new DiceNow(); - endOfTurn = new EndOfTurn(); - lobbyAccept = new LobbyAccept(); - lobbyDeny = new LobbyDeny(); - lobbyPlayerJoin = new LobbyPlayerJoin(name); - lobbyPlayerLeave = new LobbyPlayerLeave(name,color); + die = new DieMessage(6, new ArrayList<>()); + diceAgain = new DiceAgainMessage(); + diceNow = new DiceNowMessage(); + endOfTurn = new EndOfTurnMessage(); + lobbyAccept = new LobbyAcceptMessage(); + lobbyDeny = new LobbyDenyMessage(); + lobbyPlayerJoin = new LobbyPlayerJoinMessage(name); + lobbyPlayerLeave = new LobbyPlayerLeaveMessage(name,color); moveMessage = new MoveMessage("www");//Todo - noTurn = new NoTurn(); - pauseGame = new PauseGame(); - playCardSwap = new PlayCard(swapCard,"www");//Todo - playCardShield = new PlayCard(shieldCard,"www");//Todo - playCardTurbo = new PlayCard(turboCard,"www");//Todo - possibleCard = new PossibleCard(); - possiblePiece = new PossiblePiece(); - rankingResponce = new RankingResponse(); - rankingRollAgain = new RankingRollAgain(); - reconnectBriefing = new ReconnectBriefing(game); - resumeGame = new ResumeGame(); - startGame = new ServerStartGame(); - startPieceMessage = new StartPiece(); //Todo wrong class - updateReady = new UpdateReady(color,true); - updateTSK = new UpdateTSK(name,color); - waitPiece = new WaitPiece(); - interruptMessage = new Interrupt(); + noTurn = new NoTurnMessage(); + interruptMessage = new PauseGameMessage(); + playCardSwap = new PlayCardMessage(swapCard,"www");//Todo + playCardShield = new PlayCardMessage(shieldCard,"www");//Todo + playCardTurbo = new PlayCardMessage(turboCard,"www");//Todo + possibleCard = new PossibleCardMessage(); + possiblePiece = new PossiblePieceMessage(); + rankingResponce = new RankingResponseMessage(); + rankingRollAgain = new RankingRollAgainMessage(); + reconnectBriefing = new ReconnectBriefingMessage(game); + resumeGame = new ResumeGameMessage(); + startGame = new ServerStartGameMessage(); + startPieceMessage = new StartPieceMessage("www"); //Todo wrong class + updateReady = new UpdateReadyMessage(color,true); + updateTSK = new UpdateTSKMessage(name,color); + waitPiece = new WaitPieceMessage(); + interruptMessage = new PauseGameMessage(); //initialize the settings - mainSettings = new MainSettings(settingsStateMachine,clientGameLogic); - videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic); - audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic); - settings = new Settings(clientGameLogic,clientGameLogic); - - - ceremonyState =ceremony.getCeremonyState(); - choosePiece = choosePiece.getChoosePieceStateMachine(); - determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerStateMachine(); - dialogs = dialogs.getDialogsState(); - gameState = gameState.getGameStateMachine(); - powerCardStateMachine = powerCard.getPowerCardStateMachine(); - turnState = gameState.getTurnState(); + mainSettings = settings.getMainSettings(); + videoSettings = settings.getVideoSettings(); + audioSettings = settings.getAudioSettings(); + settings = new SettingsState(clientGameLogic); //initialize the states - dialogs = new Dialogs(clientGameLogic,clientGameLogic); - gameState = new GameState(clientGameLogic,clientGameLogic); - ceremony = new Ceremony(clientGameLogic,clientGameLogic); - interrupt = new Interrupt(clientGameLogic,clientGameLogic,gameState); + dialogs = clientGameLogic.getDialogs(); + gameState = clientGameLogic.getGameState(); + ceremony = clientGameLogic.getCeremony(); + interrupt = clientGameLogic.getInterrupt(); - startDialog = new StartDialog(dialogs,clientGameLogic); - networkDialog = new NetworkDialog(dialogs,clientGameLogic); - lobby = new Lobby(dialogs,clientGameLogic); + startDialog = dialogs.getStartDialog(); + networkDialog = dialogs.getNetworkDialog(); + lobby = dialogs.getLobby(); - podium = new Podium(ceremonyState,clientGameLogic); - statistics = new Statistics(ceremonyState,clientGameLogic); + podium = ceremony.getPodium(); + statistics = ceremony.getStatistics(); - determineStartPlayer = new DetermineStartPlayer(gameState,clientGameLogic); - waiting= new Waiting(gameState,clientGameLogic); - animation = new Animation(gameState,clientGameLogic); - turnState = new Turn(gameState,clientGameLogic); - spectator = new Spectator(gameState,clientGameLogic); + determineStartPlayer = gameState.getDetermineStartPlayer(); + waiting= gameState.getWaiting(); + animation = gameState.getAnimation(); + turnState = gameState.getTurn(); + spectator = gameState.getSpectator(); - rollRankingDice = new RollRankingDice(determineStartPlayerStateMachine,clientGameLogic); - waitRanking = new WaitRanking(determineStartPlayerStateMachine,clientGameLogic); + rollRankingDice = determineStartPlayer.getRollRankingDice(); + waitRanking = determineStartPlayer.getWaitRanking(); - powerCard = new PowerCard(turnState,clientGameLogic); - playPowerCard = new PlayPowerCard(turnState,clientGameLogic); - rollDice= new RollDice(turnState,clientGameLogic); - choosePiece = new ChoosePiece(turnState,clientGameLogic); - movePiece = new MovePiece(turnState,clientGameLogic); + powerCard = turnState.getPowerCard(); + playPowerCard = turnState.getPlayPowerCard(); + rollDice= turnState.getRollDice(); + choosePiece = turnState.getChoosePiece(); + movePiece = turnState.getMovePiece(); - choosePowerCard = new ChoosePowerCard(powerCardStateMachine,clientGameLogic); - shield =new Shield(powerCardStateMachine,clientGameLogic); - swap = new Swap(powerCardStateMachine,clientGameLogic); + choosePowerCard = powerCard.getChoosePowerCard(); + shield = powerCard.getShield(); + swap = powerCard.getSwap(); - noPiece = new NoPiece(choosePiece,clientGameLogic); - waitingPiece = new WaitingPiece(choosePiece,clientGameLogic); - selectPiece = new SelectPiece(choosePiece,clientGameLogic); - startPiece = new StartPiece(choosePiece,clientGameLogic); + noPiece = choosePiece.getNoPiece(); + waitingPiece = choosePiece.getWaitingPiece(); + selectPiece = choosePiece.getSelectPiece(); + startPiece = choosePiece.getStartPiece(); } /** @@ -303,7 +291,7 @@ public void testClientGameSubStatesToInterrupt() { //TODO //sends the Ceremony-Message to the client - clientGameLogic.received(pauseGame); + clientGameLogic.received(interruptMessage); //tests if the client-automaton is in the interrupt state assertEquals(clientGameLogic.getState() ,interrupt); diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 27cf4dc9..97f2a436 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -106,7 +106,7 @@ public void broadcast(ServerMessage message) { animationEnd = new AnimationEndMessage(); clientStartGame = new ClientStartGameMessage(); - deselectTSK = new DeselectTSKMessage(); + deselectTSK = new DeselectTSKMessage(Color.ARMY);//TODO forceContinueGame = new ForceContinueGameMessage(); forceStartGame = new StartGameMessage(); joinServer = new JoinServerMessage(); @@ -125,10 +125,6 @@ public void broadcast(ServerMessage message) { fromHost = 2345; //initialize the state-machines here - choosePieceState = choosePieceState.getChoosePieceMachine(); - turnState = turnState.getTurnStatemachine(); - gameState = gameState.getGameStatemachine(); - thirdRoll = rollDiceState.getThirdRollState(); secondRoll = rollDiceState.getSecondRollState(); firstRollState = rollDiceState.getThirdRollState();