Commit 2eed842e authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files

Add several tests for TrackingCard powers ; Correction of some bugs

parent 5d239330
......@@ -7,6 +7,8 @@ import fr.univnantes.alma.server.game.item.card.CardName;
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;
import fr.univnantes.alma.server.game.item.jeton.JetonArtemia;
import fr.univnantes.alma.server.game.item.jeton.JetonSymbol;
import java.util.*;
......@@ -61,12 +63,42 @@ public class DatabaseStub implements NotAloneDatabase {
private void initializeTrackingCardMap(){
trackingCardMap = new HashMap<>();
trackingCardMap.put("ACHARNEMENT", new TrackingCard(CardName.ACHARNEMENT, "Acharnement", "Lorem ipsum", Phase.PHASE_1));
trackingCardMap.put("ANGOISSE", new TrackingCard(CardName.ANGOISSE, "Angoisse", "Lorem ipsum", Phase.PHASE_1));
trackingCardMap.put("ANTICIPATION", new TrackingCard(CardName.ANTICIPATION, "Anticipation", "Lorem ipsum", Phase.PHASE_1));
trackingCardMap.put("CATACLYSME", new TrackingCard(CardName.CATACLYSME, "Cataclysme", "Lorem ipsum", Phase.PHASE_1));
trackingCardMap.put("CHAMP_DE_FORCE", new TrackingCard(CardName.CHAMP_DE_FORCE, "Champ de force", "Lorem ipsum", Phase.PHASE_1));
trackingCardMap.put("CLONE", new TrackingCard(CardName.CLONE, "Clone", "Lorem ipsum", Phase.PHASE_1));
trackingCardMap.put("ACHARNEMENT", new TrackingCard(CardName.ACHARNEMENT, "Acharnement", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("ANGOISSE", new TrackingCard(CardName.ANGOISSE, "Angoisse", "Lorem ipsum", Phase.PREPHASE_1, JetonSymbol.ARTEMIA));
trackingCardMap.put("ANTICIPATION", new TrackingCard(CardName.ANTICIPATION, "Anticipation", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("CATACLYSME", new TrackingCard(CardName.CATACLYSME, "Cataclysme", "Lorem ipsum", Phase.PREPHASE_3));
trackingCardMap.put("CHAMP_DE_FORCE", new TrackingCard(CardName.CHAMP_DE_FORCE, "Champ de force", "Lorem ipsum", Phase.PREPHASE_1, JetonSymbol.CIBLE));
trackingCardMap.put("CLONE", new TrackingCard(CardName.CLONE, "Clone", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.CIBLE));
trackingCardMap.put("DEPLOIEMENT", new TrackingCard(CardName.DEPLOIEMENT, "Déploiement", "Lorem ipsum", Phase.PREPHASE_3));
trackingCardMap.put("DESESPOIR", new TrackingCard(CardName.DESESPOIR, "Désespoir", "Lorem ipsum", Phase.PREPHASE_1, JetonSymbol.ARTEMIA));
trackingCardMap.put("DETOUR", new TrackingCard(CardName.DETOUR, "Détour", "Lorem ipsum", Phase.PREPHASE_3));
trackingCardMap.put("DOMINATION", new TrackingCard(CardName.DOMINATION, "Domination", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("EFFROI", new TrackingCard(CardName.EFFROI, "Effroi", "Lorem ipsum", Phase.POSTPHASE_1));
trackingCardMap.put("EMPRISE", new TrackingCard(CardName.EMPRISE, "Emprise", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("EPIDEMIE", new TrackingCard(CardName.EPIDEMIE, "Epidémie", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("FAILLE_TEMPORELLE", new TrackingCard(CardName.FAILLE_TEMPORELLE, "Faille temporelle", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("FLASHBACK", new TrackingCard(CardName.FLASHBACK, "Flashback", "Lorem ipsum", Phase.PREPHASE_1));
trackingCardMap.put("GARGANTUA", new TrackingCard(CardName.GARGANTUA, "Gargantua", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("HARCELEMENT", new TrackingCard(CardName.HARCELEMENT, "Harcèlements", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("HURLEMENTS", new TrackingCard(CardName.HURLEMENTS, "Hurlements", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.CIBLE));
trackingCardMap.put("INERTIE", new TrackingCard(CardName.INERTIE, "Inertie", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.CIBLE));
trackingCardMap.put("INTERFERENCES", new TrackingCard(CardName.INTERFERENCES, "Interférences", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("INTUITION", new TrackingCard(CardName.INTUITION, "Intuition", "Lorem ipsum", Phase.PREPHASE_1));
trackingCardMap.put("MAGNETISME", new TrackingCard(CardName.MAGNETISME, "Magnétisme", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.CIBLE));
trackingCardMap.put("MIRAGE", new TrackingCard(CardName.MIRAGE, "Mirage", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.CIBLE));
trackingCardMap.put("MUTATION", new TrackingCard(CardName.MUTATION, "Mutation", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.ARTEMIA));
trackingCardMap.put("PSYCHOSE", new TrackingCard(CardName.PSYCHOSE, "Psychose", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.ARTEMIA));
trackingCardMap.put("REMINISCENCE", new TrackingCard(CardName.REMINISCENCE, "Réminiscence", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.ARTEMIA));
trackingCardMap.put("REPERAGE", new TrackingCard(CardName.REPERAGE, "Repérage", "Lorem ipsum", Phase.PREPHASE_4));
trackingCardMap.put("SABLES_MOUVANTS", new TrackingCard(CardName.SABLES_MOUVANTS, "Sables mouvants", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.CIBLE));
trackingCardMap.put("SOIF_DE_SANG", new TrackingCard(CardName.SOIF_DE_SANG, "Soif de sang", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.CIBLE));
trackingCardMap.put("STASE", new TrackingCard(CardName.STASE, "Stase", "Lorem ipsum", Phase.PREPHASE_4));
trackingCardMap.put("TELEPATHIE", new TrackingCard(CardName.TELEPATHIE, "Télépathie", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.ARTEMIA));
trackingCardMap.put("TORNADE", new TrackingCard(CardName.TORNADE, "Tornade", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.ARTEMIA));
trackingCardMap.put("TOXINE", new TrackingCard(CardName.TOXINE, "Toxine", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.CIBLE));
trackingCardMap.put("UBIQUITE", new TrackingCard(CardName.UBIQUITE, "Ubiquité", "Lorem ipsum", Phase.PREPHASE_2, Arrays.asList(JetonSymbol.CIBLE, JetonSymbol.ARTEMIA)));
trackingCardMap.put("VIRUS", new TrackingCard(CardName.VIRUS, "Virus", "Lorem ipsum", Phase.PREPHASE_2, JetonSymbol.ARTEMIA));
trackingCardMap.put("ZONE_INTERDITE", new TrackingCard(CardName.ZONE_INTERDITE, "Zone interdite", "Lorem ipsum", Phase.PREPHASE_2));
}
......
......@@ -7,7 +7,6 @@ import fr.univnantes.alma.server.game.item.Reserve;
import fr.univnantes.alma.server.game.item.action.*;
import fr.univnantes.alma.server.game.item.board.Board;
import fr.univnantes.alma.server.game.item.card.*;
import fr.univnantes.alma.server.game.item.jeton.JetonCible;
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;
......@@ -275,10 +274,6 @@ public class Game implements GameInterface {
return gameRoundVariables.isJetonArtemiaIsActive();
}
public int getNumberTraqueCaughtByJetonCreature() {
return gameRoundVariables.getNumberTraqueCaughtByJetonCreature();
}
public int getNumberWillingnessDecrementByJetonCreature() {
return gameRoundVariables.getNumberWillingnessDecrementByJetonCreature();
}
......@@ -311,10 +306,6 @@ public class Game implements GameInterface {
gameRoundVariables.enableJetonArtemia();
}
public void addTraqueCaughtByJetonCreature() {
gameRoundVariables.addTraqueCaughtByJetonCreature();
}
public void setNumberWillingnessDecrementByJetonCreature(int number) {
gameRoundVariables.setNumberWillingnessDecrementByJetonCreature(number);
}
......@@ -499,11 +490,19 @@ public class Game implements GameInterface {
public Response playerPlaceJeton(int playerId, PlacedJeton placedJeton) {
Response response;
Player player = playersMap.get(playerId);
if(player.teamEqualsTo(TRAQUE) || ! state.equals(Phase.PHASE_2)){
response = new Response(false, "Only the Creature can played jeton and only in the PHASE_2");
if(player.teamEqualsTo(TRAQUE)){
response = new Response(false, "Only the Creature can played jeton");
}
else if(! state.equals(Phase.PHASE_2)) {
if(gameRoundVariables.isJetonCibleBlockPlace() && placedJeton.getJeton().getType().equals(CIBLE)) {
response = creaturePlaceAJeton(creature, placedJeton);
}
else {
response = new Response(false, "You can play jeton only in Phase 2");
}
}
else if(gameRoundVariables.refugeIsActive() && placedJeton.getJeton().getType().equals(CIBLE)) {
return new Response(false, "Can't play JetonCible when Refuge is active");
response = new Response(false, "Can't play JetonCible when Refuge is active");
}
else{
response = creaturePlaceAJeton(creature, placedJeton);
......@@ -515,8 +514,8 @@ public class Game implements GameInterface {
public Response playerPlaceJeton(int playerId, List<PlacedJeton> jetons) {
Player player = playersMap.get(playerId);
Response response;
if(player.teamEqualsTo(TRAQUE) || ! state.equals(Phase.PHASE_2)){
response = new Response(false, "Only the Creature can played jeton and only in the PHASE_2");
if(player.teamEqualsTo(TRAQUE)){
response = new Response(false, "Only the Creature can played jetons");
}
else {
boolean canPlaceAllJetons = true;
......@@ -538,7 +537,10 @@ public class Game implements GameInterface {
public Response playerResist(int playerId, int number) {
Player player = playersMap.get(playerId);
Response response;
if(player.teamEqualsTo(CREATURE)) {
if(! gameRoundVariables.traqueCanResist()) {
response = new Response(false, "You can't resist for this round");
}
else if(player.teamEqualsTo(CREATURE)) {
response = new Response(false, "Only traque can resist");
}
else{
......@@ -549,13 +551,16 @@ public class Game implements GameInterface {
else if(! state.equals(Phase.PHASE_1)){
response = new Response(false, "Resist is only possible in PHASE_1");
}
else if(traque.getNumberWillingness() > number && traque.canResist()) {
else if(traque.getNumberWillingness() >= number && traque.canResist()) {
traque.subWillingness(number);
int cardsPerWillingness = 2 + traque.getNumberOfAdditionalCardsTakeBackPerPawnWillingnessLostWithResist();
int numberCard = Math.min(cardsPerWillingness * number, traque.defausseSize());
if(numberCard > 0) {
choosePlaceCardsAction(playerId, numberCard, traque.getDefausse());
}
traque.getRights().setCanGiveUp(false);
traque.getRights().setCanResist(false);
gameRoundVariables.addPlayersWhoHaveResist(traque.getInGameId());
response = new Response(true, "");
}
else{
......@@ -708,11 +713,10 @@ public class Game implements GameInterface {
* @return A Response
*/
public Response creaturePlayTrackingCard(Creature creature, TrackingCard trackingCard) {
if(gameRoundVariables.refugeIsActive() && trackingCard.getJetons().contains(new JetonCible())) {
return new Response(false, "Unable to play this card when Refuge is active");
}
else if(creatureCanPlayThisTrackingCards(creature, trackingCard) &&
creature.playTrackingCard(trackingCard)) {
boolean canPlay = creatureCanPlayThisTrackingCards(creature, trackingCard);
if(canPlay){
if(creature.getTrackingCardToApplied().contains(trackingCard)
|| creature.playTrackingCard(trackingCard)) {
applyCreaturePlayTrackingCard(creature, trackingCard);
return new Response(true, "");
}
......@@ -720,6 +724,10 @@ public class Game implements GameInterface {
return new Response(false, "Unable to play this card");
}
}
else{
return new Response(false, "Unable to play this card");
}
}
/**
* The creature play tracking cards
......@@ -728,10 +736,10 @@ public class Game implements GameInterface {
* @return A Response
*/
public Response creaturePlayTrackingCard(Creature creature, List<TrackingCard> trackingCards) {
if( creatureCanPlayThisTrackingCards(creature, trackingCards) &&
creature.playTrackingCard(trackingCards)) {
boolean canPlay = creatureCanPlayThisTrackingCards(creature, trackingCards);
if(canPlay) {
for(TrackingCard trackingCard : trackingCards){
applyCreaturePlayTrackingCard(creature, trackingCard);
creatureCanPlayThisTrackingCards(creature, trackingCard);
}
return new Response(true, "");
}
......@@ -746,59 +754,53 @@ public class Game implements GameInterface {
* @param trackingCard The card
*/
private void applyCreaturePlayTrackingCard(Creature creature, TrackingCard trackingCard) {
if(playerCardsPlayedPhaseAndAppliedPhaseDifferent(trackingCard)) {
if(state.equals(trackingCard.getPhase())){
creature.playTrackingCard(trackingCard);
creature.addTrackingCardToApplied(trackingCard);
}
else{
applyPlayerCard(creature.getInGameId(), trackingCard, this);
Phase toApplied = trackingCard.getPhaseToApply();
if(toApplied.equals(state)) {
creature.removeTrackingCardToApplied(trackingCard);
trackingCardPioche.throwAway(trackingCard);
}
}
else{
applyPlayerCard(creature.getInGameId(), trackingCard, this);
creature.playTrackingCard(trackingCard);
trackingCardPioche.throwAway(trackingCard);
}
else {
creature.addTrackingCardToApplied(trackingCard);
}
}
public boolean creatureCanPlayThisTrackingCards(Creature creature, TrackingCard trackingCard) {
if(! gameRoundVariables.canPLayTrackingCard()) {
if(gameRoundVariables.refugeIsActive() && trackingCard.containsSymbol(CIBLE)) {
return false;
}
//if the card doesn't apply himself in the same phase that it's played
if(playerCardsPlayedPhaseAndAppliedPhaseDifferent(trackingCard)) {
//true if the card can to be played or can to be applied
return (creature.getHand().trackingCardPlayedSize() < creature.getMaxTrackingCardPlayable() && state.equals(trackingCard.getPhase()))
|| (state.equals(trackingCard.getPhaseToApply()) && creature.getTrackingCardsPlayed().contains(trackingCard));
if(! gameRoundVariables.canPlayTrackingCard()) {
return false;
}
else if(creature.getTrackingCardToApplied().contains(trackingCard) && state.equals(trackingCard.getPhaseToApply())) {
return true;
}
else{
//true if the card can to be played
return creature.getHand().trackingCardPlayedSize() < creature.getMaxTrackingCardPlayable() && state.equals(trackingCard.getPhase());
boolean canPlay = creature.getHand().trackingCardPlayedSize() < creature.getMaxTrackingCardPlayable()
&& state.equals(trackingCard.getPhase());
return canPlay && creature.getTrackingCardHand().contains(trackingCard);
}
}
public boolean creatureCanPlayThisTrackingCards(Creature creature, List<TrackingCard> trackingCards) {
if(! gameRoundVariables.canPLayTrackingCard()) {
if(! gameRoundVariables.canPlayTrackingCard()) {
return false;
}
int numberCardPlayed = 0;
//Count the number of played cards
for(TrackingCard trackingCard : trackingCards) {
if(! playerCardsPlayedPhaseAndAppliedPhaseDifferent(trackingCard)) {
++numberCardPlayed;
}
Iterator<TrackingCard> iterator = trackingCards.iterator();
boolean canPlay = true;
List<Card> toPlay = new ArrayList<>();
TrackingCard trackingCard;
while (canPlay && iterator.hasNext()) {
trackingCard = iterator.next();
if(! creature.getTrackingCardToApplied().contains(trackingCard)) {
toPlay.add(trackingCard);
}
if(creature.getHand().trackingCardPlayedSize() + numberCardPlayed > creature.getMaxTrackingCardPlayable()){
return false;
if(! creatureCanPlayThisTrackingCards(creature, trackingCard)) {
canPlay = false;
}
boolean aux = true;
for(TrackingCard trackingCard : trackingCards) {
aux = aux && creatureCanPlayThisTrackingCards(creature, trackingCard);
}
return aux;
canPlay = canPlay && creature.getHand().trackingCardPlayedSize() + toPlay.size() > creature.getMaxTrackingCardPlayable();
return canPlay && creature.getTrackingCardHand().containsAll(toPlay);
}
/**
......@@ -899,13 +901,21 @@ public class Game implements GameInterface {
* @return A Response
*/
public Response traquePlayPlaceCard(Traque traque, PlaceCard placeCard) {
if(traque.placeCardPlayedSize() < traque.getMaxPlacesCardChoosable() &&
traque.playPlaceCard(placeCard) && planet.isRevealedPlace(placeCard)) {
return new Response(true, "");
Response response;
if(!planet.isRevealedPlace(placeCard)) {
response = new Response(false, "The place must be revealed");
}
else if(planet.isBlockedPlace(placeCard) ||
(gameRoundVariables.isJetonCibleBlockPlace() && planet.isJetonSymbolOnPlaceCard(CIBLE, placeCard))) {
response = new Response(false, "The place is blocked");
}
else if(traque.placeCardPlayedSize() < traque.getMaxPlacesCardChoosable() && traque.playPlaceCard(placeCard)) {
response = new Response(true, "");
}
else{
return new Response(false, "Unable to play this card");
response = new Response(false, "Unable to play this card");
}
return response;
}
/**
......@@ -949,6 +959,18 @@ public class Game implements GameInterface {
JetonSymbol type = placedJeton.getJeton().getType();
if(placedJeton.getPlaces().size() > 1) {
JetonSymbol symbol = placedJeton.getJeton().getType();
if(symbol.equals(JetonSymbol.CIBLE) && !gameRoundVariables.jetonCibleCanBeOnTwoAdjacentPlaces()) {
return new Response(false, "JetonCible can't be place on two adjacent places");
}
else if(symbol.equals(ARTEMIA) && !gameRoundVariables.jetonArtemiaCanBeOnTwoAdjacentPlaces()) {
return new Response(false, "JetonArtemia can't be place on two adjacent places");
}
else if(symbol.equals(JetonSymbol.CREATURE) && !gameRoundVariables.jetonCreatureCanBeOnTwoAdjacentPlaces()) {
return new Response(false, "JetonCreature can't be place on two adjacent places");
}
}
if( (type.equals(CIBLE) && containsJetonCible)
|| (type.equals(ARTEMIA) && (containsJetonArtemia || board.isArtemiaSquare()))
|| type.equals(JetonSymbol.CREATURE)) {
......@@ -1070,7 +1092,7 @@ public class Game implements GameInterface {
|| gameRoundVariables.getPlayersWhoHavePlayVolteFace().contains(traque.getInGameId())) {
traque.takeBackPlayedPlaceCards();
}
else if(gameRoundVariables.ralliementIsActive() && gameRoundVariables.getPlayerWhoHasCaughtByCreature().contains(traque.getInGameId())) {
else if(gameRoundVariables.ralliementIsActive() && gameRoundVariables.getPlayersWhoHasCaughtByCreature().contains(traque.getInGameId())) {
List<PlaceCard> placeCardsWhereIsJetonCreature = planet.getPlaceCardsWhereJetonIs(JetonSymbol.CREATURE);
traque.takeBackPlaceCard(placeCardsWhereIsJetonCreature);
traque.throwAwayPlaceCard();
......@@ -1103,6 +1125,7 @@ public class Game implements GameInterface {
}
creature.reset();
applyNextRoundPowers();
gameRoundVariables.resetAfterNextRoundPowersApplication();
}
}
......@@ -1117,9 +1140,9 @@ public class Game implements GameInterface {
}
else if(power.getType().equals(PowerType.RECURRENT)) {
PowerRecurrent powerRecurrent = (PowerRecurrent) power;
powerRecurrent.apply(this);
if(powerRecurrent.conditionIsTrue(this)) {
newNextRoundPowers.add(power);
powerRecurrent.apply(this);
}
}
}
......@@ -1246,7 +1269,7 @@ public class Game implements GameInterface {
cardNames = ((ActionChooseCard) action).getCards();
cards = computeCardListFromCardNames(cardNames, cardsToChoose);
}
} while (cards.isEmpty());
} while (cards.isEmpty() || cards.size() > max);
return cards;
}
......@@ -1319,7 +1342,7 @@ public class Game implements GameInterface {
if(action.getActionType().equals(TARGET_PLAYER)) {
idTargetPlayer = ((ActionTargetPlayer) action).getIdPlayer();
}
} while(! playersIdList.contains(idTargetPlayer) && creature.getInGameId() == idTargetPlayer);
} while(! playersIdList.contains(idTargetPlayer) || creature.getInGameId() == idTargetPlayer);
return idTargetPlayer;
}
......
......@@ -16,7 +16,6 @@ public class GameRoundVariables {
//Modifiers
private int incrementScoreTraque;
private int numberTraqueCaughtByJetonCreature;
private int numberWillingnessDecrementByJetonCreature;
private int numberMaxPlaceCardsGetByPlacePower;
......@@ -31,8 +30,9 @@ public class GameRoundVariables {
//Player ids list
private List<Integer> playerWhoHaveLostAllWillingness;
private List<Integer> playerWhoHaveResist;
private List<Integer> playerCaughtByCreature;
private List<Integer> playersWhoHaveResist;
private List<Integer> playersCaughtByCreature;
private List<Integer> playersCaughtByCreatureOnNexus;
private List<Integer> playersWhoDodgeJetonArtemia;
private List<Integer> playersWhoDodgeJetonCreature;
private List<Integer> playersWhoDodgeJetonCible;
......@@ -68,6 +68,7 @@ public class GameRoundVariables {
public GameRoundVariables() {
this.numberPawnWillingnessOnBoard = 0;
this.playerWhoHaveLostAllWillingness = new ArrayList<>();
reset();
}
......@@ -78,7 +79,6 @@ public class GameRoundVariables {
//Modifiers
this.incrementScoreTraque = 1;
this.numberTraqueCaughtByJetonCreature = 0;
this.numberWillingnessDecrementByJetonCreature = 1;
this.numberMaxPlaceCardsGetByPlacePower = -1;
......@@ -91,9 +91,9 @@ public class GameRoundVariables {
this.targetByAlerte = null;
//Player ids list
this.playerWhoHaveLostAllWillingness = new ArrayList<>();
this.playerWhoHaveResist = new ArrayList<>();
this.playerCaughtByCreature = new ArrayList<>();
this.playersWhoHaveResist = new ArrayList<>();
this.playersCaughtByCreature = new ArrayList<>();
this.playersCaughtByCreatureOnNexus = new ArrayList<>();
this.playersWhoHavePlayCavale = new ArrayList<>();
this.playersWhoDodgeJetonArtemia = new ArrayList<>();
this.playersWhoHavePlayDrone = new ArrayList<>();
......@@ -129,6 +129,10 @@ public class GameRoundVariables {
this.refugeIsActive = false;
}
public void resetAfterNextRoundPowersApplication() {
this.playerWhoHaveLostAllWillingness = new ArrayList<>();
}
//Number methods
public void addPawnWillingnessOnBoard(int number) {
......@@ -174,14 +178,6 @@ public class GameRoundVariables {
this.incrementScoreTraque = incrementScoreTraque;
}
public void addTraqueCaughtByJetonCreature() {
++numberTraqueCaughtByJetonCreature;
}
public int getNumberTraqueCaughtByJetonCreature() {
return numberTraqueCaughtByJetonCreature;
}
public int getNumberWillingnessDecrementByJetonCreature() {
return numberWillingnessDecrementByJetonCreature;
}
......@@ -264,20 +260,28 @@ public class GameRoundVariables {
playerWhoHaveLostAllWillingness.add(idPlayer);
}
public List<Integer> getPlayerWhoHaveResist() {
return playerWhoHaveResist;
public List<Integer> getPlayersWhoHaveResist() {
return playersWhoHaveResist;
}
public void addPlayersWhoHaveResist(Integer idPlayer) {
playersWhoHaveResist.add(idPlayer);
}
public List<Integer> getPlayersWhoHasCaughtByCreature() {
return playersCaughtByCreature;
}
public void addPlayerWhoHaveResist(Integer idPlayer) {
playerWhoHaveResist.add(idPlayer);
public void addPlayersWhoHasCaughtByCreature(Integer idPlayer) {
playersCaughtByCreature.add(idPlayer);
}
public List<Integer> getPlayerWhoHasCaughtByCreature() {
return playerCaughtByCreature;
public List<Integer> getPlayersWhoHasCaughtByCreatureOnNexus() {
return playersCaughtByCreatureOnNexus;
}
public void addPlayerWhoHasCaughtByCreature(Integer idPlayer) {
playerCaughtByCreature.add(idPlayer);
public void addPlayersWhoHasCaughtByCreatureOnNexus(Integer idPlayer) {
playersCaughtByCreatureOnNexus.add(idPlayer);
}
public List<Integer> getPlayersWhoHavePlayCavale() {
......@@ -489,7 +493,7 @@ public class GameRoundVariables {
this.survivalCardRefugeIsActive = survivalCardRefugeIsActive;
}
public boolean canPLayTrackingCard() {
public boolean canPlayTrackingCard() {
return canPlayTrackingCard;
}
......
......@@ -103,8 +103,11 @@ public class PowerApplicator {
return true;
}
if(checkEpidemieCondition(game, placeCard)){
if(idPlayer != variables.getIdPlayerTargetByTrackingCardEpidemie()){
subWillingness(idPlayer, game, 1);
}
return true;
}
//Case where the SurvivalCard Alerte was played
Place place = planet.getPlaceDistribution().placeCardToPlace(placeCard);
if(checkAlerteCondition(variables, place)) {
......@@ -155,11 +158,9 @@ public class PowerApplicator {
game.getBoard().moveForwardTraque();
}
else{
variables.addPlayerWhoHasCaughtByCreature(idPlayer);
applyJetonCreature(idPlayer, game, placeCard);
blockPlace = true;
}
}
//Jeton Cible
......@@ -265,6 +266,8 @@ public class PowerApplicator {
case CLONE:
applyTrackingClone(idPlayer, game);
break;
case DEPLOIEMENT:
applyTrackingDeploiement(idPlayer, game);
case DESESPOIR:
applyTrackingDesespoir(idPlayer, game);
break;
......@@ -459,6 +462,9 @@ public class PowerApplicator {
return;
}
throwAwayPlaceCards(idPlayer, game, 1);
if(game.getGameRoundVariables().jetonArtemiaMadeLoseOneWillingness()) {
subWillingness(idPlayer, game, 1);
}
}
/**
......@@ -468,20 +474,26 @@ public class PowerApplicator {
* @param placeCard The placeCard where the traque was caught
*/
public static void applyJetonCreature(int idPlayer, Game game, PlaceCard placeCard) {
GameRoundVariables variables = game.getGameRoundVariables();
variables.addPlayersWhoHasCaughtByCreature(idPlayer);
int numberWillingnessDecrement = game.getNumberWillingnessDecrementByJetonCreature();
if(placeCard.getCardName().equals(ANTRE)) {
++numberWillingnessDecrement;
}
game.addTraqueCaughtByJetonCreature();
if(game.getNumberTraqueCaughtByJetonCreature() <= 1) {
if(placeCard.getCardName().equals(NEXUS)) {
game.getBoard().moveForwardCreature(2);
else if(placeCard.getCardName().equals(NEXUS)) {
variables.addPlayersWhoHasCaughtByCreatureOnNexus(idPlayer);
}
else{
int numberTraqueCaught = variables.getPlayersWhoHasCaughtByCreature().size();
int numberTraqueCaughtOnNexus = variables.getPlayersWhoHasCaughtByCreatureOnNexus().size();
if(numberTraqueCaught <= 1) {
game.getBoard().moveForwardCreature();
}
if(placeCard.getCardName().equals(NEXUS) && numberTraqueCaughtOnNexus <= 1) {
game.getBoard().moveForwardCreature();
}
//Acharnement's power
if(game.getIdPlayerTargetByTrackingCardAnticipation() == idPlayer) {
game.getBoard().moveForwardCreature();
}
......@@ -506,30 +518,34 @@ public class PowerApplicator {
***********************************/
private static void applyPlaceAntre(int idPlayer, Game game) {