Commit b024c552 authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files
parents 6e9d81c0 d632ae01
......@@ -14,8 +14,12 @@ 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.jeton.JetonSymbol;
import fr.univnantes.alma.server.game.item.jeton.PlacedJeton;
import fr.univnantes.alma.server.game.item.pioche.Pioche;
import fr.univnantes.alma.server.game.item.planet.Place;
import fr.univnantes.alma.server.game.item.planet.Planet;
import fr.univnantes.alma.server.game.item.power.Power;
import fr.univnantes.alma.server.game.item.power.modifier.PowerModifier;
import fr.univnantes.alma.server.game.item.power.modifier.PowerModifierType;
import fr.univnantes.alma.server.game.utilitary.Pair;
import fr.univnantes.alma.thrift.Response;
import fr.univnantes.alma.thrift.TAskAction;
......@@ -29,6 +33,7 @@ import java.util.Collections;
import java.util.List;
import static fr.univnantes.alma.server.game.item.card.CardName.*;
import static fr.univnantes.alma.server.game.item.power.modifier.PowerModifierType.PLAYABLE_TRACKING_CARD;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
......@@ -63,6 +68,8 @@ class GameTest {
final TrackingCard acharnement = database.findTrackingCard(ACHARNEMENT.toString());
final TrackingCard angoisse = database.findTrackingCard(ANGOISSE.toString());
final TrackingCard mutation = database.findTrackingCard(MUTATION.toString());
final TrackingCard flashBack = database.findTrackingCard(FLASHBACK.toString());
final TrackingCard virus = database.findTrackingCard(VIRUS.toString());
final SurvivalCard adrenaline = database.findSurvivalCard(ADRENALINE.toString());
final SurvivalCard alerte = database.findSurvivalCard(ALERTE.toString());
final SurvivalCard sacrifice = database.findSurvivalCard(SACRIFICE.toString());
......@@ -71,6 +78,9 @@ class GameTest {
final SurvivalCard riposte = database.findSurvivalCard(RIPOSTE.toString());
final SurvivalCard hologramme = database.findSurvivalCard(HOLOGRAMME.toString());
final SurvivalCard retraite = database.findSurvivalCard(RETRAITE.toString());
final PowerModifierType playableTrackingCard = PLAYABLE_TRACKING_CARD;
@BeforeEach
public void setUp() {
......@@ -533,7 +543,8 @@ class GameTest {
game.getTraques().get(0).setCanGiveUp(false);
Response response = new Response(false, "Need a survival card");
assertEquals(response,game.playerPlayPlayerCard(game.getPlayer(2),Arrays.asList(acharnement)));
} @Test
}
@Test
void testPlayerPlayPlayerCard_falseNeedTrackingCardList() {
Room room = mock(Room.class);
List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
......@@ -546,7 +557,96 @@ class GameTest {
Response response = new Response(false, "Need a tracking card");
assertEquals(response,game.playerPlayPlayerCard(game.getPlayer(1),Arrays.asList(vaccin)));
}
@Test
void testGetTrackingCardPioche_true() {
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);
game.getTrackingCardPioche().getCards().clear();
game.getTrackingCardPioche().getCards().add(acharnement);
Pioche<TrackingCard> response = new Pioche<TrackingCard>(Arrays.asList(acharnement));
assertEquals(response.getCards(),game.getTrackingCardPioche().getCards());
}
@Test
void testGetSurvivalCardPioche_true() {
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);
game.getSurvivalCardPioche().getCards().clear();
game.getSurvivalCardPioche().getCards().add(adrenaline);
Pioche<SurvivalCard> response = new Pioche<SurvivalCard>(Arrays.asList(adrenaline));
assertEquals(response.getCards(),game.getSurvivalCardPioche().getCards());
}
@Test
void testPowerScenario_false() throws TException {
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);
game.getCreature().getTrackingCardHand().clear();
game.getCreature().getTrackingCardHand().addAll(Arrays.asList(acharnement, mutation,virus));
PowerModifier powerModifier = new PowerModifier(1,playableTrackingCard,2);
assertEquals(Phase.PREPHASE_1,game.getState());
game.addPowerForNextRound(powerModifier);
//Start phase 1
game.startNextPhase();
//Start postphase 1
game.startNextPhase();
//Start prephase 2
game.startNextPhase();
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), acharnement));
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), mutation));
game.creaturePlayTrackingCard(game.getCreature(),acharnement);
assertFalse(game.creatureCanPlayThisTrackingCards(game.getCreature(), mutation));
//Start Phase 2
game.startNextPhase();
//Start Post phase 2
game.startNextPhase();
assertEquals(Phase.POSTPHASE_2,game.getState());
//Start Pre Phase 3
game.startNextPhase();
//Start Phase 3
game.startNextPhase();
//Start Post Phase 3
game.startNextPhase();
assertEquals(Phase.POSTPHASE_3,game.getState());
//Start Pre Phase 4
game.startNextPhase();
//Start Phase 4
game.startNextPhase();
//Start Post Phase 4
game.startNextPhase();
assertFalse(game.isFinish());
//Start Pre Phase 1
game.startNextPhase();
assertEquals(Phase.PREPHASE_1,game.getState());
//Start Phase 1
game.startNextPhase();
//Start Post Phase 1
game.startNextPhase();
//Start Pre Phase 2
game.startNextPhase();
assertEquals(Phase.PREPHASE_2,game.getState());
assertFalse(game.creatureCanPlayThisTrackingCards(game.getCreature(), acharnement));
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), mutation));
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), virus));
game.creaturePlayTrackingCard(game.getCreature(),virus);
assertFalse(game.creatureCanPlayThisTrackingCards(game.getCreature(), acharnement));
assertFalse(game.creatureCanPlayThisTrackingCards(game.getCreature(), virus));
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), mutation));
game.creaturePlayTrackingCard(game.getCreature(),mutation);
// assertFalse(game.creatureCanPlayThisTrackingCards(game.getCreature(), Arrays.asList(acharnement, mutation)));
}
@Test
void testGameScenario() throws TException {
Room room = mock(Room.class);
......
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