corrected the classes of the states in the statetests

This commit is contained in:
Benjamin Feyer
2024-11-28 19:45:18 +01:00
parent ecf1cc6e9a
commit 6d58ceee3d
2 changed files with 124 additions and 140 deletions

View File

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

View File

@@ -106,7 +106,7 @@ public void broadcast(ServerMessage message) {
animationEnd = new AnimationEndMessage(); animationEnd = new AnimationEndMessage();
clientStartGame = new ClientStartGameMessage(); clientStartGame = new ClientStartGameMessage();
deselectTSK = new DeselectTSKMessage(); deselectTSK = new DeselectTSKMessage(Color.ARMY);//TODO
forceContinueGame = new ForceContinueGameMessage(); forceContinueGame = new ForceContinueGameMessage();
forceStartGame = new StartGameMessage(); forceStartGame = new StartGameMessage();
joinServer = new JoinServerMessage(); joinServer = new JoinServerMessage();
@@ -125,10 +125,6 @@ public void broadcast(ServerMessage message) {
fromHost = 2345; fromHost = 2345;
//initialize the state-machines here //initialize the state-machines here
choosePieceState = choosePieceState.getChoosePieceMachine();
turnState = turnState.getTurnStatemachine();
gameState = gameState.getGameStatemachine();
thirdRoll = rollDiceState.getThirdRollState(); thirdRoll = rollDiceState.getThirdRollState();
secondRoll = rollDiceState.getSecondRollState(); secondRoll = rollDiceState.getSecondRollState();
firstRollState = rollDiceState.getThirdRollState(); firstRollState = rollDiceState.getThirdRollState();