fixed some tests
This commit is contained in:
@@ -85,4 +85,13 @@ public void selectAnimationEnd(){
|
||||
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is used to return the animationCounter
|
||||
*
|
||||
* @return int animationCounter
|
||||
*/
|
||||
public int getAnimationCounter(){
|
||||
return animationCounter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public void received(AnimationEndMessage msg, int from) {
|
||||
} else if (!isDied){
|
||||
LOGGER.log(System.Logger.Level.INFO, "Received AnimationEndMessage without the active player rolling a die.");
|
||||
} else if (!moveablePieces.isEmpty()) {
|
||||
System.out.println(!moveablePieces.isEmpty());
|
||||
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
|
||||
this.rollDiceAutomaton.getTurnAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getChoosePieceState());
|
||||
} else {
|
||||
@@ -89,4 +90,13 @@ public void received(AnimationEndMessage msg, int from) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the movabelPieces
|
||||
*
|
||||
* @param moveablePieces
|
||||
*/
|
||||
public void setMoveablePieces(List<Piece> moveablePieces) {
|
||||
this.moveablePieces = moveablePieces;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
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.message.client.ClientMessage;
|
||||
@@ -150,6 +153,9 @@ public void send(ClientMessage msg) {
|
||||
|
||||
//initialize a player
|
||||
player = new Player(name);
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new SwapCard());
|
||||
player.addHandCard(new ShieldCard());
|
||||
player.setColor(color);
|
||||
player.initialize();
|
||||
game.addPlayer(1234,player);
|
||||
@@ -853,7 +859,7 @@ public void testDetermineStartPlayerToWait() {
|
||||
assertEquals(determineStartPlayer.getState(), waitRanking);
|
||||
|
||||
//sends the message, that indicate a statechange to wait
|
||||
clientGameLogic.received(activePlayer);
|
||||
clientGameLogic.received(new ActivePlayerMessage(enemyColor));
|
||||
clientGameLogic.selectAnimationEnd();
|
||||
|
||||
//tests if the client is in the intro
|
||||
@@ -861,7 +867,12 @@ public void testDetermineStartPlayerToWait() {
|
||||
assertEquals(gameState.getState(), determineStartPlayer);
|
||||
assertEquals(determineStartPlayer.getState(),determineStartPlayer.getIntro());
|
||||
|
||||
//todo
|
||||
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);
|
||||
@@ -1420,7 +1431,8 @@ public void testStayInPlayPowerCard() {
|
||||
assertEquals(gameState.getState(), turnState);
|
||||
|
||||
//sends the turnState in PlayPowerCard
|
||||
turnState.setState(playPowerCard);
|
||||
playPowerCard.setPlayCard(playCardShield);
|
||||
turnState.setState(turnState.getPlayPowerCard());
|
||||
assertEquals(turnState.getState(), playPowerCard);
|
||||
|
||||
//sends all messages that don't indicate a state-change
|
||||
@@ -2763,8 +2775,6 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() {
|
||||
//sends all messages that don't indicate a state-change
|
||||
clientGameLogic.received(anyPiece);
|
||||
clientGameLogic.received(briefing);
|
||||
clientGameLogic.received(die);
|
||||
//clientGameLogic.received(endOfTurn);
|
||||
clientGameLogic.received(lobbyAccept);
|
||||
clientGameLogic.received(lobbyDeny);
|
||||
clientGameLogic.received(lobbyPlayerJoin);
|
||||
@@ -2791,8 +2801,19 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() {
|
||||
assertEquals(gameState.getState(), determineStartPlayer);
|
||||
assertEquals(determineStartPlayer.getState(), waitRanking);
|
||||
|
||||
//sends endOfTurn-message todo intro
|
||||
clientGameLogic.received(activePlayer);
|
||||
clientGameLogic.received(new ActivePlayerMessage(enemyColor));
|
||||
clientGameLogic.selectAnimationEnd();
|
||||
|
||||
//test if the client is in intro
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
assertEquals(gameState.getState(), determineStartPlayer);
|
||||
assertEquals(determineStartPlayer.getState(), determineStartPlayer.getIntro());
|
||||
|
||||
//sends endOfTurn-message
|
||||
int animationCounter =determineStartPlayer.getIntro().getAnimationCounter();
|
||||
for(int i =0; i<animationCounter;i++){
|
||||
clientGameLogic.selectAnimationEnd();
|
||||
}
|
||||
|
||||
//test if the client is in wait
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -260,6 +261,9 @@ public void shutdown() {
|
||||
*/
|
||||
@Test
|
||||
public void testMove() {
|
||||
//sets the active Player to host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//sends the server in firstRoll
|
||||
serverGameLogic.setCurrentState(gameState);
|
||||
gameState.setCurrentState(turnState);
|
||||
@@ -272,15 +276,13 @@ public void testMove() {
|
||||
assertEquals(turnState.getCurrentState(),rollDiceState);
|
||||
assertEquals(rollDiceState.getCurrentState(),firstRollState);
|
||||
|
||||
//sets the active Player to host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//sets the die-class, to roll 4's
|
||||
Die die = new Die(4);
|
||||
Die die = new Die(6);
|
||||
game.setDie(die4);
|
||||
|
||||
//sends the request-die-message
|
||||
serverGameLogic.received(new RequestDieMessage(),IDHost);
|
||||
serverGameLogic.received(new AnimationEndMessage(),IDHost);
|
||||
|
||||
//tests if the server is in selectPieceState
|
||||
assertTrue(game.getBoard().getInfield()[12].isOccupied());
|
||||
@@ -315,6 +317,9 @@ public void testMove() {
|
||||
*/
|
||||
@Test
|
||||
public void testCantMove() {
|
||||
//set active player to army
|
||||
game.setActiveColor(clientColor);
|
||||
|
||||
//sends the server in firstRoll
|
||||
serverGameLogic.setCurrentState(gameState);
|
||||
gameState.setCurrentState(turnState);
|
||||
@@ -327,9 +332,6 @@ public void testCantMove() {
|
||||
assertEquals(turnState.getCurrentState(),rollDiceState);
|
||||
assertEquals(rollDiceState.getCurrentState(),firstRollState);
|
||||
|
||||
//set active player to army
|
||||
game.setActiveColor(clientColor);
|
||||
|
||||
//set die-class
|
||||
game.setDie(die2);
|
||||
|
||||
@@ -367,6 +369,10 @@ public void testNoPossibleMove() {
|
||||
*/
|
||||
@Test
|
||||
public void testThrow() {
|
||||
|
||||
//set active player to host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//sends the server in firstRoll
|
||||
serverGameLogic.setCurrentState(gameState);
|
||||
gameState.setCurrentState(turnState);
|
||||
@@ -379,9 +385,6 @@ public void testThrow() {
|
||||
assertEquals(turnState.getCurrentState(),rollDiceState);
|
||||
assertEquals(rollDiceState.getCurrentState(),firstRollState);
|
||||
|
||||
//set active player to host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//set Dice to 1
|
||||
game.setDie(die1);
|
||||
|
||||
@@ -446,6 +449,10 @@ public void testGetThrown() {
|
||||
*/
|
||||
@Test
|
||||
public void testLeaveWaitingArea() {
|
||||
|
||||
//set active player to host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//sends the server in firstRoll
|
||||
serverGameLogic.setCurrentState(gameState);
|
||||
gameState.setCurrentState(turnState);
|
||||
@@ -458,9 +465,6 @@ public void testLeaveWaitingArea() {
|
||||
assertEquals(turnState.getCurrentState(),rollDiceState);
|
||||
assertEquals(rollDiceState.getCurrentState(),firstRollState);
|
||||
|
||||
//set active player to host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//set Dice to 6
|
||||
game.setDie(die6);
|
||||
|
||||
@@ -492,6 +496,9 @@ public void testLeaveWaitingArea() {
|
||||
*/
|
||||
@Test
|
||||
public void testMustLeaveStartingField() {
|
||||
//sets the activePlayer to cyber
|
||||
game.setActiveColor(cyberColor);
|
||||
|
||||
//sends the server in firstRoll
|
||||
serverGameLogic.setCurrentState(gameState);
|
||||
gameState.setCurrentState(turnState);
|
||||
@@ -504,20 +511,18 @@ public void testMustLeaveStartingField() {
|
||||
assertEquals(turnState.getCurrentState(),rollDiceState);
|
||||
assertEquals(rollDiceState.getCurrentState(),firstRollState);
|
||||
|
||||
//sets the activePlayer to cyber
|
||||
game.setActiveColor(cyberColor);
|
||||
|
||||
//set Dice to 4
|
||||
game.setDie(die4);
|
||||
|
||||
//send requestDiceMessage
|
||||
serverGameLogic.received(new RequestDieMessage(),IDCyber);
|
||||
serverGameLogic.received(new AnimationEndMessage(),IDCyber);
|
||||
|
||||
//tests if the sever is in startPiece
|
||||
serverGameLogic.setCurrentState(gameState);
|
||||
gameState.setCurrentState(turnState);
|
||||
turnState.setCurrentState(choosePieceState);
|
||||
choosePieceState.setCurrentState(startPieceState);
|
||||
assertEquals(serverGameLogic.getCurrentState(),gameState);
|
||||
assertEquals(gameState.getCurrentState(), turnState);
|
||||
assertEquals(turnState.getCurrentState(),choosePieceState);
|
||||
assertEquals(choosePieceState.getCurrentState(),startPieceState);
|
||||
|
||||
//send requestMoveMessage
|
||||
serverGameLogic.received(new RequestMoveMessage(pieceHost1),IDCyber);
|
||||
@@ -655,6 +660,10 @@ public void testCantLeaveStartingField() {
|
||||
*/
|
||||
@Test
|
||||
public void testReachBonusField() {
|
||||
|
||||
//sets the active Player to Host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//sends the server in firstRoll
|
||||
serverGameLogic.setCurrentState(gameState);
|
||||
gameState.setCurrentState(turnState);
|
||||
@@ -670,9 +679,6 @@ public void testReachBonusField() {
|
||||
//gets the top bonusCard
|
||||
PowerCard card = game.getDrawPile().get(0);
|
||||
|
||||
//sets the active Player to Host
|
||||
game.setActiveColor(hostColor);
|
||||
|
||||
//sets the dice-seed to 4
|
||||
game.setDie(die4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user