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; ...@@ -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.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;
import fr.univnantes.alma.server.game.item.jeton.JetonArtemia;
import fr.univnantes.alma.server.game.item.jeton.JetonSymbol;
import java.util.*; import java.util.*;
...@@ -61,13 +63,43 @@ public class DatabaseStub implements NotAloneDatabase { ...@@ -61,13 +63,43 @@ public class DatabaseStub implements NotAloneDatabase {
private void initializeTrackingCardMap(){ private void initializeTrackingCardMap(){
trackingCardMap = new HashMap<>(); trackingCardMap = new HashMap<>();
trackingCardMap.put("ACHARNEMENT", new TrackingCard(CardName.ACHARNEMENT, "Acharnement", "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.PHASE_1)); 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.PHASE_1)); trackingCardMap.put("ANTICIPATION", new TrackingCard(CardName.ANTICIPATION, "Anticipation", "Lorem ipsum", Phase.PREPHASE_2));
trackingCardMap.put("CATACLYSME", new TrackingCard(CardName.CATACLYSME, "Cataclysme", "Lorem ipsum", Phase.PHASE_1)); 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.PHASE_1)); 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.PHASE_1)); 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));
}
@Override @Override
......
...@@ -7,7 +7,6 @@ import fr.univnantes.alma.server.game.item.Reserve; ...@@ -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.action.*;
import fr.univnantes.alma.server.game.item.board.Board; import fr.univnantes.alma.server.game.item.board.Board;
import fr.univnantes.alma.server.game.item.card.*; 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.JetonSymbol;
import fr.univnantes.alma.server.game.item.jeton.PlacedJeton; 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.pioche.Pioche;
...@@ -275,10 +274,6 @@ public class Game implements GameInterface { ...@@ -275,10 +274,6 @@ public class Game implements GameInterface {
return gameRoundVariables.isJetonArtemiaIsActive(); return gameRoundVariables.isJetonArtemiaIsActive();
} }
public int getNumberTraqueCaughtByJetonCreature() {
return gameRoundVariables.getNumberTraqueCaughtByJetonCreature();
}
public int getNumberWillingnessDecrementByJetonCreature() { public int getNumberWillingnessDecrementByJetonCreature() {
return gameRoundVariables.getNumberWillingnessDecrementByJetonCreature(); return gameRoundVariables.getNumberWillingnessDecrementByJetonCreature();
} }
...@@ -311,10 +306,6 @@ public class Game implements GameInterface { ...@@ -311,10 +306,6 @@ public class Game implements GameInterface {
gameRoundVariables.enableJetonArtemia(); gameRoundVariables.enableJetonArtemia();
} }
public void addTraqueCaughtByJetonCreature() {
gameRoundVariables.addTraqueCaughtByJetonCreature();
}
public void setNumberWillingnessDecrementByJetonCreature(int number) { public void setNumberWillingnessDecrementByJetonCreature(int number) {
gameRoundVariables.setNumberWillingnessDecrementByJetonCreature(number); gameRoundVariables.setNumberWillingnessDecrementByJetonCreature(number);
} }
...@@ -499,11 +490,19 @@ public class Game implements GameInterface { ...@@ -499,11 +490,19 @@ public class Game implements GameInterface {
public Response playerPlaceJeton(int playerId, PlacedJeton placedJeton) { public Response playerPlaceJeton(int playerId, PlacedJeton placedJeton) {
Response response; Response response;
Player player = playersMap.get(playerId); Player player = playersMap.get(playerId);
if(player.teamEqualsTo(TRAQUE) || ! state.equals(Phase.PHASE_2)){ if(player.teamEqualsTo(TRAQUE)){
response = new Response(false, "Only the Creature can played jeton and only in the PHASE_2"); 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)) { 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{ else{
response = creaturePlaceAJeton(creature, placedJeton); response = creaturePlaceAJeton(creature, placedJeton);
...@@ -515,8 +514,8 @@ public class Game implements GameInterface { ...@@ -515,8 +514,8 @@ public class Game implements GameInterface {
public Response playerPlaceJeton(int playerId, List<PlacedJeton> jetons) { public Response playerPlaceJeton(int playerId, List<PlacedJeton> jetons) {
Player player = playersMap.get(playerId); Player player = playersMap.get(playerId);
Response response; Response response;
if(player.teamEqualsTo(TRAQUE) || ! state.equals(Phase.PHASE_2)){ if(player.teamEqualsTo(TRAQUE)){
response = new Response(false, "Only the Creature can played jeton and only in the PHASE_2"); response = new Response(false, "Only the Creature can played jetons");
} }
else { else {
boolean canPlaceAllJetons = true; boolean canPlaceAllJetons = true;
...@@ -538,7 +537,10 @@ public class Game implements GameInterface { ...@@ -538,7 +537,10 @@ public class Game implements GameInterface {
public Response playerResist(int playerId, int number) { public Response playerResist(int playerId, int number) {
Player player = playersMap.get(playerId); Player player = playersMap.get(playerId);
Response response; 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"); response = new Response(false, "Only traque can resist");
} }
else{ else{
...@@ -549,13 +551,16 @@ public class Game implements GameInterface { ...@@ -549,13 +551,16 @@ public class Game implements GameInterface {
else if(! state.equals(Phase.PHASE_1)){ else if(! state.equals(Phase.PHASE_1)){
response = new Response(false, "Resist is only possible in 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); traque.subWillingness(number);
int cardsPerWillingness = 2 + traque.getNumberOfAdditionalCardsTakeBackPerPawnWillingnessLostWithResist(); int cardsPerWillingness = 2 + traque.getNumberOfAdditionalCardsTakeBackPerPawnWillingnessLostWithResist();
int numberCard = Math.min(cardsPerWillingness * number, traque.defausseSize()); int numberCard = Math.min(cardsPerWillingness * number, traque.defausseSize());
choosePlaceCardsAction(playerId, numberCard, traque.getDefausse()); if(numberCard > 0) {
choosePlaceCardsAction(playerId, numberCard, traque.getDefausse());
}
traque.getRights().setCanGiveUp(false); traque.getRights().setCanGiveUp(false);
traque.getRights().setCanResist(false); traque.getRights().setCanResist(false);
gameRoundVariables.addPlayersWhoHaveResist(traque.getInGameId());
response = new Response(true, ""); response = new Response(true, "");
} }
else{ else{
...@@ -708,13 +713,16 @@ public class Game implements GameInterface { ...@@ -708,13 +713,16 @@ public class Game implements GameInterface {
* @return A Response * @return A Response
*/ */
public Response creaturePlayTrackingCard(Creature creature, TrackingCard trackingCard) { public Response creaturePlayTrackingCard(Creature creature, TrackingCard trackingCard) {
if(gameRoundVariables.refugeIsActive() && trackingCard.getJetons().contains(new JetonCible())) { boolean canPlay = creatureCanPlayThisTrackingCards(creature, trackingCard);
return new Response(false, "Unable to play this card when Refuge is active"); if(canPlay){
} if(creature.getTrackingCardToApplied().contains(trackingCard)
else if(creatureCanPlayThisTrackingCards(creature, trackingCard) && || creature.playTrackingCard(trackingCard)) {
creature.playTrackingCard(trackingCard)) { applyCreaturePlayTrackingCard(creature, trackingCard);
applyCreaturePlayTrackingCard(creature, trackingCard); return new Response(true, "");
return new Response(true, ""); }
else{
return new Response(false, "Unable to play this card");
}
} }
else{ else{
return new Response(false, "Unable to play this card"); return new Response(false, "Unable to play this card");
...@@ -728,10 +736,10 @@ public class Game implements GameInterface { ...@@ -728,10 +736,10 @@ public class Game implements GameInterface {
* @return A Response * @return A Response
*/ */
public Response creaturePlayTrackingCard(Creature creature, List<TrackingCard> trackingCards) { public Response creaturePlayTrackingCard(Creature creature, List<TrackingCard> trackingCards) {
if( creatureCanPlayThisTrackingCards(creature, trackingCards) && boolean canPlay = creatureCanPlayThisTrackingCards(creature, trackingCards);
creature.playTrackingCard(trackingCards)) { if(canPlay) {
for(TrackingCard trackingCard : trackingCards){ for(TrackingCard trackingCard : trackingCards){
applyCreaturePlayTrackingCard(creature, trackingCard); creatureCanPlayThisTrackingCards(creature, trackingCard);
} }
return new Response(true, ""); return new Response(true, "");
} }
...@@ -746,59 +754,53 @@ public class Game implements GameInterface { ...@@ -746,59 +754,53 @@ public class Game implements GameInterface {
* @param trackingCard The card * @param trackingCard The card
*/ */
private void applyCreaturePlayTrackingCard(Creature creature, TrackingCard trackingCard) { private void applyCreaturePlayTrackingCard(Creature creature, TrackingCard trackingCard) {
if(playerCardsPlayedPhaseAndAppliedPhaseDifferent(trackingCard)) { Phase toApplied = trackingCard.getPhaseToApply();
if(state.equals(trackingCard.getPhase())){ if(toApplied.equals(state)) {
creature.playTrackingCard(trackingCard); creature.removeTrackingCardToApplied(trackingCard);
creature.addTrackingCardToApplied(trackingCard);
}
else{
applyPlayerCard(creature.getInGameId(), trackingCard, this);
creature.removeTrackingCardToApplied(trackingCard);
trackingCardPioche.throwAway(trackingCard);
}
}
else{
applyPlayerCard(creature.getInGameId(), trackingCard, this); applyPlayerCard(creature.getInGameId(), trackingCard, this);
creature.playTrackingCard(trackingCard);
trackingCardPioche.throwAway(trackingCard); trackingCardPioche.throwAway(trackingCard);
} }
else {
creature.addTrackingCardToApplied(trackingCard);
}
} }
public boolean creatureCanPlayThisTrackingCards(Creature creature, TrackingCard trackingCard) { public boolean creatureCanPlayThisTrackingCards(Creature creature, TrackingCard trackingCard) {
if(! gameRoundVariables.canPLayTrackingCard()) { if(gameRoundVariables.refugeIsActive() && trackingCard.containsSymbol(CIBLE)) {
return false; return false;
} }
//if the card doesn't apply himself in the same phase that it's played if(! gameRoundVariables.canPlayTrackingCard()) {
if(playerCardsPlayedPhaseAndAppliedPhaseDifferent(trackingCard)) { return false;
//true if the card can to be played or can to be applied }
return (creature.getHand().trackingCardPlayedSize() < creature.getMaxTrackingCardPlayable() && state.equals(trackingCard.getPhase())) else if(creature.getTrackingCardToApplied().contains(trackingCard) && state.equals(trackingCard.getPhaseToApply())) {
|| (state.equals(trackingCard.getPhaseToApply()) && creature.getTrackingCardsPlayed().contains(trackingCard)); return true;
} }
else{ else{
//true if the card can to be played boolean canPlay = creature.getHand().trackingCardPlayedSize() < creature.getMaxTrackingCardPlayable()
return creature.getHand().trackingCardPlayedSize() < creature.getMaxTrackingCardPlayable() && state.equals(trackingCard.getPhase()); && state.equals(trackingCard.getPhase());
return canPlay && creature.getTrackingCardHand().contains(trackingCard);
} }
} }
public boolean creatureCanPlayThisTrackingCards(Creature creature, List<TrackingCard> trackingCards) { public boolean creatureCanPlayThisTrackingCards(Creature creature, List<TrackingCard> trackingCards) {
if(! gameRoundVariables.canPLayTrackingCard()) { if(! gameRoundVariables.canPlayTrackingCard()) {
return false; return false;
} }
int numberCardPlayed = 0; Iterator<TrackingCard> iterator = trackingCards.iterator();
//Count the number of played cards boolean canPlay = true;
for(TrackingCard trackingCard : trackingCards) { List<Card> toPlay = new ArrayList<>();
if(! playerCardsPlayedPhaseAndAppliedPhaseDifferent(trackingCard)) { TrackingCard trackingCard;
++numberCardPlayed; while (canPlay && iterator.hasNext()) {
trackingCard = iterator.next();
if(! creature.getTrackingCardToApplied().contains(trackingCard)) {
toPlay.add(trackingCard);
}
if(! creatureCanPlayThisTrackingCards(creature, trackingCard)) {
canPlay = false;
} }
} }
if(creature.getHand().trackingCardPlayedSize() + numberCardPlayed > creature.getMaxTrackingCardPlayable()){ canPlay = canPlay && creature.getHand().trackingCardPlayedSize() + toPlay.size() > creature.getMaxTrackingCardPlayable();
return false; return canPlay && creature.getTrackingCardHand().containsAll(toPlay);
}
boolean aux = true;
for(TrackingCard trackingCard : trackingCards) {
aux = aux && creatureCanPlayThisTrackingCards(creature, trackingCard);
}
return aux;
} }
/** /**
...@@ -899,13 +901,21 @@ public class Game implements GameInterface { ...@@ -899,13 +901,21 @@ public class Game implements GameInterface {
* @return A Response * @return A Response
*/ */
public Response traquePlayPlaceCard(Traque traque, PlaceCard placeCard) { public Response traquePlayPlaceCard(Traque traque, PlaceCard placeCard) {
if(traque.placeCardPlayedSize() < traque.getMaxPlacesCardChoosable() && Response response;
traque.playPlaceCard(placeCard) && planet.isRevealedPlace(placeCard)) { if(!planet.isRevealedPlace(placeCard)) {
return new Response(true, ""); 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{ 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 { ...@@ -949,6 +959,18 @@ public class Game implements GameInterface {
JetonSymbol type = placedJeton.getJeton().getType(); 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) if( (type.equals(CIBLE) && containsJetonCible)
|| (type.equals(ARTEMIA) && (containsJetonArtemia || board.isArtemiaSquare())) || (type.equals(ARTEMIA) && (containsJetonArtemia || board.isArtemiaSquare()))
|| type.equals(JetonSymbol.CREATURE)) { || type.equals(JetonSymbol.CREATURE)) {
...@@ -1070,7 +1092,7 @@ public class Game implements GameInterface { ...@@ -1070,7 +1092,7 @@ public class Game implements GameInterface {
|| gameRoundVariables.getPlayersWhoHavePlayVolteFace().contains(traque.getInGameId())) { || gameRoundVariables.getPlayersWhoHavePlayVolteFace().contains(traque.getInGameId())) {
traque.takeBackPlayedPlaceCards(); 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); List<PlaceCard> placeCardsWhereIsJetonCreature = planet.getPlaceCardsWhereJetonIs(JetonSymbol.CREATURE);
traque.takeBackPlaceCard(placeCardsWhereIsJetonCreature); traque.takeBackPlaceCard(placeCardsWhereIsJetonCreature);
traque.throwAwayPlaceCard(); traque.throwAwayPlaceCard();
...@@ -1103,6 +1125,7 @@ public class Game implements GameInterface { ...@@ -1103,6 +1125,7 @@ public class Game implements GameInterface {
} }
creature.reset(); creature.reset();
applyNextRoundPowers(); applyNextRoundPowers();
gameRoundVariables.resetAfterNextRoundPowersApplication();
} }
} }
...@@ -1117,9 +1140,9 @@ public class Game implements GameInterface { ...@@ -1117,9 +1140,9 @@ public class Game implements GameInterface {
} }
else if(power.getType().equals(PowerType.RECURRENT)) { else if(power.getType().equals(PowerType.RECURRENT)) {
PowerRecurrent powerRecurrent = (PowerRecurrent) power; PowerRecurrent powerRecurrent = (PowerRecurrent) power;
powerRecurrent.apply(this);
if(powerRecurrent.conditionIsTrue(this)) { if(powerRecurrent.conditionIsTrue(this)) {
newNextRoundPowers.add(power); newNextRoundPowers.add(power);
powerRecurrent.apply(this);
} }
} }
} }
...@@ -1246,7 +1269,7 @@ public class Game implements GameInterface { ...@@ -1246,7 +1269,7 @@ public class Game implements GameInterface {
cardNames = ((ActionChooseCard) action).getCards(); cardNames = ((ActionChooseCard) action).getCards();
cards = computeCardListFromCardNames(cardNames, cardsToChoose); cards = computeCardListFromCardNames(cardNames, cardsToChoose);
} }
} while (cards.isEmpty()); } while (cards.isEmpty() || cards.size() > max);
return cards; return cards;
} }
...@@ -1319,7 +1342,7 @@ public class Game implements GameInterface { ...@@ -1319,7 +1342,7 @@ public class Game implements GameInterface {
if(action.getActionType().equals(TARGET_PLAYER)) { if(action.getActionType().equals(TARGET_PLAYER)) {
idTargetPlayer = ((ActionTargetPlayer) action).getIdPlayer(); idTargetPlayer = ((ActionTargetPlayer) action).getIdPlayer();
} }
} while(! playersIdList.contains(idTargetPlayer) && creature.getInGameId() == idTargetPlayer); } while(! playersIdList.contains(idTargetPlayer) || creature.getInGameId() == idTargetPlayer);
return idTargetPlayer; return idTargetPlayer;
} }
......
...@@ -16,7 +16,6 @@ public class GameRoundVariables { ...@@ -16,7 +16,6 @@ public class GameRoundVariables {
//Modifiers //Modifiers
private int incrementScoreTraque; private int incrementScoreTraque;
private int numberTraqueCaughtByJetonCreature;
private int numberWillingnessDecrementByJetonCreature; private int numberWillingnessDecrementByJetonCreature;
private int numberMaxPlaceCardsGetByPlacePower; private int numberMaxPlaceCardsGetByPlacePower;
...@@ -31,8 +30,9 @@ public class GameRoundVariables { ...@@ -31,8 +30,9 @@ public class GameRoundVariables {
//Player ids list //Player ids list
private List<Integer> playerWhoHaveLostAllWillingness; private List<Integer> playerWhoHaveLostAllWillingness;
private List<Integer> playerWhoHaveResist; private List<Integer> playersWhoHaveResist;
private List<Integer> playerCaughtByCreature; private List<Integer> playersCaughtByCreature;
private List<Integer> playersCaughtByCreatureOnNexus;
private List<Integer> playersWhoDodgeJetonArtemia; private List<Integer> playersWhoDodgeJetonArtemia;
private List<Integer> playersWhoDodgeJetonCreature; private List<Integer> playersWhoDodgeJetonCreature;
private List<Integer> playersWhoDodgeJetonCible; private List<Integer> playersWhoDodgeJetonCible;
...@@ -68,6 +68,7 @@ public class GameRoundVariables { ...@@ -68,6 +68,7 @@ public class GameRoundVariables {
public GameRoundVariables() { public GameRoundVariables() {
this.numberPawnWillingnessOnBoard = 0; this.numberPawnWillingnessOnBoard = 0;
this.playerWhoHaveLostAllWillingness = new ArrayList<>();
reset(); reset();
} }
...@@ -78,7 +79,6 @@ public class GameRoundVariables { ...@@ -78,7 +79,6 @@ public class GameRoundVariables {
//Modifiers //Modifiers
this.incrementScoreTraque = 1; this.incrementScoreTraque = 1;
this.numberTraqueCaughtByJetonCreature = 0;
this.numberWillingnessDecrementByJetonCreature = 1; this.numberWillingnessDecrementByJetonCreature = 1;
this.numberMaxPlaceCardsGetByPlacePower = -1; this.numberMaxPlaceCardsGetByPlacePower = -1;
...@@ -91,9 +91,9 @@ public class GameRoundVariables { ...@@ -91,9 +91,9 @@ public class GameRoundVariables {
this.targetByAlerte = null; this.targetByAlerte = null;
//Player ids list //Player ids list
this.playerWhoHaveLostAllWillingness = new ArrayList<>(); this.playersWhoHaveResist = new ArrayList<>();
this.playerWhoHaveResist = new ArrayList<>(); this.playersCaughtByCreature = new ArrayList<>();
this.playerCaughtByCreature = new ArrayList<>(); this.playersCaughtByCreatureOnNexus = new ArrayList<>();
this.playersWhoHavePlayCavale = new ArrayList<>(); this.playersWhoHavePlayCavale = new ArrayList<>();
this.playersWhoDodgeJetonArtemia = new ArrayList<>(); this.playersWhoDodgeJetonArtemia = new ArrayList<>();
this.playersWhoHavePlayDrone = new ArrayList<>(); this.playersWhoHavePlayDrone = new ArrayList<>();
...@@ -129,6 +129,10 @@ public class GameRoundVariables { ...@@ -129,6 +129,10 @@ public class GameRoundVariables {
this.refugeIsActive = false; this.refugeIsActive = false;
} }
public void resetAfterNextRoundPowersApplication() {