Commit 67b7d9ff authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files
parents 7453117d 9c2a0468
...@@ -9,6 +9,7 @@ import fr.univnantes.alma.server.game.item.board.Board; ...@@ -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.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;
...@@ -433,12 +434,147 @@ class GameTest { ...@@ -433,12 +434,147 @@ class GameTest {
Board board = game.getBoard(); Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore()); assertEquals(new Score(7, 13), board.getScore());
board.moveForwardTraque(11);
board.moveForwardCreature(6); when(room.askAction(any(Integer.class), any(TAskAction.class)))
assertEquals(new Score(1, 2), board.getScore()); .thenReturn(new ActionChoosePower(0));
}
@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))) 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(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));
} }
} }
...@@ -462,7 +598,6 @@ class GameTest { ...@@ -462,7 +598,6 @@ class GameTest {
assertEquals(game.getState(), Phase.PREPHASE_1); assertEquals(game.getState(), Phase.PREPHASE_1);
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);
assertEquals(game.getState(), Phase.PHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state); assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state); assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state); assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
......
package fr.univnantes.alma.server.game.item.player.hand; package fr.univnantes.alma.server.game.item.player.hand;
import fr.univnantes.alma.server.game.item.Phase;
import fr.univnantes.alma.server.game.item.card.CardName;
import fr.univnantes.alma.server.game.item.card.TrackingCard;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import fr.univnantes.alma.server.game.item.jeton.JetonSymbol;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
class HandCreatureTest { class HandCreatureTest {
/*
HandCreature hand = new HandCreature(); HandCreature hand = new HandCreature();
@Test @Test
public void testInitializationJeton(){ public void testInitializationJeton(){
Jeton j1 = new JetonArtemia(); assertTrue(hand.getJetonSymbols().contains(JetonSymbol.ARTEMIA));
Jeton j2 = new JetonCreature(); assertTrue(hand.getJetonSymbols().contains(JetonSymbol.CREATURE));
Jeton j3 = new JetonCible(); assertTrue(hand.getJetonSymbols().contains(JetonSymbol.CIBLE));
hand.initializationJeton(); assertTrue(hand.getJetonSymbolsPlayed().isEmpty());
assertTrue(hand.getJetons().contains(j1)); }
assertTrue(hand.getJetons().contains(j2)); @Test
assertTrue(hand.getJetons().contains(j3)); public void testAddTrackingCardToApplied(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
hand.addTrackingCardToApplied(card);
assertTrue(hand.getTrackingCardToApplied().contains(card));
}
@Test
public void testAddTrackingCardToAppliedList(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
List<TrackingCard> testCards= new ArrayList<>();
testCards.add(card);
hand.addTrackingCardToApplied(testCards);
assertTrue(hand.getTrackingCardToApplied().containsAll(testCards));
}
@Test
public void testRemoveTrackingCardToApplied(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
hand.addTrackingCardToApplied(card);
hand.removeTrackingCardToApplied(card);
assertFalse(hand.getTrackingCardToApplied().contains(card));
}
@Test
public void testRemoveTrackingCardToAppliedList(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
List<TrackingCard> testCards= new ArrayList<>();
testCards.add(card);
hand.addTrackingCardToApplied(testCards);
hand.removeTrackingCardToApplied(testCards);
assertFalse(hand.getTrackingCardToApplied().containsAll(testCards));
}
@Test
public void testGetTrackingCardToApplied(){
assertEquals(hand.getTrackingCardToApplied(),new ArrayList<>());
}
@Test
public void testGetJetonSymbolsPlayed(){
assertEquals(hand.getJetonSymbolsPlayed(),new ArrayList<>());
}
@Test
public void testGetJetonSymbols(){
assertEquals(hand.getJetonSymbols(),new ArrayList<>(Arrays.asList(JetonSymbol.CIBLE, JetonSymbol.CREATURE, JetonSymbol.ARTEMIA)));
} }
@Test @Test
public void testPlayJeton(){ public void testPlayJeton(){
Jeton j1 = new JetonArtemia(); JetonSymbol j1 = JetonSymbol.ARTEMIA;
hand.getJetons().add(j1); boolean result = hand.playJeton(j1);
Jeton result = hand.playJeton(j1); assertTrue(result);
assertFalse(hand.getJetons().contains(j1)); assertFalse(hand.getJetonSymbols().contains(j1));
assertTrue(hand.getJetonSymbolsPlayed().contains(j1));
} }
@Test @Test
public void testPlayJetonSet(){ public void testPlayJetonList(){
Jeton j1 = new JetonArtemia(); JetonSymbol j1 = JetonSymbol.ARTEMIA;
Set<Jeton> testjetons = new HashSet<>(); List<JetonSymbol> testjetons = new ArrayList<>();
testjetons.add(j1); testjetons.add(j1);
hand.getJetons().add(j1); hand.getJetonSymbols().add(j1);
Set<Jeton> result = hand.playJeton(testjetons); boolean result = hand.playJeton(testjetons);
assertFalse(hand.getJetons().containsAll(testjetons)); assertTrue(result);
assertFalse(hand.getJetonSymbols().containsAll(testjetons));
assertTrue(hand.getJetonSymbolsPlayed().containsAll(testjetons));
}
@Test
public void testJetonSize(){
assertEquals(3,hand.jetonsSize());
}
@Test
public void testJetonsPlayedSize(){
assertEquals(0,hand.jetonsPlayedSize());
}
@Test
public void testJetonsIsEmpty(){
assertFalse(hand.jetonsIsEmpty());
}
@Test
public void testJetonsPlayedIsEmpty(){
assertTrue(hand.jetonsPlayedIsEmpty());
} }
*/ @Test
public void testGetMaxTrackingCards(){
assertEquals(3,hand.getMaxTrackingCards());
}
@Test
public void testTrackingCardHandSize(){
assertEquals(0,hand.trackingCardHandSize());
}
@Test
public void testTrackingCardPlayedSize(){
assertEquals(0,hand.trackingCardPlayedSize());
}
@Test
public void testTrackingCardHandIsEmpty(){
assertTrue(hand.trackingCardIsEmpty());
}
@Test
public void testTrackingCardHandPlayedIsEmpty(){
assertTrue(hand.trackingCardPlayedIsEmpty());
}
@Test
public void testClearTrackingCardPlayed(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
hand.addTrackingCard(card);
hand.playTrackingCard(card);
hand.clearTrackingCardPlayed();
assertTrue(hand.trackingCardPlayedIsEmpty());
}
@Test
public void testAddTrackingCard(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
hand.addTrackingCard(card);
assertTrue(hand.getTrackingCardHand().contains(card));
}
@Test
public void testAddTrackingCardList(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
List<TrackingCard> testCards = new ArrayList<>();
testCards.add(card);
hand.addTrackingCard(testCards);
assertTrue(hand.getTrackingCardHand().containsAll(testCards));
}
@Test
public void testRemoveTrackingCard(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
hand.addTrackingCard(card);
hand.removeTrackingCard(card);
assertFalse(hand.getTrackingCardHand().contains(card));
}
@Test
public void testRemoveTrackingCardList(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
List<TrackingCard> testCards = new ArrayList<>();
testCards.add(card);
hand.addTrackingCard(testCards);
hand.removeTrackingCard(testCards);
assertFalse(hand.getTrackingCardHand().containsAll(testCards));
}
@Test
public void testPlayTrackingCard(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
hand.addTrackingCard(card);
assertTrue(hand.playTrackingCard(card));
assertFalse(hand.getTrackingCardHand().contains(card));
assertTrue(hand.getTrackingCardsPlayed().contains(card));
}
@Test
public void testPlayTrackingCardList(){
TrackingCard card = new TrackingCard(CardName.INTERFERENCES,"InterferenceCard","The powers of the Beach and the Wreck are ineffective", Phase.PHASE_2);
List<TrackingCard> testCards = new ArrayList<>();
testCards.add(card);
hand.addTrackingCard(testCards);
assertTrue(hand.playTrackingCard(testCards));
assertFalse(hand.getTrackingCardHand().containsAll(testCards));
assertTrue(hand.getTrackingCardsPlayed().containsAll(testCards));
}
} }
\ No newline at end of file
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