Commit 9c2a0468 authored by Thomas DENIS's avatar Thomas DENIS
Browse files

Merge remote-tracking branch 'origin/master'

parents 2c6ac810 d369a840
......@@ -9,6 +9,7 @@ import fr.univnantes.alma.server.game.item.board.Board;
import fr.univnantes.alma.server.game.item.board.BoardColor;
import fr.univnantes.alma.server.game.item.board.BoardDistribution;
import fr.univnantes.alma.server.game.item.board.Score;
import fr.univnantes.alma.server.game.item.card.Card;
import fr.univnantes.alma.server.game.item.card.PlaceCard;
import fr.univnantes.alma.server.game.item.card.SurvivalCard;
import fr.univnantes.alma.server.game.item.card.TrackingCard;
......@@ -71,6 +72,8 @@ public class GameTest {
final SurvivalCard vaccin = database.findSurvivalCard(VACCIN.toString());
final SurvivalCard sixieme_sens = database.findSurvivalCard(SIXIEME_SENS.toString());
final SurvivalCard riposte = database.findSurvivalCard(RIPOSTE.toString());
final SurvivalCard hologramme = database.findSurvivalCard(HOLOGRAMME.toString());
final SurvivalCard retraite = database.findSurvivalCard(RETRAITE.toString());
@BeforeEach
public void setUp() {
......@@ -313,6 +316,67 @@ public class GameTest {
.thenReturn(new ActionChoosePower(0));
assertTrue(game.traqueCanResist());
}
@Test
void testPlayerResist_false() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
Response response = new Response(false, "Number must be 1 or 2");
assertEquals(response, game.playerResist(2, 3));
}
@Test
void testPlayerResist_falsePhase2() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_2).state);
assertTrue(game.playerPlaceJeton(1, Collections.singletonList(new PlacedJeton(JetonSymbol.CREATURE, Collections.singletonList(Place.PLACE_ONE)))).state);
Response response = new Response(false, "Resist is only possible in PHASE_1");
assertEquals(response, game.playerResist(2, 2));
}
@Test
void testPlayerResist_true() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
Response response = new Response(true, "");
assertEquals(response, game.playerResist(2, 2));
}
@Test
void testTraqueCanPickSurvivalCards() throws TException {
......@@ -421,19 +485,86 @@ public class GameTest {
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), new ArrayList<TrackingCard>(Arrays.asList(acharnement, mutation))));
}
@Test
void testApplyTraquePlaySurvivalCard_true() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
game.getCreature().getTrackingCardHand().clear();
game.getCreature().getTrackingCardHand().add(acharnement);
game.getCreature().getTrackingCardHand().add(mutation);
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
board.moveForwardTraque(11);
board.moveForwardCreature(6);
assertEquals(new Score(1, 2), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
game.traquePlaySurvivalCard(game.getTraques().get(0), vaccin);
assertEquals(2,game.getBoard().getScoreCreature());
}
@Test
void testPlayerPlayCard_sendErrorMessage() throws TException {
void testApplyTraquePlaySurvivalCard_false() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(retraite);
game.getTraques().get(0).getSurvivalCardsHand().add(hologramme);
board.moveForwardTraque(11);
board.moveForwardCreature(6);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
Response response = new Response(false, "Unable to play this card");
assertEquals(response, game.traquePlaySurvivalCard(game.getTraques().get(0), hologramme));
assertEquals(response, game.traquePlaySurvivalCard(game.getTraques().get(0), new ArrayList<SurvivalCard>(Arrays.asList(hologramme,retraite))));
}
@Test
void testCreaturePlayTrackingCard() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
game.getCreature().getTrackingCardHand().clear();
game.getCreature().getTrackingCardHand().add(acharnement);
game.getCreature().getTrackingCardHand().add(mutation);
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
assertEquals(new Score(7, 13), board.getScore());
board.moveForwardTraque(11);
board.moveForwardCreature(6);
assertEquals(new Score(1, 2), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
game.traquePlaySurvivalCard(game.getTraques().get(0), vaccin);
assertEquals(2,game.getBoard().getScoreCreature());
}
@Test
void testPlayerPlayCard_sendErrorMessage() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
......@@ -455,10 +586,147 @@ public class GameTest {
/*test playerPlayCard*/
Response response = new Response(false, "No card authorize in this phase");
assertEquals(response, game.playerPlayCard(2, riviere));
}
@Test
void testPlayerPlayCard_sendErrorMessage2() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
Response response = new Response(false, "Need a place card");
assertEquals(response,game.playerPlayCard(2, vaccin));
}
@Test
void testPlayerPlayCard_sendErrorMessage3() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
game.getCreature().getTrackingCardHand().clear();
game.getCreature().getTrackingCardHand().add(acharnement);
game.getCreature().getTrackingCardHand().add(mutation);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
Response response = new Response(false, "No card authorize in this phase");
assertEquals(response,game.playerPlayCard(1, acharnement));
}@Test
void testPlayerPlayCard_true() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
Response response = new Response(true, "");
assertEquals(response,game.playerPlayCard(2, plage));
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
}
@Test
void testPlayerPlayCardList_sendErrorMessage() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
assertEquals(new Score(7, 13), board.getScore());
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
Response response = new Response(false, "Need only place card");
assertEquals(response,game.playerPlayCard(2, new ArrayList(Arrays.asList(plage,vaccin))));
}
@Test
void testTraquePlayPlaceCard_sendErrorMessage() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
assertEquals(new Score(7, 13), board.getScore());
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
Response response = new Response(false, "Unable to play this card");
game.traquePlayPlaceCard(game.getTraques().get(0), plage);
assertEquals(response,game.traquePlayPlaceCard(game.getTraques().get(0), riviere));
}
}
/*Pour moi
/*Pour moi playerResist
@Test
void testGamePair() throws TException {
Room room = mock(Room.class);
......@@ -478,7 +746,6 @@ public class GameTest {
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertEquals(game.getState(), Phase.PHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment