Commit 000a01d9 authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files

Refactoring of GameTest

parent 67b7d9ff
...@@ -9,7 +9,6 @@ import fr.univnantes.alma.server.game.item.board.Board; ...@@ -9,7 +9,6 @@ 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.BoardColor;
import fr.univnantes.alma.server.game.item.board.BoardDistribution; 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.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.PlaceCard;
import fr.univnantes.alma.server.game.item.card.SurvivalCard; import fr.univnantes.alma.server.game.item.card.SurvivalCard;
import fr.univnantes.alma.server.game.item.card.TrackingCard; import fr.univnantes.alma.server.game.item.card.TrackingCard;
...@@ -346,62 +345,6 @@ class GameTest { ...@@ -346,62 +345,6 @@ class GameTest {
assertEquals(response, game.playerPlayCard(2, riviere)); assertEquals(response, game.playerPlayCard(2, riviere));
} }
@Test
void testGameScenario() throws TException {
Room room = mock(Room.class);
Game game = new Game(Arrays.asList(1, 2), 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
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));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertFalse(game.playerHasFinished(2, 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);
assertFalse(game.playerHasFinished(1, Phase.PHASE_2).state);
assertTrue(game.playerPlaceJeton(1, Collections.singletonList(new PlacedJeton(JetonSymbol.CREATURE, Collections.singletonList(Place.PLACE_ONE)))).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_2).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_2).state);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_4).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_4).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_4).state);
assertTrue(game.isFinish());
}
@Test @Test
void testApplyTraquePlaySurvivalCard_true() { void testApplyTraquePlaySurvivalCard_true() {
Room room = mock(Room.class); Room room = mock(Room.class);
...@@ -440,141 +383,121 @@ class GameTest { ...@@ -440,141 +383,121 @@ class GameTest {
} }
@Test @Test
void testPlayerPlayCard_sendErrorMessage2() throws TException { void testPlayerPlayCard_traquePlaySurvivalCardInPhase1() {
Room room = mock(Room.class); Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile"))); List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(a, 1, planet, board, room); Game game = new Game(list, 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(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens); //Start phase1
when(room.askAction(any(Integer.class), any(TAskAction.class))) game.startNextPhase();
.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"); Response response = new Response(false, "Need a place card");
assertEquals(response,game.playerPlayCard(2, vaccin)); assertEquals(response,game.playerPlayCard(2, vaccin));
} }
@Test @Test
void testPlayerPlayCard_sendErrorMessage3() throws TException { void testPlayerPlayCard_creaturePlayTrackingCardInPhase1() {
Room room = mock(Room.class); Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile"))); List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(a, 1, planet, board, room); Game game = new Game(list, 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().clear();
game.getCreature().getTrackingCardHand().add(acharnement); game.getCreature().getTrackingCardHand().addAll(Arrays.asList(acharnement, mutation));
game.getCreature().getTrackingCardHand().add(mutation); //Start phase1
game.startNextPhase();
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"); Response response = new Response(false, "No card authorize in this phase");
assertEquals(response,game.playerPlayCard(1, acharnement)); assertEquals(response,game.playerPlayCard(1, acharnement));
}
@Test
void testPlayerPlayCard_traquePlayPlaceCardInPhase1() {
}@Test
void testPlayerPlayCard_true() throws TException {
Room room = mock(Room.class); Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile"))); List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(a, 1, planet, board, room); Game game = new Game(list, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn(); //Start phase1
Board board = game.getBoard(); game.startNextPhase();
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, ""); Response response = new Response(true, "");
assertEquals(response,game.playerPlayCard(2, plage)); assertEquals(response,game.playerPlayCard(2, plage));
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state); assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
}
@Test
void testPlayerPlayCardList_traquePlaySurvivalAndPlaceCardInPhase1() {
Room room = mock(Room.class);
List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(list, 1, planet, board, room);
//Start phase1
game.startNextPhase();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
Response response = new Response(false, "Need only place card");
assertEquals(response,game.playerPlayCard(2, Arrays.asList(plage,vaccin)));
} }
@Test @Test
void testPlayerPlayCardList_sendErrorMessage() throws TException { void testTraquePlayPlaceCard_traquePlaceTwoPlaceCard() {
Room room = mock(Room.class); Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile"))); List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(a, 1, planet, board, room); Game game = new Game(list, 1, planet, board, room);
//Start phase1
game.startNextPhase();
game.traquePlayPlaceCard(game.getTraques().get(0), plage);
Response response = new Response(false, "Unable to play this card");
assertEquals(response,game.traquePlayPlaceCard(game.getTraques().get(0), riviere));
}
@Test
void testGameScenario() throws TException {
Room room = mock(Room.class);
Game game = new Game(Arrays.asList(1, 2), 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore()); assertEquals(new Score(7, 13), board.getScore());
board.moveForwardTraque(11);
board.moveForwardCreature(6);
game.getTraques().get(0).getSurvivalCardsHand().clear(); assertEquals(new Score(1, 2), board.getScore());
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
when(room.askAction(any(Integer.class), any(TAskAction.class))) when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0)); .thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state); assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, 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))));
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertFalse(game.playerHasFinished(2, 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);
@Test assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_1).state);
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()); assertTrue(game.playerHasFinished(1, Phase.PREPHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_2).state);
assertFalse(game.playerHasFinished(1, Phase.PHASE_2).state);
assertTrue(game.playerPlaceJeton(1, Collections.singletonList(new PlacedJeton(JetonSymbol.CREATURE, Collections.singletonList(Place.PLACE_ONE)))).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_2).state);
game.getTraques().get(0).getSurvivalCardsHand().clear(); assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_2).state);
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin); assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_2).state);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
when(room.askAction(any(Integer.class), any(TAskAction.class))) assertTrue(game.playerHasFinished(1, Phase.PREPHASE_3).state);
.thenReturn(new ActionChoosePower(0)); assertTrue(game.playerHasFinished(2, Phase.PREPHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state); assertTrue(game.playerHasFinished(1, Phase.PREPHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state); assertTrue(game.playerHasFinished(2, Phase.PREPHASE_4).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));
assertTrue(game.playerHasFinished(1, Phase.PHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_4).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_4).state);
assertTrue(game.isFinish());
} }
} }
......
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