|
|
|
|
@@ -1,9 +1,18 @@
|
|
|
|
|
package pp.mdga.client.clientState;
|
|
|
|
|
|
|
|
|
|
import org.junit.*;
|
|
|
|
|
import pp.mdga.client.*;
|
|
|
|
|
import pp.mdga.client.ceremonystate.*;
|
|
|
|
|
import pp.mdga.client.dialogstate.*;
|
|
|
|
|
import org.junit.Before;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import pp.mdga.client.CeremonyState;
|
|
|
|
|
import pp.mdga.client.ClientGameLogic;
|
|
|
|
|
import pp.mdga.client.ClientSender;
|
|
|
|
|
import pp.mdga.client.DialogsState;
|
|
|
|
|
import pp.mdga.client.GameState;
|
|
|
|
|
import pp.mdga.client.InterruptState;
|
|
|
|
|
import pp.mdga.client.ceremonystate.PodiumState;
|
|
|
|
|
import pp.mdga.client.ceremonystate.StatisticsState;
|
|
|
|
|
import pp.mdga.client.dialogstate.LobbyState;
|
|
|
|
|
import pp.mdga.client.dialogstate.NetworkDialogState;
|
|
|
|
|
import pp.mdga.client.dialogstate.StartDialogState;
|
|
|
|
|
import pp.mdga.client.gamestate.AnimationState;
|
|
|
|
|
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
|
|
|
|
import pp.mdga.client.gamestate.SpectatorState;
|
|
|
|
|
@@ -11,28 +20,21 @@
|
|
|
|
|
import pp.mdga.client.gamestate.WaitingState;
|
|
|
|
|
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
|
|
|
|
|
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
|
|
|
|
|
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
|
|
|
|
import pp.mdga.client.gamestate.turnstate.MovePieceState;
|
|
|
|
|
import pp.mdga.client.gamestate.turnstate.*;
|
|
|
|
|
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
|
|
|
|
|
import pp.mdga.client.gamestate.turnstate.powercardstate.*;
|
|
|
|
|
import pp.mdga.game.Game;
|
|
|
|
|
import pp.mdga.game.Piece;
|
|
|
|
|
import pp.mdga.game.PieceState;
|
|
|
|
|
import pp.mdga.game.Player;
|
|
|
|
|
import pp.mdga.game.card.PowerCard;
|
|
|
|
|
import pp.mdga.game.card.ShieldCard;
|
|
|
|
|
import pp.mdga.game.card.SwapCard;
|
|
|
|
|
import pp.mdga.game.card.TurboCard;
|
|
|
|
|
import pp.mdga.message.server.*;
|
|
|
|
|
import pp.mdga.game.Color;
|
|
|
|
|
import pp.mdga.client.gamestate.turnstate.powercardstate.ShieldState;
|
|
|
|
|
import pp.mdga.game.*;
|
|
|
|
|
import pp.mdga.game.card.*;
|
|
|
|
|
import pp.mdga.message.client.ClientMessage;
|
|
|
|
|
import pp.mdga.visitor.Visitor;
|
|
|
|
|
import pp.mdga.message.server.*;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this test-class tests the testcases T170-T239
|
|
|
|
|
@@ -75,7 +77,6 @@ public class ClientStateTest {
|
|
|
|
|
private WaitingState waiting;
|
|
|
|
|
private WaitingPieceState waitingPiece;
|
|
|
|
|
private WaitRankingState waitRanking;
|
|
|
|
|
//private todo
|
|
|
|
|
|
|
|
|
|
//declare server-messages here
|
|
|
|
|
private ShutdownMessage shutdownMessage;
|
|
|
|
|
@@ -163,15 +164,10 @@ public void send(ClientMessage msg) {
|
|
|
|
|
player.removeWaitingPiece(ownPiece);
|
|
|
|
|
game.getBoard().setPieceOnBoard(22, ownPiece);
|
|
|
|
|
|
|
|
|
|
//todo piece
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
swapCard = new SwapCard();
|
|
|
|
|
shieldCard = new ShieldCard();
|
|
|
|
|
turboCard = new TurboCard();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player.addHandCard(turboCard);
|
|
|
|
|
player.addHandCard(swapCard);
|
|
|
|
|
player.addHandCard(shieldCard);
|
|
|
|
|
@@ -197,7 +193,6 @@ public void send(ClientMessage msg) {
|
|
|
|
|
clientGameLogic.getGame().getBoard().setPieceOnBoard(15, ownPiece);
|
|
|
|
|
clientGameLogic.getGame().getBoard().setPieceOnBoard(25, enemyPiece);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//initialize the messages from the server
|
|
|
|
|
shutdownMessage = new ShutdownMessage();
|
|
|
|
|
activePlayer = new ActivePlayerMessage(color);
|
|
|
|
|
@@ -215,13 +210,12 @@ public void send(ClientMessage msg) {
|
|
|
|
|
moveMessage = new MoveMessage(ownPiece, false, 25);
|
|
|
|
|
noTurn = new NoTurnMessage();
|
|
|
|
|
interruptMessage = new PauseGameMessage();
|
|
|
|
|
playCardSwap = new PlayCardMessage(swapCard, new ArrayList<>(List.of(ownPiece, enemyPiece)), 1); //TODO
|
|
|
|
|
playCardSwap = new PlayCardMessage(swapCard, new ArrayList<>(List.of(ownPiece, enemyPiece)), 1);
|
|
|
|
|
playCardShield = new PlayCardMessage(shieldCard, new ArrayList<>(List.of(ownPiece)), 1);
|
|
|
|
|
playCardTurbo = new PlayCardMessage(turboCard, new ArrayList<>(List.of(ownPiece)), 1);
|
|
|
|
|
possibleCard = new PossibleCardsMessage(new ArrayList<>(List.of(swapCard, shieldCard, turboCard)));
|
|
|
|
|
possiblePieceShield = PossiblePieceMessage.shieldPossiblePieces(new ArrayList<>(List.of(ownPiece))); //TODO
|
|
|
|
|
possiblePieceSwap = PossiblePieceMessage.swapPossiblePieces(new ArrayList<>(List.of(ownPiece)), new ArrayList<>(List.of(enemyPiece))); //TODO
|
|
|
|
|
//todo possiblePieceSwap = new PossiblePieceMessage(new ArrayList<>(List.of(ownPiece)), new ArrayList<>(List.of(enemyPiece)));
|
|
|
|
|
possiblePieceShield = PossiblePieceMessage.shieldPossiblePieces(new ArrayList<>(List.of(ownPiece)));
|
|
|
|
|
possiblePieceSwap = PossiblePieceMessage.swapPossiblePieces(new ArrayList<>(List.of(ownPiece)), new ArrayList<>(List.of(enemyPiece)));
|
|
|
|
|
possiblePiece = new PossiblePieceMessage();
|
|
|
|
|
rankingResponse = new RankingResponseMessage();
|
|
|
|
|
rankingRollAgain = new RankingRollAgainMessage();
|
|
|
|
|
@@ -322,10 +316,7 @@ public void testDialogsToGame() {
|
|
|
|
|
clientGameLogic.received(rankingRollAgain);
|
|
|
|
|
clientGameLogic.received(reconnectBriefing);
|
|
|
|
|
clientGameLogic.received(resumeGame);
|
|
|
|
|
//clientGameLogic.received(startGame);
|
|
|
|
|
clientGameLogic.received(startPieceMessage);
|
|
|
|
|
//clientGameLogic.received(updateReady);
|
|
|
|
|
//clientGameLogic.received(updateTSK);
|
|
|
|
|
clientGameLogic.received(waitPiece);
|
|
|
|
|
clientGameLogic.received(spectatorMessage);
|
|
|
|
|
clientGameLogic.received(selectPieceMessage);
|
|
|
|
|
@@ -401,7 +392,6 @@ public void testClientGameToCeremony() {
|
|
|
|
|
clientGameLogic.received(ceremonyMessage);
|
|
|
|
|
|
|
|
|
|
//tests if the client is in the ceremony after receiving the message
|
|
|
|
|
System.out.println(clientGameLogic.getState());
|
|
|
|
|
assertEquals(clientGameLogic.getState(), ceremony);
|
|
|
|
|
|
|
|
|
|
//tests if the state of ceremony is Podium
|
|
|
|
|
@@ -473,7 +463,6 @@ public void testStayInInterrupt() {
|
|
|
|
|
clientGameLogic.received(rankingResponse);
|
|
|
|
|
clientGameLogic.received(rankingRollAgain);
|
|
|
|
|
clientGameLogic.received(reconnectBriefing);
|
|
|
|
|
//clientGameLogic.received(resumeGame); commented out, because it indicates a state-change to gameState
|
|
|
|
|
clientGameLogic.received(startGame);
|
|
|
|
|
clientGameLogic.received(startPieceMessage);
|
|
|
|
|
clientGameLogic.received(updateReady);
|
|
|
|
|
@@ -634,15 +623,13 @@ public void testNetworkDialogToNetworkDialog1() {
|
|
|
|
|
assertEquals(dialogs.getState(), networkDialog);
|
|
|
|
|
|
|
|
|
|
//simulate all input, that don't indicate a state-change
|
|
|
|
|
clientGameLogic.selectPiece(null); //TODO
|
|
|
|
|
clientGameLogic.selectPiece(null);
|
|
|
|
|
clientGameLogic.selectCard(null);
|
|
|
|
|
clientGameLogic.selectTsk(color);
|
|
|
|
|
clientGameLogic.selectDice();
|
|
|
|
|
clientGameLogic.selectName(name);
|
|
|
|
|
clientGameLogic.selectReady(true);
|
|
|
|
|
clientGameLogic.selectHost(name);
|
|
|
|
|
//clientGameLogic.selectLeave(); commented because it indicate a state-change to start-dialog
|
|
|
|
|
//clientGameLogic.selectJoin(name); commented because it indicate a state-change to lobby
|
|
|
|
|
clientGameLogic.selectAnimationEnd();
|
|
|
|
|
clientGameLogic.selectStart();
|
|
|
|
|
|
|
|
|
|
@@ -714,17 +701,15 @@ public void testStayInLobby() {
|
|
|
|
|
assertEquals(dialogs.getState(), lobby);
|
|
|
|
|
|
|
|
|
|
//simulate all input that don't indicate a state-change
|
|
|
|
|
clientGameLogic.selectPiece(null); //TODO
|
|
|
|
|
clientGameLogic.selectPiece(null);
|
|
|
|
|
clientGameLogic.selectCard(null);
|
|
|
|
|
clientGameLogic.selectTsk(color);
|
|
|
|
|
clientGameLogic.selectDice();
|
|
|
|
|
clientGameLogic.selectName(name);
|
|
|
|
|
clientGameLogic.selectReady(true);
|
|
|
|
|
clientGameLogic.selectHost(name);
|
|
|
|
|
//clientGameLogic.selectLeave(); commented because it indicate a state-change to start-dialog
|
|
|
|
|
clientGameLogic.selectJoin(name);
|
|
|
|
|
clientGameLogic.selectAnimationEnd();
|
|
|
|
|
//clientGameLogic.selectStart(); commented because it indicate a state-change to determineStartPlayer if host
|
|
|
|
|
|
|
|
|
|
//sends all messages, which don't indicate a statechange
|
|
|
|
|
clientGameLogic.received(activePlayer);
|
|
|
|
|
@@ -751,7 +736,6 @@ public void testStayInLobby() {
|
|
|
|
|
clientGameLogic.received(rankingRollAgain);
|
|
|
|
|
clientGameLogic.received(reconnectBriefing);
|
|
|
|
|
clientGameLogic.received(resumeGame);
|
|
|
|
|
//clientGameLogic.received(startGame); commented because it indicate a state-change to determineStartPlayer
|
|
|
|
|
clientGameLogic.received(startPieceMessage);
|
|
|
|
|
clientGameLogic.received(updateReady);
|
|
|
|
|
clientGameLogic.received(updateTSK);
|
|
|
|
|
@@ -816,11 +800,9 @@ public void testDetermineStartPlayerToWait() {
|
|
|
|
|
assertEquals(determineStartPlayer.getState(), determineStartPlayer.getIntro());
|
|
|
|
|
|
|
|
|
|
int animationCounter = determineStartPlayer.getIntro().getAnimationCounter();
|
|
|
|
|
System.out.println(animationCounter);
|
|
|
|
|
for (int i = 0; i < animationCounter; i++) {
|
|
|
|
|
clientGameLogic.selectAnimationEnd();
|
|
|
|
|
}
|
|
|
|
|
System.out.println(determineStartPlayer.getIntro().getAnimationCounter());
|
|
|
|
|
|
|
|
|
|
//tests if the client is in the Wait-State
|
|
|
|
|
assertEquals(clientGameLogic.getState(), gameState);
|
|
|
|
|
@@ -851,7 +833,7 @@ public void testWaitToAnimation() {
|
|
|
|
|
gameState.setState(waiting);
|
|
|
|
|
assertEquals(gameState.getState(), waiting);
|
|
|
|
|
|
|
|
|
|
//sends the playTurboCard-message todo
|
|
|
|
|
//sends the playTurboCard-message
|
|
|
|
|
clientGameLogic.received(playCardTurbo);
|
|
|
|
|
|
|
|
|
|
//tests if a powerCard is played,that the client goes into Animation
|
|
|
|
|
@@ -942,18 +924,14 @@ public void testTurnSubStatesToGameEndState() {
|
|
|
|
|
clientGameLogic.received(activePlayer);
|
|
|
|
|
clientGameLogic.received(anyPiece);
|
|
|
|
|
clientGameLogic.received(briefing);
|
|
|
|
|
//clientGameLogic.received(ceremonyMessage); commented because it indicate a state-change to ceremony-state
|
|
|
|
|
clientGameLogic.received(die);
|
|
|
|
|
clientGameLogic.received(diceAgain);
|
|
|
|
|
//clientGameLogic.received(diceNow); commented because it indicate a state-change to rollDice-state
|
|
|
|
|
//clientGameLogic.received(endOfTurn); commented because it indicate a state-change to wait-state
|
|
|
|
|
clientGameLogic.received(lobbyAccept);
|
|
|
|
|
clientGameLogic.received(lobbyDeny);
|
|
|
|
|
clientGameLogic.received(lobbyPlayerJoin);
|
|
|
|
|
clientGameLogic.received(lobbyPlayerLeave);
|
|
|
|
|
clientGameLogic.received(moveMessage);
|
|
|
|
|
clientGameLogic.received(noTurn);
|
|
|
|
|
//clientGameLogic.received(interruptMessage); commented because it indicate a state-change to interrupt-state
|
|
|
|
|
clientGameLogic.received(playCardSwap);
|
|
|
|
|
clientGameLogic.received(playCardShield);
|
|
|
|
|
clientGameLogic.received(playCardTurbo);
|
|
|
|
|
@@ -968,7 +946,6 @@ public void testTurnSubStatesToGameEndState() {
|
|
|
|
|
clientGameLogic.received(updateReady);
|
|
|
|
|
clientGameLogic.received(updateTSK);
|
|
|
|
|
clientGameLogic.received(waitPiece);
|
|
|
|
|
//clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state
|
|
|
|
|
clientGameLogic.received(selectPieceMessage);
|
|
|
|
|
|
|
|
|
|
//tests if the client is still in MovePiece
|
|
|
|
|
@@ -1170,18 +1147,14 @@ public void testTurnSubStatesToSpectator() {
|
|
|
|
|
clientGameLogic.received(activePlayer);
|
|
|
|
|
clientGameLogic.received(anyPiece);
|
|
|
|
|
clientGameLogic.received(briefing);
|
|
|
|
|
//clientGameLogic.received(ceremonyMessage); commented because it indicate a state-change to ceremony-state
|
|
|
|
|
clientGameLogic.received(die);
|
|
|
|
|
clientGameLogic.received(diceAgain);
|
|
|
|
|
//clientGameLogic.received(diceNow); commented because it indicate a state-change to rollDice-state
|
|
|
|
|
//clientGameLogic.received(endOfTurn); commented because it indicate a state-change to wait-state
|
|
|
|
|
clientGameLogic.received(lobbyAccept);
|
|
|
|
|
clientGameLogic.received(lobbyDeny);
|
|
|
|
|
clientGameLogic.received(lobbyPlayerJoin);
|
|
|
|
|
clientGameLogic.received(lobbyPlayerLeave);
|
|
|
|
|
clientGameLogic.received(moveMessage);
|
|
|
|
|
clientGameLogic.received(noTurn);
|
|
|
|
|
//clientGameLogic.received(interruptMessage); commented because it indicate a state-change to interrupt-state
|
|
|
|
|
clientGameLogic.received(playCardSwap);
|
|
|
|
|
clientGameLogic.received(playCardShield);
|
|
|
|
|
clientGameLogic.received(playCardTurbo);
|
|
|
|
|
@@ -1196,7 +1169,6 @@ public void testTurnSubStatesToSpectator() {
|
|
|
|
|
clientGameLogic.received(updateReady);
|
|
|
|
|
clientGameLogic.received(updateTSK);
|
|
|
|
|
clientGameLogic.received(waitPiece);
|
|
|
|
|
//clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state
|
|
|
|
|
clientGameLogic.received(selectPieceMessage);
|
|
|
|
|
|
|
|
|
|
//tests if the client is still in MovePiece
|
|
|
|
|
@@ -2397,9 +2369,7 @@ public void testStayInSelectedPiece() {
|
|
|
|
|
clientGameLogic.received(lobbyDeny);
|
|
|
|
|
clientGameLogic.received(lobbyPlayerJoin);
|
|
|
|
|
clientGameLogic.received(lobbyPlayerLeave);
|
|
|
|
|
//clientGameLogic.received(moveMessage);
|
|
|
|
|
clientGameLogic.received(noTurn);
|
|
|
|
|
//clientGameLogic.received(interruptMessage);
|
|
|
|
|
clientGameLogic.received(playCardSwap);
|
|
|
|
|
clientGameLogic.received(playCardShield);
|
|
|
|
|
clientGameLogic.received(playCardTurbo);
|
|
|
|
|
@@ -2485,9 +2455,7 @@ public void testStayInStartPiece() {
|
|
|
|
|
clientGameLogic.received(lobbyDeny);
|
|
|
|
|
clientGameLogic.received(lobbyPlayerJoin);
|
|
|
|
|
clientGameLogic.received(lobbyPlayerLeave);
|
|
|
|
|
//clientGameLogic.received(moveMessage);
|
|
|
|
|
clientGameLogic.received(noTurn);
|
|
|
|
|
//clientGameLogic.received(interruptMessage);
|
|
|
|
|
clientGameLogic.received(playCardSwap);
|
|
|
|
|
clientGameLogic.received(playCardShield);
|
|
|
|
|
clientGameLogic.received(playCardTurbo);
|
|
|
|
|
|