fixed and added some tests
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SelectPieceState extends ChoosePieceAutomatonState {
|
public class SelectPieceState extends ChoosePieceAutomatonState {
|
||||||
/**
|
/**
|
||||||
@@ -20,8 +21,8 @@ public class SelectPieceState extends ChoosePieceAutomatonState {
|
|||||||
private static final System.Logger LOGGER = System.getLogger(SelectPieceState.class.getName());
|
private static final System.Logger LOGGER = System.getLogger(SelectPieceState.class.getName());
|
||||||
|
|
||||||
private ArrayList<Piece> moveablePieces = new ArrayList<>();
|
private ArrayList<Piece> moveablePieces = new ArrayList<>();
|
||||||
private final ArrayList<Boolean> isHomeMove = new ArrayList<>();
|
private ArrayList<Boolean> isHomeMove = new ArrayList<>();
|
||||||
private final ArrayList<Integer> targetIndex = new ArrayList<>();
|
private ArrayList<Integer> targetIndex = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a server state of the specified game logic.
|
* Constructs a server state of the specified game logic.
|
||||||
@@ -178,4 +179,22 @@ public void exit() {
|
|||||||
public ArrayList<Piece> getMoveablePieces() {
|
public ArrayList<Piece> getMoveablePieces() {
|
||||||
return moveablePieces;
|
return moveablePieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method is used to set the isHomeMoveIndex
|
||||||
|
*
|
||||||
|
* @param list to be set
|
||||||
|
*/
|
||||||
|
public void setIsHomeMove(ArrayList<Boolean> list){
|
||||||
|
this.isHomeMove=list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method is used to set the targetIndex
|
||||||
|
*
|
||||||
|
* @param list to be set
|
||||||
|
*/
|
||||||
|
public void setTargetIndex(ArrayList<Integer> list){
|
||||||
|
this.targetIndex=list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
package pp.mdga.client.clientState;
|
package pp.mdga.client.clientState;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.Before;
|
||||||
import pp.mdga.client.*;
|
import org.junit.Test;
|
||||||
import pp.mdga.client.ceremonystate.*;
|
import pp.mdga.client.CeremonyState;
|
||||||
import pp.mdga.client.dialogstate.*;
|
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.AnimationState;
|
||||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
||||||
import pp.mdga.client.gamestate.SpectatorState;
|
import pp.mdga.client.gamestate.SpectatorState;
|
||||||
@@ -11,28 +20,21 @@
|
|||||||
import pp.mdga.client.gamestate.WaitingState;
|
import pp.mdga.client.gamestate.WaitingState;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
|
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
|
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.*;
|
||||||
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
|
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
|
||||||
import pp.mdga.client.gamestate.turnstate.powercardstate.*;
|
import pp.mdga.client.gamestate.turnstate.powercardstate.*;
|
||||||
import pp.mdga.game.Game;
|
import pp.mdga.client.gamestate.turnstate.powercardstate.ShieldState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.*;
|
||||||
import pp.mdga.game.PieceState;
|
import pp.mdga.game.card.*;
|
||||||
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.message.client.ClientMessage;
|
import pp.mdga.message.client.ClientMessage;
|
||||||
import pp.mdga.visitor.Visitor;
|
import pp.mdga.message.server.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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
|
* this test-class tests the testcases T170-T239
|
||||||
@@ -75,7 +77,6 @@ public class ClientStateTest {
|
|||||||
private WaitingState waiting;
|
private WaitingState waiting;
|
||||||
private WaitingPieceState waitingPiece;
|
private WaitingPieceState waitingPiece;
|
||||||
private WaitRankingState waitRanking;
|
private WaitRankingState waitRanking;
|
||||||
//private todo
|
|
||||||
|
|
||||||
//declare server-messages here
|
//declare server-messages here
|
||||||
private ShutdownMessage shutdownMessage;
|
private ShutdownMessage shutdownMessage;
|
||||||
@@ -163,15 +164,10 @@ public void send(ClientMessage msg) {
|
|||||||
player.removeWaitingPiece(ownPiece);
|
player.removeWaitingPiece(ownPiece);
|
||||||
game.getBoard().setPieceOnBoard(22, ownPiece);
|
game.getBoard().setPieceOnBoard(22, ownPiece);
|
||||||
|
|
||||||
//todo piece
|
|
||||||
|
|
||||||
|
|
||||||
swapCard = new SwapCard();
|
swapCard = new SwapCard();
|
||||||
shieldCard = new ShieldCard();
|
shieldCard = new ShieldCard();
|
||||||
turboCard = new TurboCard();
|
turboCard = new TurboCard();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
player.addHandCard(turboCard);
|
player.addHandCard(turboCard);
|
||||||
player.addHandCard(swapCard);
|
player.addHandCard(swapCard);
|
||||||
player.addHandCard(shieldCard);
|
player.addHandCard(shieldCard);
|
||||||
@@ -197,7 +193,6 @@ public void send(ClientMessage msg) {
|
|||||||
clientGameLogic.getGame().getBoard().setPieceOnBoard(15, ownPiece);
|
clientGameLogic.getGame().getBoard().setPieceOnBoard(15, ownPiece);
|
||||||
clientGameLogic.getGame().getBoard().setPieceOnBoard(25, enemyPiece);
|
clientGameLogic.getGame().getBoard().setPieceOnBoard(25, enemyPiece);
|
||||||
|
|
||||||
|
|
||||||
//initialize the messages from the server
|
//initialize the messages from the server
|
||||||
shutdownMessage = new ShutdownMessage();
|
shutdownMessage = new ShutdownMessage();
|
||||||
activePlayer = new ActivePlayerMessage(color);
|
activePlayer = new ActivePlayerMessage(color);
|
||||||
@@ -215,13 +210,12 @@ public void send(ClientMessage msg) {
|
|||||||
moveMessage = new MoveMessage(ownPiece, false, 25);
|
moveMessage = new MoveMessage(ownPiece, false, 25);
|
||||||
noTurn = new NoTurnMessage();
|
noTurn = new NoTurnMessage();
|
||||||
interruptMessage = new PauseGameMessage();
|
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);
|
playCardShield = new PlayCardMessage(shieldCard, new ArrayList<>(List.of(ownPiece)), 1);
|
||||||
playCardTurbo = new PlayCardMessage(turboCard, 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)));
|
possibleCard = new PossibleCardsMessage(new ArrayList<>(List.of(swapCard, shieldCard, turboCard)));
|
||||||
possiblePieceShield = PossiblePieceMessage.shieldPossiblePieces(new ArrayList<>(List.of(ownPiece))); //TODO
|
possiblePieceShield = PossiblePieceMessage.shieldPossiblePieces(new ArrayList<>(List.of(ownPiece)));
|
||||||
possiblePieceSwap = PossiblePieceMessage.swapPossiblePieces(new ArrayList<>(List.of(ownPiece)), new ArrayList<>(List.of(enemyPiece))); //TODO
|
possiblePieceSwap = PossiblePieceMessage.swapPossiblePieces(new ArrayList<>(List.of(ownPiece)), new ArrayList<>(List.of(enemyPiece)));
|
||||||
//todo possiblePieceSwap = new PossiblePieceMessage(new ArrayList<>(List.of(ownPiece)), new ArrayList<>(List.of(enemyPiece)));
|
|
||||||
possiblePiece = new PossiblePieceMessage();
|
possiblePiece = new PossiblePieceMessage();
|
||||||
rankingResponse = new RankingResponseMessage();
|
rankingResponse = new RankingResponseMessage();
|
||||||
rankingRollAgain = new RankingRollAgainMessage();
|
rankingRollAgain = new RankingRollAgainMessage();
|
||||||
@@ -322,10 +316,7 @@ public void testDialogsToGame() {
|
|||||||
clientGameLogic.received(rankingRollAgain);
|
clientGameLogic.received(rankingRollAgain);
|
||||||
clientGameLogic.received(reconnectBriefing);
|
clientGameLogic.received(reconnectBriefing);
|
||||||
clientGameLogic.received(resumeGame);
|
clientGameLogic.received(resumeGame);
|
||||||
//clientGameLogic.received(startGame);
|
|
||||||
clientGameLogic.received(startPieceMessage);
|
clientGameLogic.received(startPieceMessage);
|
||||||
//clientGameLogic.received(updateReady);
|
|
||||||
//clientGameLogic.received(updateTSK);
|
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
clientGameLogic.received(spectatorMessage);
|
clientGameLogic.received(spectatorMessage);
|
||||||
clientGameLogic.received(selectPieceMessage);
|
clientGameLogic.received(selectPieceMessage);
|
||||||
@@ -401,7 +392,6 @@ public void testClientGameToCeremony() {
|
|||||||
clientGameLogic.received(ceremonyMessage);
|
clientGameLogic.received(ceremonyMessage);
|
||||||
|
|
||||||
//tests if the client is in the ceremony after receiving the message
|
//tests if the client is in the ceremony after receiving the message
|
||||||
System.out.println(clientGameLogic.getState());
|
|
||||||
assertEquals(clientGameLogic.getState(), ceremony);
|
assertEquals(clientGameLogic.getState(), ceremony);
|
||||||
|
|
||||||
//tests if the state of ceremony is Podium
|
//tests if the state of ceremony is Podium
|
||||||
@@ -473,7 +463,6 @@ public void testStayInInterrupt() {
|
|||||||
clientGameLogic.received(rankingResponse);
|
clientGameLogic.received(rankingResponse);
|
||||||
clientGameLogic.received(rankingRollAgain);
|
clientGameLogic.received(rankingRollAgain);
|
||||||
clientGameLogic.received(reconnectBriefing);
|
clientGameLogic.received(reconnectBriefing);
|
||||||
//clientGameLogic.received(resumeGame); commented out, because it indicates a state-change to gameState
|
|
||||||
clientGameLogic.received(startGame);
|
clientGameLogic.received(startGame);
|
||||||
clientGameLogic.received(startPieceMessage);
|
clientGameLogic.received(startPieceMessage);
|
||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
@@ -634,15 +623,13 @@ public void testNetworkDialogToNetworkDialog1() {
|
|||||||
assertEquals(dialogs.getState(), networkDialog);
|
assertEquals(dialogs.getState(), networkDialog);
|
||||||
|
|
||||||
//simulate all input, that don't indicate a state-change
|
//simulate all input, that don't indicate a state-change
|
||||||
clientGameLogic.selectPiece(null); //TODO
|
clientGameLogic.selectPiece(null);
|
||||||
clientGameLogic.selectCard(null);
|
clientGameLogic.selectCard(null);
|
||||||
clientGameLogic.selectTsk(color);
|
clientGameLogic.selectTsk(color);
|
||||||
clientGameLogic.selectDice();
|
clientGameLogic.selectDice();
|
||||||
clientGameLogic.selectName(name);
|
clientGameLogic.selectName(name);
|
||||||
clientGameLogic.selectReady(true);
|
clientGameLogic.selectReady(true);
|
||||||
clientGameLogic.selectHost(name);
|
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.selectAnimationEnd();
|
||||||
clientGameLogic.selectStart();
|
clientGameLogic.selectStart();
|
||||||
|
|
||||||
@@ -714,17 +701,15 @@ public void testStayInLobby() {
|
|||||||
assertEquals(dialogs.getState(), lobby);
|
assertEquals(dialogs.getState(), lobby);
|
||||||
|
|
||||||
//simulate all input that don't indicate a state-change
|
//simulate all input that don't indicate a state-change
|
||||||
clientGameLogic.selectPiece(null); //TODO
|
clientGameLogic.selectPiece(null);
|
||||||
clientGameLogic.selectCard(null);
|
clientGameLogic.selectCard(null);
|
||||||
clientGameLogic.selectTsk(color);
|
clientGameLogic.selectTsk(color);
|
||||||
clientGameLogic.selectDice();
|
clientGameLogic.selectDice();
|
||||||
clientGameLogic.selectName(name);
|
clientGameLogic.selectName(name);
|
||||||
clientGameLogic.selectReady(true);
|
clientGameLogic.selectReady(true);
|
||||||
clientGameLogic.selectHost(name);
|
clientGameLogic.selectHost(name);
|
||||||
//clientGameLogic.selectLeave(); commented because it indicate a state-change to start-dialog
|
|
||||||
clientGameLogic.selectJoin(name);
|
clientGameLogic.selectJoin(name);
|
||||||
clientGameLogic.selectAnimationEnd();
|
clientGameLogic.selectAnimationEnd();
|
||||||
//clientGameLogic.selectStart(); commented because it indicate a state-change to determineStartPlayer if host
|
|
||||||
|
|
||||||
//sends all messages, which don't indicate a statechange
|
//sends all messages, which don't indicate a statechange
|
||||||
clientGameLogic.received(activePlayer);
|
clientGameLogic.received(activePlayer);
|
||||||
@@ -751,7 +736,6 @@ public void testStayInLobby() {
|
|||||||
clientGameLogic.received(rankingRollAgain);
|
clientGameLogic.received(rankingRollAgain);
|
||||||
clientGameLogic.received(reconnectBriefing);
|
clientGameLogic.received(reconnectBriefing);
|
||||||
clientGameLogic.received(resumeGame);
|
clientGameLogic.received(resumeGame);
|
||||||
//clientGameLogic.received(startGame); commented because it indicate a state-change to determineStartPlayer
|
|
||||||
clientGameLogic.received(startPieceMessage);
|
clientGameLogic.received(startPieceMessage);
|
||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
@@ -816,11 +800,9 @@ public void testDetermineStartPlayerToWait() {
|
|||||||
assertEquals(determineStartPlayer.getState(), determineStartPlayer.getIntro());
|
assertEquals(determineStartPlayer.getState(), determineStartPlayer.getIntro());
|
||||||
|
|
||||||
int animationCounter = determineStartPlayer.getIntro().getAnimationCounter();
|
int animationCounter = determineStartPlayer.getIntro().getAnimationCounter();
|
||||||
System.out.println(animationCounter);
|
|
||||||
for (int i = 0; i < animationCounter; i++) {
|
for (int i = 0; i < animationCounter; i++) {
|
||||||
clientGameLogic.selectAnimationEnd();
|
clientGameLogic.selectAnimationEnd();
|
||||||
}
|
}
|
||||||
System.out.println(determineStartPlayer.getIntro().getAnimationCounter());
|
|
||||||
|
|
||||||
//tests if the client is in the Wait-State
|
//tests if the client is in the Wait-State
|
||||||
assertEquals(clientGameLogic.getState(), gameState);
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
@@ -851,7 +833,7 @@ public void testWaitToAnimation() {
|
|||||||
gameState.setState(waiting);
|
gameState.setState(waiting);
|
||||||
assertEquals(gameState.getState(), waiting);
|
assertEquals(gameState.getState(), waiting);
|
||||||
|
|
||||||
//sends the playTurboCard-message todo
|
//sends the playTurboCard-message
|
||||||
clientGameLogic.received(playCardTurbo);
|
clientGameLogic.received(playCardTurbo);
|
||||||
|
|
||||||
//tests if a powerCard is played,that the client goes into Animation
|
//tests if a powerCard is played,that the client goes into Animation
|
||||||
@@ -942,18 +924,14 @@ public void testTurnSubStatesToGameEndState() {
|
|||||||
clientGameLogic.received(activePlayer);
|
clientGameLogic.received(activePlayer);
|
||||||
clientGameLogic.received(anyPiece);
|
clientGameLogic.received(anyPiece);
|
||||||
clientGameLogic.received(briefing);
|
clientGameLogic.received(briefing);
|
||||||
//clientGameLogic.received(ceremonyMessage); commented because it indicate a state-change to ceremony-state
|
|
||||||
clientGameLogic.received(die);
|
clientGameLogic.received(die);
|
||||||
clientGameLogic.received(diceAgain);
|
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(lobbyAccept);
|
||||||
clientGameLogic.received(lobbyDeny);
|
clientGameLogic.received(lobbyDeny);
|
||||||
clientGameLogic.received(lobbyPlayerJoin);
|
clientGameLogic.received(lobbyPlayerJoin);
|
||||||
clientGameLogic.received(lobbyPlayerLeave);
|
clientGameLogic.received(lobbyPlayerLeave);
|
||||||
clientGameLogic.received(moveMessage);
|
clientGameLogic.received(moveMessage);
|
||||||
clientGameLogic.received(noTurn);
|
clientGameLogic.received(noTurn);
|
||||||
//clientGameLogic.received(interruptMessage); commented because it indicate a state-change to interrupt-state
|
|
||||||
clientGameLogic.received(playCardSwap);
|
clientGameLogic.received(playCardSwap);
|
||||||
clientGameLogic.received(playCardShield);
|
clientGameLogic.received(playCardShield);
|
||||||
clientGameLogic.received(playCardTurbo);
|
clientGameLogic.received(playCardTurbo);
|
||||||
@@ -968,7 +946,6 @@ public void testTurnSubStatesToGameEndState() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
//clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state
|
|
||||||
clientGameLogic.received(selectPieceMessage);
|
clientGameLogic.received(selectPieceMessage);
|
||||||
|
|
||||||
//tests if the client is still in MovePiece
|
//tests if the client is still in MovePiece
|
||||||
@@ -1170,18 +1147,14 @@ public void testTurnSubStatesToSpectator() {
|
|||||||
clientGameLogic.received(activePlayer);
|
clientGameLogic.received(activePlayer);
|
||||||
clientGameLogic.received(anyPiece);
|
clientGameLogic.received(anyPiece);
|
||||||
clientGameLogic.received(briefing);
|
clientGameLogic.received(briefing);
|
||||||
//clientGameLogic.received(ceremonyMessage); commented because it indicate a state-change to ceremony-state
|
|
||||||
clientGameLogic.received(die);
|
clientGameLogic.received(die);
|
||||||
clientGameLogic.received(diceAgain);
|
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(lobbyAccept);
|
||||||
clientGameLogic.received(lobbyDeny);
|
clientGameLogic.received(lobbyDeny);
|
||||||
clientGameLogic.received(lobbyPlayerJoin);
|
clientGameLogic.received(lobbyPlayerJoin);
|
||||||
clientGameLogic.received(lobbyPlayerLeave);
|
clientGameLogic.received(lobbyPlayerLeave);
|
||||||
clientGameLogic.received(moveMessage);
|
clientGameLogic.received(moveMessage);
|
||||||
clientGameLogic.received(noTurn);
|
clientGameLogic.received(noTurn);
|
||||||
//clientGameLogic.received(interruptMessage); commented because it indicate a state-change to interrupt-state
|
|
||||||
clientGameLogic.received(playCardSwap);
|
clientGameLogic.received(playCardSwap);
|
||||||
clientGameLogic.received(playCardShield);
|
clientGameLogic.received(playCardShield);
|
||||||
clientGameLogic.received(playCardTurbo);
|
clientGameLogic.received(playCardTurbo);
|
||||||
@@ -1196,7 +1169,6 @@ public void testTurnSubStatesToSpectator() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
//clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state
|
|
||||||
clientGameLogic.received(selectPieceMessage);
|
clientGameLogic.received(selectPieceMessage);
|
||||||
|
|
||||||
//tests if the client is still in MovePiece
|
//tests if the client is still in MovePiece
|
||||||
@@ -2397,9 +2369,7 @@ public void testStayInSelectedPiece() {
|
|||||||
clientGameLogic.received(lobbyDeny);
|
clientGameLogic.received(lobbyDeny);
|
||||||
clientGameLogic.received(lobbyPlayerJoin);
|
clientGameLogic.received(lobbyPlayerJoin);
|
||||||
clientGameLogic.received(lobbyPlayerLeave);
|
clientGameLogic.received(lobbyPlayerLeave);
|
||||||
//clientGameLogic.received(moveMessage);
|
|
||||||
clientGameLogic.received(noTurn);
|
clientGameLogic.received(noTurn);
|
||||||
//clientGameLogic.received(interruptMessage);
|
|
||||||
clientGameLogic.received(playCardSwap);
|
clientGameLogic.received(playCardSwap);
|
||||||
clientGameLogic.received(playCardShield);
|
clientGameLogic.received(playCardShield);
|
||||||
clientGameLogic.received(playCardTurbo);
|
clientGameLogic.received(playCardTurbo);
|
||||||
@@ -2485,9 +2455,7 @@ public void testStayInStartPiece() {
|
|||||||
clientGameLogic.received(lobbyDeny);
|
clientGameLogic.received(lobbyDeny);
|
||||||
clientGameLogic.received(lobbyPlayerJoin);
|
clientGameLogic.received(lobbyPlayerJoin);
|
||||||
clientGameLogic.received(lobbyPlayerLeave);
|
clientGameLogic.received(lobbyPlayerLeave);
|
||||||
//clientGameLogic.received(moveMessage);
|
|
||||||
clientGameLogic.received(noTurn);
|
clientGameLogic.received(noTurn);
|
||||||
//clientGameLogic.received(interruptMessage);
|
|
||||||
clientGameLogic.received(playCardSwap);
|
clientGameLogic.received(playCardSwap);
|
||||||
clientGameLogic.received(playCardShield);
|
clientGameLogic.received(playCardShield);
|
||||||
clientGameLogic.received(playCardTurbo);
|
clientGameLogic.received(playCardTurbo);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public void setUp() {
|
|||||||
playerClient.initialize();
|
playerClient.initialize();
|
||||||
playerClient.addHandCard(bonusCardClient);
|
playerClient.addHandCard(bonusCardClient);
|
||||||
game.addPlayer(IDPlayerClient, playerClient);
|
game.addPlayer(IDPlayerClient, playerClient);
|
||||||
pieceClient4 = playerHost.getWaitingArea()[3];
|
pieceClient4 = playerClient.getWaitingArea()[3];
|
||||||
game.getBoard().setPieceOnBoard(22,pieceClient4);
|
game.getBoard().setPieceOnBoard(22,pieceClient4);
|
||||||
pieceClient4.setState(PieceState.ACTIVE);
|
pieceClient4.setState(PieceState.ACTIVE);
|
||||||
|
|
||||||
@@ -784,19 +784,34 @@ public void testPlayPowerCardToRollDice() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChoosePieceToMovePiece() {
|
public void testChoosePieceToMovePiece() {
|
||||||
|
playerClient.setHandCards(new ArrayList<>());
|
||||||
|
game.setActiveColor(playerClientColor);
|
||||||
|
turnState.setPlayer(playerClient);
|
||||||
|
playerClient.removeWaitingPiece(pieceClient4);
|
||||||
|
game.getBoard().setPieceOnBoard(25,pieceClient4);
|
||||||
|
pieceClient4.setState(PieceState.ACTIVE);
|
||||||
|
|
||||||
//sends the server in Game-State
|
//sends the server in Game-State
|
||||||
serverGameLogic.setCurrentState(gameState);
|
serverGameLogic.setCurrentState(gameState);
|
||||||
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
||||||
|
game.setActiveColor(playerClientColor);
|
||||||
|
game.setDiceEyes(1);
|
||||||
//sends the gameState in Turn
|
//sends the gameState in Turn
|
||||||
gameState.setCurrentState(turnState);
|
gameState.setCurrentState(turnState);
|
||||||
assertEquals(gameState.getCurrentState(), turnState);
|
assertEquals(gameState.getCurrentState(), turnState);
|
||||||
|
game.setActiveColor(playerClientColor);
|
||||||
//sends the TurnState in ChoosePiece
|
//sends the TurnState in ChoosePiece
|
||||||
turnState.setCurrentState(choosePieceState);
|
turnState.setCurrentState(choosePieceState);
|
||||||
assertEquals(turnState.getCurrentState(), choosePieceState);
|
assertEquals(turnState.getCurrentState(), choosePieceState);
|
||||||
|
|
||||||
//Todo ???
|
choosePieceState.setCurrentState(selectPieceState);
|
||||||
|
System.out.println(game.getBoard().getInfieldIndexOfPiece(pieceClient4));
|
||||||
|
selectPieceState.setMoveablePieces(new ArrayList<>(List.of(pieceClient4)));
|
||||||
|
selectPieceState.setIsHomeMove(new ArrayList<>(List.of(false)));
|
||||||
|
selectPieceState.setTargetIndex(new ArrayList<>(List.of(23)));
|
||||||
|
|
||||||
|
serverGameLogic.received(new RequestMoveMessage(pieceClient4),IDPlayerClient);
|
||||||
|
|
||||||
|
|
||||||
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
||||||
assertEquals(gameState.getCurrentState(), turnState);
|
assertEquals(gameState.getCurrentState(), turnState);
|
||||||
@@ -867,7 +882,7 @@ public void testMovePieceToFirstRoll() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFirstRollToRollDiceEndState() {
|
public void testFirstRollToRollDiceEndState() {
|
||||||
|
playerClient.setHandCards(new ArrayList<>());
|
||||||
|
|
||||||
//sends the server in Game-State
|
//sends the server in Game-State
|
||||||
serverGameLogic.setCurrentState(gameState);
|
serverGameLogic.setCurrentState(gameState);
|
||||||
@@ -877,6 +892,7 @@ public void testFirstRollToRollDiceEndState() {
|
|||||||
gameState.setCurrentState(turnState);
|
gameState.setCurrentState(turnState);
|
||||||
assertEquals(gameState.getCurrentState(), turnState);
|
assertEquals(gameState.getCurrentState(), turnState);
|
||||||
|
|
||||||
|
game.setActiveColor(playerClientColor);
|
||||||
//sends the TurnState in RollDice
|
//sends the TurnState in RollDice
|
||||||
turnState.setCurrentState(rollDiceState);
|
turnState.setCurrentState(rollDiceState);
|
||||||
assertEquals(turnState.getCurrentState(), rollDiceState);
|
assertEquals(turnState.getCurrentState(), rollDiceState);
|
||||||
@@ -885,13 +901,17 @@ public void testFirstRollToRollDiceEndState() {
|
|||||||
rollDiceState.setCurrentState(firstRollState);
|
rollDiceState.setCurrentState(firstRollState);
|
||||||
assertEquals(rollDiceState.getCurrentState(), firstRollState);
|
assertEquals(rollDiceState.getCurrentState(), firstRollState);
|
||||||
|
|
||||||
//TODO 2 Möglichkeiten
|
firstRollState.setMoveablePieces(new ArrayList<>(List.of(pieceClient4)));
|
||||||
|
|
||||||
//tests if the server is in NoPiece of ChoosePiece
|
game.setDie(new Die(1));
|
||||||
|
|
||||||
|
serverGameLogic.received(new RequestDieMessage(),IDPlayerClient);
|
||||||
|
serverGameLogic.received(new AnimationEndMessage(),IDPlayerClient);
|
||||||
|
|
||||||
|
//tests if the server is in ChoosePiece
|
||||||
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
||||||
assertEquals(gameState.getCurrentState(), turnState);
|
assertEquals(gameState.getCurrentState(), turnState);
|
||||||
assertEquals(turnState.getCurrentState(), choosePieceState);
|
assertEquals(turnState.getCurrentState(), choosePieceState);
|
||||||
assertEquals(choosePieceState.getCurrentState(), noPieceState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -923,9 +943,9 @@ public void testFirstRollToSecondRoll() {
|
|||||||
|
|
||||||
game.setDie(new Die(5));
|
game.setDie(new Die(5));
|
||||||
game.setDiceEyes(5);
|
game.setDiceEyes(5);
|
||||||
//Todo player has no figures to move and had no 6
|
//player has no figures to move and had no 6
|
||||||
serverGameLogic.received(requestDie, IDPlayerHost);
|
serverGameLogic.received(requestDie, IDPlayerClient);
|
||||||
serverGameLogic.received(animationEnd, IDPlayerHost);
|
serverGameLogic.received(animationEnd, IDPlayerClient);
|
||||||
|
|
||||||
//tests if the server is in the SecondRoll
|
//tests if the server is in the SecondRoll
|
||||||
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
||||||
|
|||||||
Reference in New Issue
Block a user