Commit 8df229a8 authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files

Add the first tests of SurvivalCards power

parent fe708122
...@@ -52,13 +52,37 @@ public class DatabaseStub implements NotAloneDatabase { ...@@ -52,13 +52,37 @@ public class DatabaseStub implements NotAloneDatabase {
private void initializeSurvivalCardMap(){ private void initializeSurvivalCardMap(){
survivalCardMap = new HashMap<>(); survivalCardMap = new HashMap<>();
survivalCardMap.put("ADRENALINE", new SurvivalCard(CardName.ADRENALINE,"Adrénaline", "Lorem ipsum", Phase.PHASE_1)); survivalCardMap.put("ADRENALINE", new SurvivalCard(CardName.ADRENALINE,"Adrénaline", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("ALERTE", new SurvivalCard(CardName.ALERTE,"Alerte", "Lorem ipsum", Phase.PHASE_1)); survivalCardMap.put("ALERTE", new SurvivalCard(CardName.ALERTE,"Alerte", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("AMPLIFICATEUR", new SurvivalCard(CardName.AMPLIFICATEUR,"Amplificateur", "Lorem ipsum", Phase.PHASE_1)); survivalCardMap.put("AMPLIFICATEUR", new SurvivalCard(CardName.AMPLIFICATEUR,"Amplificateur", "Lorem ipsum", Phase.PREPHASE_4));
survivalCardMap.put("BROUILLAGE", new SurvivalCard(CardName.BROUILLAGE,"Brouillage", "Lorem ipsum", Phase.PHASE_1)); survivalCardMap.put("BROUILLAGE", new SurvivalCard(CardName.BROUILLAGE,"Brouillage", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("CAVALE", new SurvivalCard(CardName.CAVALE,"Cavale", "Lorem ipsum", Phase.PHASE_1)); survivalCardMap.put("CAVALE", new SurvivalCard(CardName.CAVALE,"Cavale", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("DETECTEUR", new SurvivalCard(CardName.DETECTEUR,"Détecteur", "Lorem ipsum", Phase.PHASE_1)); survivalCardMap.put("DETECTEUR", new SurvivalCard(CardName.DETECTEUR,"Détecteur", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("DRONE", new SurvivalCard(CardName.DRONE,"Drone", "Lorem ipsum", Phase.PHASE_1)); survivalCardMap.put("DRONE", new SurvivalCard(CardName.DRONE,"Drone", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("ENTRAVE", new SurvivalCard(CardName.ENTRAVE,"Entrave", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("EQUIPEMENT", new SurvivalCard(CardName.EQUIPEMENT,"Equipement", "Lorem ipsum", Phase.PREPHASE_4));
survivalCardMap.put("ESQUIVE", new SurvivalCard(CardName.ESQUIVE,"Esquive", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("FAUSSE_PISTE", new SurvivalCard(CardName.FAUSSE_PISTE,"Fausse-piste", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("HOLOGRAMME", new SurvivalCard(CardName.HOLOGRAMME,"Hologramme", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("LEURRE", new SurvivalCard(CardName.LEURRE,"Leurre", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("MIMETISME", new SurvivalCard(CardName.MIMETISME,"Mimétisme", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("NAVETTE", new SurvivalCard(CardName.NAVETTE,"Navette", "Lorem ipsum", Phase.PREPHASE_4));
survivalCardMap.put("PLANQUES", new SurvivalCard(CardName.PLANQUES,"Planques", "Lorem ipsum", Phase.PREPHASE_4));
survivalCardMap.put("PORTAIL_SURVIVAL", new SurvivalCard(CardName.PORTAIL_SURVIVAL,"Portail", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("RALLIEMENT", new SurvivalCard(CardName.RALLIEMENT,"Ralliement", "Lorem ipsum", Phase.PREPHASE_4));
survivalCardMap.put("REFUGE", new SurvivalCard(CardName.REFUGE,"Refuge", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("REGENERATION", new SurvivalCard(CardName.REGENERATION,"Régénération", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("RESISTANCE", new SurvivalCard(CardName.RESISTANCE,"Résistance", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("RETRAITE", new SurvivalCard(CardName.RETRAITE,"Retraite", "Lorem ipsum", Phase.PREPHASE_3));
survivalCardMap.put("RIPOSTE", new SurvivalCard(CardName.RIPOSTE,"Riposte", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("SACRIFICE", new SurvivalCard(CardName.SACRIFICE,"Sacrifice", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("SECOND_SOUFFLE", new SurvivalCard(CardName.SECOND_SOUFFLE,"Second souffle", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("SIXIEME_SENS", new SurvivalCard(CardName.SIXIEME_SENS,"Sixième sens", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("SYSTEME_D", new SurvivalCard(CardName.SYSTEME_D,"Système D", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("TENACITE", new SurvivalCard(CardName.TENACITE,"Ténacité", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("VACCIN", new SurvivalCard(CardName.VACCIN,"Vaccin", "Lorem ipsum", Phase.PREPHASE_1));
survivalCardMap.put("VOLTE_FACE", new SurvivalCard(CardName.VOLTE_FACE,"Volte-face", "Lorem ipsum", Phase.PREPHASE_4));
survivalCardMap.put("VORTEX", new SurvivalCard(CardName.VORTEX,"Vortex", "Lorem ipsum", Phase.PREPHASE_2));
} }
private void initializeTrackingCardMap(){ private void initializeTrackingCardMap(){
......
...@@ -363,66 +363,97 @@ public class PowerApplicator { ...@@ -363,66 +363,97 @@ public class PowerApplicator {
public static void applySurvivalCardPower(int idPlayer, Game game, CardName cardName) { public static void applySurvivalCardPower(int idPlayer, Game game, CardName cardName) {
switch (cardName) { switch (cardName) {
case ADRENALINE: case ADRENALINE:
applySurvivalAdrenaline(idPlayer, game);
break; break;
case ALERTE: case ALERTE:
applySurvivalAlerte(idPlayer, game);
break; break;
case AMPLIFICATEUR: case AMPLIFICATEUR:
applySurvivalAmplificateur(idPlayer, game);
break; break;
case BROUILLAGE: case BROUILLAGE:
applySurvivalBrouillage(idPlayer, game);
break; break;
case CAVALE: case CAVALE:
applySurvivalCavale(idPlayer, game);
break; break;
case DETECTEUR: case DETECTEUR:
applySurvivalDetecteur(idPlayer, game);
break; break;
case DRONE: case DRONE:
applySurvivalDrone(idPlayer, game);
break; break;
case ENTRAVE: case ENTRAVE:
applySurvivalEntrave(idPlayer, game);
break; break;
case EQUIPEMENT: case EQUIPEMENT:
applySurvivalEquipement(idPlayer, game);
break; break;
case ESQUIVE: case ESQUIVE:
applySurvivalEsquive(idPlayer, game);
break; break;
case FAUSSE_PISTE: case FAUSSE_PISTE:
applySurvivalFaussePiste(idPlayer, game);
break; break;
case HOLOGRAMME: case HOLOGRAMME:
applySurvivalHologramme(idPlayer, game);
break; break;
case LEURRE: case LEURRE:
applySurvivalLeurre(idPlayer, game);
break; break;
case MIMETISME: case MIMETISME:
applySurvivalMimetisme(idPlayer, game);
break; break;
case NAVETTE: case NAVETTE:
applySurvivalNavette(idPlayer, game);
break; break;
case PLANQUES: case PLANQUES:
applySurvivalPlanques(idPlayer, game);
break; break;
case PORTAIL_SURVIVAL: case PORTAIL_SURVIVAL:
applySurvivalPortail(idPlayer, game);
break; break;
case RALLIEMENT: case RALLIEMENT:
applySurvivalRalliement(idPlayer, game);
break; break;
case REFUGE: case REFUGE:
applySurvivalRefuge(idPlayer, game);
break; break;
case REGENERATION: case REGENERATION:
applySurvivalRegeneration(idPlayer, game);
break; break;
case RESISTANCE: case RESISTANCE:
applySurvivalResistance(idPlayer, game);
break; break;
case RETRAITE: case RETRAITE:
applySurvivalRetraite(idPlayer, game);
break; break;
case RIPOSTE: case RIPOSTE:
applySurvivalRiposte(idPlayer, game);
break; break;
case SACRIFICE: case SACRIFICE:
applySurvivalSacrifice(idPlayer, game);
break; break;
case SECOND_SOUFFLE: case SECOND_SOUFFLE:
applySurvivalSecondSouffle(idPlayer, game);
break; break;
case SIXIEME_SENS: case SIXIEME_SENS:
applySurvivalSixiemeSens(idPlayer, game);
break; break;
case SYSTEME_D: case SYSTEME_D:
applySurvivalSystemeD(idPlayer, game);
break; break;
case TENACITE: case TENACITE:
applySurvivalTenacite(idPlayer, game);
break; break;
case VACCIN: case VACCIN:
applySurvivalVaccin(idPlayer, game);
break; break;
case VOLTE_FACE: case VOLTE_FACE:
applySurvivalVolteFace(idPlayer, game);
break; break;
case VORTEX: case VORTEX:
applySurvivalVortex(idPlayer, game);
break; break;
default: default:
throw new IllegalArgumentException(cardName + " is not a SurvivalCard name"); throw new IllegalArgumentException(cardName + " is not a SurvivalCard name");
...@@ -1438,10 +1469,22 @@ public class PowerApplicator { ...@@ -1438,10 +1469,22 @@ public class PowerApplicator {
} }
} }
private static void applySurvivalSystemeD(int idPlayer, Game game) { private static void applySurvivalSixiemeSens(int idPlayer, Game game) {
takeBackCardsFromDefausse(idPlayer, game, 2); takeBackCardsFromDefausse(idPlayer, game, 2);
} }
private static void applySurvivalSystemeD(int idPlayer, Game game) {
Planet planet = game.getPlanet();
if(!planet.planetPawnIsActive()) {
planet.forceMovePlanetPawn();
}
}
private static void applySurvivalTenacite(int idPlayer, Game game) {
Traque traque = (Traque) game.getPlayer(idPlayer);
traque.getRights().setNumberOfAdditionalCardsTakeBackPerPawnWillingnessLostWithResist(1);
}
private static void applySurvivalVaccin(int idPlayer, Game game) { private static void applySurvivalVaccin(int idPlayer, Game game) {
game.getBoard().moveBackCreature(); game.getBoard().moveBackCreature();
} }
......
...@@ -1731,7 +1731,6 @@ class PowerApplicatorTest { ...@@ -1731,7 +1731,6 @@ class PowerApplicatorTest {
void testApplyPlayerCard_cataclysme() throws TException { void testApplyPlayerCard_cataclysme() throws TException {
Game game = new Game(2, 1, planet, board, room, gameClientHandler); Game game = new Game(2, 1, planet, board, room, gameClientHandler);
TAction choosePlace = new TAction(CHOOSE_PLACE.toString(), TAction choosePlace = new TAction(CHOOSE_PLACE.toString(),
Collections.singletonList(new TPair(TPairType.PLACE.toString(), Place.PLACE_ONE.toString()))); Collections.singletonList(new TPair(TPairType.PLACE.toString(), Place.PLACE_ONE.toString())));
...@@ -2960,4 +2959,179 @@ class PowerApplicatorTest { ...@@ -2960,4 +2959,179 @@ class PowerApplicatorTest {
assertTrue(traque2.getDefausse().contains(antre)); assertTrue(traque2.getDefausse().contains(antre));
assertTrue(traque3.getDefausse().contains(antre)); assertTrue(traque3.getDefausse().contains(antre));
} }
@Test
void testApplyPlayerCard_adrenaline() throws TException {
Game game = new Game(4, 1, planet, board, room, gameClientHandler);
Traque traque = (Traque) game.getPlayer(2);
traque.subWillingness(1);
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, ADRENALINE);
assertEquals(3, traque.getNumberWillingness());
}
@Test
void testApplyPlayerCard_alerte() throws TException {
Game game = new Game(4, 1, planet, board, room, gameClientHandler);
Traque traque = (Traque) game.getPlayer(2);
TAction choosePlace = new TAction(CHOOSE_PLACE.toString(),
Collections.singletonList(new TPair(TPairType.PLACE.toString(), Place.PLACE_ONE.toString())));
when(gameClientHandler.askAction(any(TAskAction.class)))
.thenReturn(choosePlace);
PlacedJeton placedJeton = new PlacedJeton(JetonSymbol.CREATURE, Place.PLACE_ONE);
planet.placeJeton(placedJeton);
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, ALERTE);
PowerApplicator.resolvePlace(traque.getInGameId(), antre, game);
assertEquals(3, traque.getNumberWillingness());
}
@Test
void testApplyPlayerCard_amplificateur() {
Game game = new Game(4, 1, planet, board, room, gameClientHandler);
Traque traque = (Traque) game.getPlayer(2);
planet.forceMovePlanetPawn();
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, AMPLIFICATEUR);
assertTrue(planet.planetPawnIsActive());
}
@Test
void testApplyPlayerCard_amplificateurWithExtension() {
Game game = new Game(4, 1, planetExtension, board, room, gameClientHandler);
Traque traque = (Traque) game.getPlayer(2);
planet.forceMovePlanetPawn();
planet.forceMovePlanetPawn();
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, AMPLIFICATEUR);
assertTrue(planet.planetPawnIsActive());
}
@Test
void testApplyPlayerCard_brouillage() {
Game game = new Game(4, 1, planet, board, room, gameClientHandler);
Traque traque = (Traque) game.getPlayer(2);
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, BROUILLAGE);
assertTrue(game.getGameRoundVariables().defaussePlaceCardsAreHidden());
}
@Test
void testApplyPlayerCard_cavale() throws TException {
Game game = new Game(2, 1, planet, board, room, gameClientHandler);
TAction chooseCard = new TAction(CHOOSE_CARD.toString(),
Collections.singletonList(new TPair(TPairType.CARD.toString(), PLAGE.toString())));
when(gameClientHandler.askAction(any(TAskAction.class)))
.thenReturn(chooseCard)
.thenReturn(chooseFirstPower);
planet.forceMovePlanetPawn();
Traque traque = (Traque) game.getPlayer(2);
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, CAVALE);
//Start phase 1
game.startNextPhase();
assertTrue(game.playerPlayCard(traque.getInGameId(), Arrays.asList(plage, jungle, riviere)).state);
game.managePhase3();
game.managePhase4();
assertTrue(traque.getDefausse().containsAll(Arrays.asList(jungle, riviere)));
assertTrue(traque.getPlaceCards().containsAll(Arrays.asList(plage, antre, rover)));
assertTrue(planet.planetPawnIsActive());
}
@Test
void testApplyPlayerCard_detecteur() throws TException {
Game game = new Game(2, 1, planet, board, room, gameClientHandler);
when(gameClientHandler.askAction(any(TAskAction.class)))
.thenReturn(chooseFirstPower);
planet.forceMovePlanetPawn();
PlacedJeton placedJeton = new PlacedJeton(JetonSymbol.ARTEMIA, Place.PLACE_FOUR);
planet.placeJeton(placedJeton);
Traque traque = (Traque) game.getPlayer(2);
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, DETECTEUR);
PowerApplicator.resolvePlace(traque.getInGameId(), plage, game);
assertTrue(traque.getDefausse().isEmpty());
assertTrue(planet.planetPawnIsActive());
}
@Test
void testApplyPlayerCard_drone() throws TException {
Game game = new Game(2, 1, planet, board, room, gameClientHandler);
TAction chooseCard1 = new TAction(CHOOSE_CARD.toString(),
Collections.singletonList(new TPair(TPairType.CARD.toString(), ARTEFACT.toString())));
TAction chooseCard2 = new TAction(CHOOSE_CARD.toString(),
Collections.singletonList(new TPair(TPairType.CARD.toString(), MARAIS.toString())));
when(gameClientHandler.askAction(any(TAskAction.class)))
.thenReturn(chooseCard1)
.thenReturn(chooseCard2);
planet.forceMovePlanetPawn();
Traque traque = (Traque) game.getPlayer(2);
traque.addPlaceCard(artefact);
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, DRONE);
PowerApplicator.resolvePlace(traque.getInGameId(), plage, game);
assertTrue(traque.getDefausse().isEmpty());
assertFalse(planet.planetPawnIsActive());
assertTrue(traque.getPlaceCards().contains(marais));
}
@Test
void testApplyPlayerCard_dronePlaceNotRevealed() throws TException {
Game game = new Game(2, 1, planetExtension, board, room, gameClientHandler);
List<PlaceCard> placeCards = planetExtension.getPlaceCardsInInterval(6,10);
PlaceCard revealed = placeCards.get(0);
TAction chooseCard1 = new TAction(CHOOSE_CARD.toString(),
Collections.singletonList(new TPair(TPairType.CARD.toString(), placeCards.get(0).getCardName().toString())));
TAction chooseCard2 = new TAction(CHOOSE_CARD.toString(),
Collections.singletonList(new TPair(TPairType.CARD.toString(), revealed.getCardName().toString())));
when(gameClientHandler.askAction(any(TAskAction.class)))
.thenReturn(chooseCard1)
.thenReturn(chooseCard2);
planetExtension.revealPlace(revealed);
Traque traque = (Traque) game.getPlayer(2);
PowerApplicator.applySurvivalCardPower(traque.getInGameId(), game, DRONE);
PowerApplicator.resolvePlace(traque.getInGameId(), plage, game);
assertTrue(traque.getDefausse().isEmpty());
assertFalse(planet.planetPawnIsActive());
assertTrue(traque.getPlaceCards().contains(revealed));
}
} }
\ No newline at end of file
Supports Markdown
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