added some parts of test-method piecetest
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
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.message.server.*;
|
||||
import pp.mdga.game.BonusCard;
|
||||
@@ -108,29 +110,35 @@ public class ClientStateTest {
|
||||
//declare a player
|
||||
private Player player;
|
||||
|
||||
//declare own piece
|
||||
private Piece ownPiece= new Piece(Color.ARMY, PieceState.ACTIVE,666);
|
||||
|
||||
//declare enemy piece
|
||||
private Piece enemyPiece = new Piece(Color.CYBER, PieceState.ACTIVE,666);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
//initialize the game
|
||||
game = new Game();
|
||||
|
||||
//initialize the clientGameLogic
|
||||
clientGameLogic = new ClientGameLogic(game, new ClientSender() {
|
||||
clientGameLogic = new ClientGameLogic(new ClientSender() {
|
||||
@Override
|
||||
public void send(ClientMessage msg) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//initialize a player
|
||||
player = new Player(name);
|
||||
|
||||
//todo piece
|
||||
//initialize the game
|
||||
game = clientGameLogic.getGame();
|
||||
|
||||
//initialize the playerID
|
||||
from = 1234;
|
||||
name = "Daniel";
|
||||
color = Color.ARMY;
|
||||
|
||||
//initialize a player
|
||||
player = new Player(name);
|
||||
|
||||
//todo piece
|
||||
|
||||
swapCard = BonusCard.SWAP;
|
||||
shieldCard = BonusCard.SHIELD;
|
||||
turboCard = BonusCard.TURBO;
|
||||
@@ -148,12 +156,12 @@ public void send(ClientMessage msg) {
|
||||
lobbyDeny = new LobbyDenyMessage();
|
||||
lobbyPlayerJoin = new LobbyPlayerJoinedMessage(from, player);
|
||||
lobbyPlayerLeave = new LobbyPlayerLeaveMessage(from);
|
||||
moveMessage = new MoveMessage(, false, 20);//Todo
|
||||
moveMessage = new MoveMessage(ownPiece.getUuid(), false, 25);
|
||||
noTurn = new NoTurnMessage();
|
||||
interruptMessage = new PauseGameMessage();
|
||||
playCardSwap = PlayCardMessage.swap();//Todo
|
||||
playCardShield = PlayCardMessage.shield();//Todo
|
||||
playCardTurbo = PlayCardMessage.turbo(1);//Todo
|
||||
playCardSwap = PlayCardMessage.swap(ownPiece.getUuid(),enemyPiece.getUuid());
|
||||
playCardShield = PlayCardMessage.shield(ownPiece.getUuid());
|
||||
playCardTurbo = PlayCardMessage.turbo(1);
|
||||
possibleCard = new PossibleCardMessage();
|
||||
possiblePieceShield = PossiblePieceMessage.shieldPossiblePieces(new ArrayList<>()); //TODO
|
||||
possiblePieceSwap = PossiblePieceMessage.swapPossiblePieces(new ArrayList<>(), new ArrayList<>()); //TODO
|
||||
@@ -163,7 +171,7 @@ public void send(ClientMessage msg) {
|
||||
reconnectBriefing = new ReconnectBriefingMessage(game);
|
||||
resumeGame = new ResumeGameMessage();
|
||||
startGame = new ServerStartGameMessage();
|
||||
startPieceMessage = new StartPieceMessage(); //Todo wrong class
|
||||
startPieceMessage = new StartPieceMessage(ownPiece.getUuid(),25);
|
||||
updateReady = new UpdateReadyMessage(from, true);
|
||||
updateTSK = new UpdateTSKMessage(from, color);
|
||||
waitPiece = new WaitPieceMessage();
|
||||
@@ -304,11 +312,15 @@ public void testClientGameToCeremony() {
|
||||
clientGameLogic.setState(gameState);
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
|
||||
//sends the gameState in wait
|
||||
gameState.setState(waiting);
|
||||
assertEquals(gameState.getState(), waiting);
|
||||
|
||||
clientGameLogic.received(activePlayer);
|
||||
clientGameLogic.received(anyPiece);
|
||||
clientGameLogic.received(briefing);
|
||||
//clientGameLogic.received(ceremonyMessage);
|
||||
clientGameLogic.received(die);
|
||||
clientGameLogic.received(ceremonyMessage);
|
||||
//clientGameLogic.received(die);
|
||||
clientGameLogic.received(diceAgain);
|
||||
clientGameLogic.received(diceNow);
|
||||
clientGameLogic.received(endOfTurn);
|
||||
@@ -324,8 +336,8 @@ public void testClientGameToCeremony() {
|
||||
clientGameLogic.received(playCardTurbo);
|
||||
clientGameLogic.received(possibleCard);
|
||||
clientGameLogic.received(possiblePiece);
|
||||
clientGameLogic.received(rankingResponse);
|
||||
clientGameLogic.received(rankingRollAgain);
|
||||
//clientGameLogic.received(rankingResponse);
|
||||
//clientGameLogic.received(rankingRollAgain);
|
||||
clientGameLogic.received(reconnectBriefing);
|
||||
clientGameLogic.received(resumeGame);
|
||||
clientGameLogic.received(startGame);
|
||||
@@ -343,6 +355,7 @@ 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
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import pp.mdga.message.client.RequestDieMessage;
|
||||
import pp.mdga.message.client.RequestMoveMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
import pp.mdga.message.server.ServerMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.ServerSender;
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -42,6 +46,10 @@ public class PieceTest {
|
||||
private Piece pieceHost2;
|
||||
private Piece pieceHost3;
|
||||
|
||||
//ID's for player
|
||||
private int IDHost = 1;
|
||||
private int IDClient = 2;
|
||||
|
||||
//declare messages here
|
||||
|
||||
@Before
|
||||
@@ -60,12 +68,17 @@ public void send(int id, ServerMessage message) {
|
||||
public void broadcast(ServerMessage message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnectClient(int id) {
|
||||
|
||||
}
|
||||
}, game);
|
||||
|
||||
//declare player-Client here
|
||||
playerClient = new Player(nameClient);
|
||||
clientColor = Color.ARMY;
|
||||
game.addPlayer(2, playerClient);
|
||||
game.addPlayer(IDClient, playerClient);
|
||||
|
||||
//declare pieces of client here
|
||||
pieceClient0 = game.getBoard().getPlayerData().get(clientColor).getPieces()[0];
|
||||
@@ -81,7 +94,7 @@ public void broadcast(ServerMessage message) {
|
||||
//declare player-host here
|
||||
playerHost = new Player(nameHost);
|
||||
hostColor = Color.NAVY;
|
||||
game.addPlayer(1, playerHost);
|
||||
game.addPlayer(IDHost, playerHost);
|
||||
|
||||
//declare pieces of host here
|
||||
pieceHost0 = game.getBoard().getPlayerData().get(hostColor).getPieces()[0];
|
||||
@@ -98,7 +111,7 @@ public void broadcast(ServerMessage message) {
|
||||
game.getBoard().setPieceOnBoard(25, pieceClient0); //for UC 02, 03.01, 14,4
|
||||
game.getBoard().getPlayerData().get(clientColor).setPieceInHome(1, pieceClient1); //set piece in Home at 2 slot for UC 18,12,13,11
|
||||
game.getBoard().setPieceOnBoard(19, pieceClient2); //for UC 13, 15
|
||||
game.getBoard().setPieceOnBoard(); //todo
|
||||
//game.getBoard().setPieceOnBoard(); //todo
|
||||
|
||||
//set the host-pieces here
|
||||
|
||||
@@ -126,14 +139,25 @@ public void testMove() {
|
||||
// TODO:
|
||||
//sends the server in selectPiece
|
||||
serverGameLogic.setCurrentState(serverGameLogic.getGameState());
|
||||
GameState gameState = serverGameLogic.getGameState();
|
||||
serverGameLogic.getGameState().setCurrentState(serverGameLogic.getGameState().getTurnState());
|
||||
serverGameLogic.getGameState().getTurnState().setCurrentState(turnState.getChoosePieceState());
|
||||
serverGameLogic.getGameState().getTurnState().getChoosePieceState(serverGameLogic.getGameState().getTurnState().getChoosePieceState().getSelectedPieceState());
|
||||
turnState.getChoosePieceState().setCurrentState(turnState.getChoosePieceState().getSelectPieceState());
|
||||
|
||||
//tests if the server is in selectPieces
|
||||
assertEquals(serverGameLogic.getCurrentState(),serverGameLogic.getGameState());
|
||||
assertEquals(serverGameLogic.getGameState().getCurrentState(), turnState);
|
||||
|
||||
//sets the active Player to host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//sets the die-class
|
||||
|
||||
//sends the request-die-message
|
||||
serverGameLogic.received(new RequestDieMessage(),IDHost);
|
||||
|
||||
//sends the move-message
|
||||
serverGameLogic.received(new RequestMoveMessage(pieceHost2.getUuid()),IDHost);
|
||||
|
||||
//tests if the piece has moved in the right direction
|
||||
assertTrue(game.getBoard().getInfield()[4].isOccupied());
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
/**
|
||||
* this test-class tests the Testcases T132-T169
|
||||
*/
|
||||
|
||||
public class ServerStateTest {
|
||||
|
||||
//declare game here
|
||||
@@ -75,7 +76,7 @@ public class ServerStateTest {
|
||||
private CeremonyState ceremonyState;
|
||||
private ChoosePieceState choosePieceState;
|
||||
private DetermineStartPlayerState determineStartPlayerState;
|
||||
private FirstRollStateState firstRollState;
|
||||
private FirstRollState firstRollState;
|
||||
private GameState gameState;
|
||||
private InterruptState interruptState;
|
||||
private LobbyState lobbyState;
|
||||
@@ -92,14 +93,27 @@ public class ServerStateTest {
|
||||
private TurnState turnState;
|
||||
private WaitingPieceState waitingPieceState;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* this method is used to initialize the attributes of this test-class
|
||||
*/
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
game = new Game();
|
||||
game.setActiveColor(playerClientColor);
|
||||
//initialize two players
|
||||
playerHost = new Player("Host");
|
||||
IDPlayerHost = 1;
|
||||
playerHostColor = Color.CYBER;
|
||||
playerHost.setColor(playerHostColor);
|
||||
game.addPlayer(IDPlayerHost, playerHost);
|
||||
|
||||
playerClient = new Player("Client");
|
||||
IDPlayerClient = 2;
|
||||
playerClientColor = Color.ARMY;
|
||||
playerClient.setColor(playerClientColor);
|
||||
playerClient.addHandCard(bonusCardClient);
|
||||
game.addPlayer(IDPlayerClient, playerClient); //TODO random uuid
|
||||
|
||||
serverGameLogic = new ServerGameLogic(new ServerSender() {
|
||||
@Override
|
||||
@@ -118,63 +132,8 @@ public void disconnectClient(int id) {
|
||||
}
|
||||
}, game);
|
||||
|
||||
animationEnd = new AnimationEndMessage();
|
||||
deselectTSK = new DeselectTSKMessage(playerClientColor);
|
||||
disconnected = new DisconnectedMessage();
|
||||
forceContinueGame = new ForceContinueGameMessage();
|
||||
joinServer = new JoinedLobbyMessage();
|
||||
leaveGame = new LeaveGameMessage();
|
||||
lobbyNotReady = new LobbyNotReadyMessage();
|
||||
lobbyReady = new LobbyReadyMessage();
|
||||
noPowerCard = new NoPowerCardMessage();
|
||||
requestBriefing = new RequestBriefingMessage();
|
||||
requestDie = new RequestDieMessage();
|
||||
requestMove = new RequestMoveMessage(IDPiece);
|
||||
requestPlayCard = RequestPlayCardMessage.requestPlayShield(bonusCardClient); //TODO
|
||||
selectCard = new SelectCardMessage(); //TODO
|
||||
selectedPieces = new SelectedPiecesMessage();
|
||||
selectTSK = new SelectTSKMessage();
|
||||
startGame = new StartGameMessage();
|
||||
|
||||
//initialize the states here
|
||||
thirdRollState = rollDiceState.getThirdRollState();
|
||||
secondRollState = rollDiceState.getSecondRollState();
|
||||
firstRollState = rollDiceState.getThirdRollState();
|
||||
|
||||
noPieceState = choosePieceState.getNoPieceState();
|
||||
noTurnState = choosePieceState.getNoTurnState();
|
||||
waitingPieceState = choosePieceState.getWaitingPieceState();
|
||||
startPieceState = choosePieceState.getStartPieceState();
|
||||
selectPieceState = choosePieceState.getSelectPieceState();
|
||||
|
||||
powerCardState = turnState.getPowerCardState();
|
||||
playPowerCardState = turnState.getPlayPowerCardState();
|
||||
rollDiceState = turnState.getRollDiceState();
|
||||
choosePieceState = turnState.getChoosePieceState();
|
||||
movePieceState = turnState.getMovePieceState();
|
||||
|
||||
determineStartPlayerState = gameState.getDetermineStartPlayerState();
|
||||
turnState = gameState.getTurnState();
|
||||
animationState = gameState.getAnimationState();
|
||||
|
||||
lobbyState = (LobbyState) serverGameLogic.getLobbyState();
|
||||
gameState = (GameState) serverGameLogic.getGameState();
|
||||
ceremonyState = (CeremonyState) serverGameLogic.getCeremonyState();
|
||||
interruptState = (InterruptState) serverGameLogic.getInterruptState();
|
||||
|
||||
//initialize two players
|
||||
playerHost = new Player("Host");
|
||||
IDPlayerHost = 1;
|
||||
playerHostColor = Color.CYBER;
|
||||
playerHost.setColor(playerHostColor);
|
||||
game.addPlayer(IDPlayerHost, playerHost);
|
||||
|
||||
playerClient = new Player("Client");
|
||||
IDPlayerClient = 2;
|
||||
playerClientColor = Color.ARMY;
|
||||
playerClient.setColor(playerClientColor);
|
||||
playerClient.addHandCard(bonusCardClient);
|
||||
game.addPlayer(IDPlayerClient, playerClient); //TODO random uuid
|
||||
game.setActiveColor(playerClientColor);
|
||||
|
||||
//initialize a piece for client
|
||||
IDPiece = 3;
|
||||
@@ -195,6 +154,52 @@ public void disconnectClient(int id) {
|
||||
|
||||
//initialize the powerCard
|
||||
bonusCardClient = BonusCard.SHIELD;
|
||||
|
||||
lobbyState = (LobbyState) serverGameLogic.getLobbyState();
|
||||
gameState = (GameState) serverGameLogic.getGameState();
|
||||
ceremonyState = (CeremonyState) serverGameLogic.getCeremonyState();
|
||||
interruptState = (InterruptState) serverGameLogic.getInterruptState();
|
||||
|
||||
determineStartPlayerState = (DetermineStartPlayerState) gameState.getDetermineStartPlayerState();
|
||||
turnState = (TurnState) gameState.getTurnState();
|
||||
animationState = (AnimationState) gameState.getAnimationState();
|
||||
|
||||
|
||||
animationEnd = new AnimationEndMessage();
|
||||
deselectTSK = new DeselectTSKMessage(playerClientColor);
|
||||
disconnected = new DisconnectedMessage();
|
||||
forceContinueGame = new ForceContinueGameMessage();
|
||||
joinServer = new JoinedLobbyMessage();
|
||||
leaveGame = new LeaveGameMessage();
|
||||
lobbyNotReady = new LobbyNotReadyMessage();
|
||||
lobbyReady = new LobbyReadyMessage();
|
||||
noPowerCard = new NoPowerCardMessage();
|
||||
requestBriefing = new RequestBriefingMessage();
|
||||
requestDie = new RequestDieMessage();
|
||||
//requestMove = new RequestMoveMessage(); TODO
|
||||
//requestPlayCard = RequestPlayCardMessage.requestPlayShield(bonusCardClient); //TODO
|
||||
//selectCard = new SelectCardMessage(); //TODO
|
||||
//selectedPieces = new SelectedPiecesMessage(); TODO
|
||||
//selectTSK = new SelectTSKMessage(); TODO
|
||||
//startGame = new StartGameMessage(); TODO
|
||||
|
||||
//initialize the states here
|
||||
|
||||
powerCardState = turnState.getPowerCardState();
|
||||
playPowerCardState = turnState.getPlayPowerCardState();
|
||||
rollDiceState = turnState.getRollDiceState();
|
||||
choosePieceState = turnState.getChoosePieceState();
|
||||
movePieceState = turnState.getMovePieceState();
|
||||
|
||||
thirdRollState = rollDiceState.getThirdRollState();
|
||||
secondRollState = rollDiceState.getSecondRollState();
|
||||
firstRollState = rollDiceState.getFirstRollState();
|
||||
|
||||
noPieceState = choosePieceState.getNoPieceState();
|
||||
noTurnState = choosePieceState.getNoTurnState();
|
||||
waitingPieceState = choosePieceState.getWaitingPieceState();
|
||||
startPieceState = choosePieceState.getStartPieceState();
|
||||
selectPieceState = choosePieceState.getSelectPieceState();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user