Commit 3df2a92e authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files

Add TrackingCard powers in PowerApplicator ; Add first PowerApplicator tests ;...

Add TrackingCard powers in PowerApplicator ; Add first PowerApplicator tests ; Several modifications
parent 3e50e271
......@@ -63,7 +63,9 @@ service GameClientService {
void sendStartPhase(common.TPhaseId phaseId, TPlayerTeam team, THand hand, TScore score, TPlanet planet, list<TCardReserve> reserve, list<TTraque> traquesInformation, TCreature creatureInformation)
common.TAction askAction(common.TAskAction actionAsked)
common.TAction askAction(common.TAskAction askedAction)
void sendActionWithoutExpectedResponse(common.TAskAction askedAction);
}
......
......@@ -17,11 +17,16 @@
<description>Spring Boot Not Alone server</description>
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
......
......@@ -31,22 +31,37 @@ public class DatabaseStub implements NotAloneDatabase {
placeCardMap.put("JUNGLE", new PlaceCard(CardName.JUNGLE, "Jungle", "Lorem ipsum", 2, "/image.png", "#4466bb"));
placeCardMap.put("RIVIERE", new PlaceCard(CardName.RIVIERE, "Rivière", "Lorem ipsum", 3, "/image.png", "#4466bb"));
placeCardMap.put("DOME", new PlaceCard(CardName.DOME,"Dôme", "Lorem ipsum", 4, "/image.png", "#4466bb"));
placeCardMap.put("PLAGE", new PlaceCard(CardName.PLAGE,"Plage", "Lorem ipsum", 5, "/image.png", "#4466bb"));
placeCardMap.put("PLAGE", new PlaceCard(CardName.PLAGE,"Plage", "Lorem ipsum", 4, "/image.png", "#4466bb"));
placeCardMap.put("ROVER", new PlaceCard(CardName.ROVER,"Rover", "Lorem ipsum", 5, "/image.png", "#4466bb"));
placeCardMap.put("MANGROVE", new PlaceCard(CardName.MANGROVE, "Mangrove", "Lorem ipsum", 6, "/image.png", "#4466bb"));
placeCardMap.put("MARAIS", new PlaceCard(CardName.MARAIS, "Marais", "Lorem ipsum", 6, "/image.png", "#4466bb"));
placeCardMap.put("ABRI", new PlaceCard(CardName.ABRI, "Abri", "Lorem ipsum", 7, "/image.png", "#4466bb"));
placeCardMap.put("EPAVE", new PlaceCard(CardName.EPAVE, "Epave", "Lorem ipsum", 8, "/image.png", "#4466bb"));
placeCardMap.put("FUNGI", new PlaceCard(CardName.FUNGI, "Fungi", "Lorem ipsum", 9, "/image.png", "#4466bb"));
placeCardMap.put("SOURCE", new PlaceCard(CardName.SOURCE, "Source", "Lorem ipsum", 9, "/image.png", "#4466bb"));
placeCardMap.put("PORTAIL", new PlaceCard(CardName.PORTAIL, "Portail", "Lorem ipsum", 10, "/image.png", "#4466bb"));
placeCardMap.put("ARTEFACT", new PlaceCard(CardName.ARTEFACT, "Artefact", "Lorem ipsum", 10, "/image.png", "#4466bb"));
}
private void initializeSurvivalCardMap(){
survivalCardMap = new HashMap<>();
survivalCardMap.put("ADRENALINE", new SurvivalCard(CardName.ADRENALINE,"Adrénaline", "Lorem ipsum", Phase.PHASE_1));
survivalCardMap.put("ALERTE", new SurvivalCard(CardName.ALERTE,"Alerte", "Lorem ipsum", Phase.PHASE_1));
survivalCardMap.put("AMPLIFICATEUR", new SurvivalCard(CardName.AMPLIFICATEUR,"Amplificateur", "Lorem ipsum", Phase.PHASE_1));
survivalCardMap.put("BROUILLAGE", new SurvivalCard(CardName.BROUILLAGE,"Brouillage", "Lorem ipsum", Phase.PHASE_1));
survivalCardMap.put("CAVALE", new SurvivalCard(CardName.CAVALE,"Cavale", "Lorem ipsum", Phase.PHASE_1));
survivalCardMap.put("DETECTEUR", new SurvivalCard(CardName.DETECTEUR,"Détecteur", "Lorem ipsum", Phase.PHASE_1));
survivalCardMap.put("DRONE", new SurvivalCard(CardName.DRONE,"Drone", "Lorem ipsum", Phase.PHASE_1));
}
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));
}
......
package fr.univnantes.alma.data.item;
public class User {
private String id;
private String mail;
private String passwordHash;
private String pseudo;
//Only for JPA
protected User(){}
public User(String id, String password, String pseudo){
this.id = id;
public User(String mail, String password, String pseudo){
this.mail = this.mail;
this.passwordHash = hash(password);
this.pseudo = pseudo;
}
public String getId() {
return id;
public String getMail() {
return mail;
}
public String getPasswordHash() {
......
......@@ -8,6 +8,7 @@ import fr.univnantes.alma.game.item.power.Power;
import fr.univnantes.alma.thrift.Response;
import fr.univnantes.alma.thrift.TAction;
import fr.univnantes.alma.thrift.TAskAction;
import org.apache.thrift.TException;
import java.util.List;
......@@ -19,12 +20,6 @@ public interface GameInterface {
*/
public boolean isFinish();
/**
* Apply power in the game
* @param power
*/
void apply(Power power);
/**
* Inform the game that the player has finished a phase
* @param playerId The game id of the player
......@@ -100,7 +95,14 @@ public interface GameInterface {
* @param askedAction The asked action
* @return An Action
*/
public Action askAction(int inGameIdPlayer, TAskAction askedAction);
public Action askAction(int inGameIdPlayer, TAskAction askedAction) throws TException;
/**
* Send an action to a client
* @param inGameIdPlayer The id of player
* @param askedAction The asked action
*/
public void sendActionWithoutExpectedResponse(int inGameIdPlayer, TAskAction askedAction);
/**
* Send that the game start
......
package fr.univnantes.alma.game;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
public class GameRoundVariables {
//Functions
private BiConsumer<Integer, Game> actionJetonCible;
private BiConsumer<Integer, Game> actionAdjacentPlaceJetonCible;
//Modifiers
private int incrementScoreTraque;
private int numberTraqueCaughtByJetonCreature;
private int numberWillingnessDecrementByJetonCreature;
private int numberMaxPlaceCardsGetByPlacePower;
//Id players
private int idPlayerTargetByTrackingCardAnticipation;
private int idPlayerTargetByTrackingCardDomination;
private int idPlayerTargetByTrackingCardEpidemie;
private int idPlayerTargetBySurvivalCardMimetisme;
//Player ids list
private List<Integer> playerWhoHaveLostAllWillingness;
private List<Integer> playerWhoHaveResist;
//Conditions
private boolean traqueCanResist;
private boolean traqueCanPickSurvivalCards;
private boolean jetonArtemiaIsActive;
private boolean jetonArtemiaMadeLoseOneWillingness;
private boolean rescuePawnCanMoveForward;
private boolean jetonCibleCanBeOnTwoAdjacentPlaces;
private boolean jetonCreatureCanBeOnTwoAdjacentPlaces;
private boolean jetonArtemiaCanBeOnTwoAdjacentPlaces;
private boolean defaussePlaceCardsAreHidden;
private boolean canPlaceJetonCreatureOnPlaces6To10;
private boolean survivalCardRalliementIsActive;
private boolean survivalCardRefugeIsActive;
private boolean canPlayTrackingCard;
private boolean inertieTrackingCardIsPlayed;
private boolean jetonCibleBlockPlace;
private boolean jetonCibleBlockAdjacentPlace;
private boolean jetonCibleAdjacentPlaceMoveTraque;
public GameRoundVariables() {
this.incrementScoreTraque = 1;
jetonArtemiaIsActive = true;
reset();
}
public void reset(){
//Functions
this.actionJetonCible = (a,b) -> {};
this.actionAdjacentPlaceJetonCible = (a,b) -> {};
//Modifiers
this.incrementScoreTraque = 1;
jetonArtemiaIsActive = true;
this.numberTraqueCaughtByJetonCreature = 0;
this.numberWillingnessDecrementByJetonCreature = 1;
this.numberMaxPlaceCardsGetByPlacePower = -1;
//Id players
this.idPlayerTargetByTrackingCardAnticipation = -1;
this.idPlayerTargetByTrackingCardDomination = -1;
this.idPlayerTargetByTrackingCardEpidemie = -1;
this.idPlayerTargetBySurvivalCardMimetisme = -1;
//Player ids list
this.playerWhoHaveLostAllWillingness = new ArrayList<>();
this.playerWhoHaveResist = new ArrayList<>();
//Conditions
this.traqueCanResist = true;
this.traqueCanPickSurvivalCards = true;
this.jetonArtemiaIsActive = true;
this.jetonArtemiaMadeLoseOneWillingness = true;
this.rescuePawnCanMoveForward = true;
this.jetonCibleCanBeOnTwoAdjacentPlaces = false;
this.jetonCreatureCanBeOnTwoAdjacentPlaces = false;
this.jetonArtemiaCanBeOnTwoAdjacentPlaces = false;
this.defaussePlaceCardsAreHidden = false;
this.canPlaceJetonCreatureOnPlaces6To10 = true;
this.survivalCardRalliementIsActive = false;
this.survivalCardRefugeIsActive = false;
this.canPlayTrackingCard = true;
this.inertieTrackingCardIsPlayed = false;
this.jetonCibleBlockPlace = false;
this.jetonCibleBlockAdjacentPlace = false;
this.jetonCibleAdjacentPlaceMoveTraque = false;
}
//Functions methods
public BiConsumer<Integer, Game> getActionJetonCible() {
return actionJetonCible;
}
public void setActionJetonCible(BiConsumer<Integer, Game> actionJetonCible) {
this.actionJetonCible = actionJetonCible;
}
public BiConsumer<Integer, Game> getActionAdjacentPlaceJetonCible() {
return actionAdjacentPlaceJetonCible;
}
public void setActionAdjacentPlaceJetonCible(BiConsumer<Integer, Game> actionAdjacentPlaceJetonCible) {
this.actionAdjacentPlaceJetonCible = actionAdjacentPlaceJetonCible;
}
//Modifiers methods
public int getIncrementScoreTraque() {
return incrementScoreTraque;
}
......@@ -22,6 +118,104 @@ public class GameRoundVariables {
this.incrementScoreTraque = incrementScoreTraque;
}
public void addTraqueCaughtByJetonCreature() {
++numberTraqueCaughtByJetonCreature;
}
public int getNumberTraqueCaughtByJetonCreature() {
return numberTraqueCaughtByJetonCreature;
}
public int getNumberWillingnessDecrementByJetonCreature() {
return numberWillingnessDecrementByJetonCreature;
}
public void setNumberWillingnessDecrementByJetonCreature(int numberWillingnessDecrementByJetonCreature) {
this.numberWillingnessDecrementByJetonCreature = numberWillingnessDecrementByJetonCreature;
}
public void addNumberWillingnessByJetonCreature() {
++this.numberWillingnessDecrementByJetonCreature;
}
public boolean numberMaxPlaceCardsGetByPlacePowerIsLimited() {
return numberMaxPlaceCardsGetByPlacePower != -1;
}
public int getNumberMaxPlaceCardsGetByPlacePower() {
return numberMaxPlaceCardsGetByPlacePower;
}
public void setNumberMaxPlaceCardsGetByPlacePower(int numberMaxPlaceCardsGetByPlacePower) {
this.numberMaxPlaceCardsGetByPlacePower = numberMaxPlaceCardsGetByPlacePower;
}
//Id players
public void setIdPlayerTargetByTrackingCardAnticipation(int idPlayerTargetByJetonCreature) {
this.idPlayerTargetByTrackingCardAnticipation = idPlayerTargetByJetonCreature;
}
public int getIdPlayerTargetByTrackingCardAnticipation() {
return idPlayerTargetByTrackingCardAnticipation;
}
public boolean playerIsTargetByTrackingCardDomination() {
return idPlayerTargetByTrackingCardDomination != -1;
}
public boolean playerIsTargetByTrackingCardEpidemie() {
return idPlayerTargetByTrackingCardEpidemie != -1;
}
public boolean playerIsTargetBySurvivalCardMimetisme() {
return idPlayerTargetBySurvivalCardMimetisme != -1;
}
public int getIdPlayerTargetByTrackingCardDomination() {
return idPlayerTargetByTrackingCardDomination;
}
public void setIdPlayerTargetByTrackingCardDomination(int idPlayerTargetByTrackingCardDomination) {
this.idPlayerTargetByTrackingCardDomination = idPlayerTargetByTrackingCardDomination;
}
public int getIdPlayerTargetByTrackingCardEpidemie() {
return idPlayerTargetByTrackingCardEpidemie;
}
public void setIdPlayerTargetByTrackingCardEpidemie(int idPlayerTargetByTrackingCardEpidemie) {
this.idPlayerTargetByTrackingCardEpidemie = idPlayerTargetByTrackingCardEpidemie;
}
public int getIdPlayerTargetBySurvivalCardMimetisme() {
return idPlayerTargetBySurvivalCardMimetisme;
}
public void setIdPlayerTargetBySurvivalCardMimetisme(int idPlayerTargetBySurvivalCardMimetisme) {
this.idPlayerTargetBySurvivalCardMimetisme = idPlayerTargetBySurvivalCardMimetisme;
}
//Player ids list
public List<Integer> getPlayerWhoHaveLostAllWillingness() {
return playerWhoHaveLostAllWillingness;
}
public void addPlayerWhoHaveLostAllWillingness(Integer idPlayer) {
playerWhoHaveLostAllWillingness.add(idPlayer);
}
public List<Integer> getPlayerWhoHaveResist() {
return playerWhoHaveResist;
}
public void addPlayerWhoHaveResist(Integer idPlayer) {
playerWhoHaveResist.add(idPlayer);
}
//Conditions
public boolean isJetonArtemiaIsActive() {
return jetonArtemiaIsActive;
}
......@@ -33,4 +227,136 @@ public class GameRoundVariables {
public void enableJetonArtemia() {
jetonArtemiaIsActive = true;
}
public boolean traqueCanResist() {
return traqueCanResist;
}
public void setTraqueCanResist(boolean traqueCanResist) {
this.traqueCanResist = traqueCanResist;
}
public boolean traqueCanPickSurvivalCards() {
return traqueCanPickSurvivalCards;
}
public void setTraqueCanPickSurvivalCards(boolean traqueCanPickSurvivalCards) {
this.traqueCanPickSurvivalCards = traqueCanPickSurvivalCards;
}
public void setJetonArtemiaIsActive(boolean jetonArtemiaIsActive) {
this.jetonArtemiaIsActive = jetonArtemiaIsActive;
}
public boolean jetonArtemiaMadeLoseOneWillingness() {
return jetonArtemiaMadeLoseOneWillingness;
}
public void setJetonArtemiaMadeLoseOneWillingness(boolean jetonArtemiaMadeLoseOneWillingness) {
this.jetonArtemiaMadeLoseOneWillingness = jetonArtemiaMadeLoseOneWillingness;
}
public boolean rescuePawnCanMoveForward() {
return rescuePawnCanMoveForward;
}
public void setRescuePawnCanMoveForward(boolean rescuePawnCanMoveForward) {
this.rescuePawnCanMoveForward = rescuePawnCanMoveForward;
}
public boolean jetonCibleCanBeOnTwoAdjacentPlaces() {
return jetonCibleCanBeOnTwoAdjacentPlaces;
}
public void setJetonCibleCanBeOnTwoAdjacentPlaces(boolean jetonCibleCanBeOnTwoAdjacentPlaces) {
this.jetonCibleCanBeOnTwoAdjacentPlaces = jetonCibleCanBeOnTwoAdjacentPlaces;
}
public boolean jetonCreatureCanBeOnTwoAdjacentPlaces() {
return jetonCreatureCanBeOnTwoAdjacentPlaces;
}
public void setJetonCreatureCanBeOnTwoAdjacentPlaces(boolean jetonCreatureCanBeOnTwoAdjacentPlaces) {
this.jetonCreatureCanBeOnTwoAdjacentPlaces = jetonCreatureCanBeOnTwoAdjacentPlaces;
}
public boolean jetonArtemiaCanBeOnTwoAdjacentPlaces() {
return jetonArtemiaCanBeOnTwoAdjacentPlaces;
}
public void jetonArtemiaCanBeOnTwoAdjacentPlaces(boolean jetonArtemiaCanBeOnTwoAdjacentPlaces) {
this.jetonArtemiaCanBeOnTwoAdjacentPlaces = jetonArtemiaCanBeOnTwoAdjacentPlaces;
}
public boolean defaussePlaceCardsAreHidden() {
return defaussePlaceCardsAreHidden;
}
public void setDefaussePlaceCardsAreHidden(boolean defaussePlaceCardsAreHidden) {
this.defaussePlaceCardsAreHidden = defaussePlaceCardsAreHidden;
}
public boolean canPlaceJetonCreatureOnPlaces6To10() {
return canPlaceJetonCreatureOnPlaces6To10;
}
public void setCanPlaceJetonCreatureOnPlaces6To10(boolean canPlaceJetonCreatureOnPlaces6To10) {
this.canPlaceJetonCreatureOnPlaces6To10 = canPlaceJetonCreatureOnPlaces6To10;
}
public boolean survivalCardRalliementIsActive() {
return survivalCardRalliementIsActive;
}
public void setSurvivalCardRalliementIsActive(boolean survivalCardRalliementIsActive) {
this.survivalCardRalliementIsActive = survivalCardRalliementIsActive;
}
public boolean survivalCardRefugeIsActive() {
return survivalCardRefugeIsActive;
}
public void setSurvivalCardRefugeIsActive(boolean survivalCardRefugeIsActive) {
this.survivalCardRefugeIsActive = survivalCardRefugeIsActive;
}
public boolean canPLayTrackingCard() {
return canPlayTrackingCard;
}
public void setCanPlayTrackingCard(boolean canPlayTrackingCard) {
this.canPlayTrackingCard = canPlayTrackingCard;
}
public boolean inertieTrackingCardIsPlayed() {
return inertieTrackingCardIsPlayed;
}
public void setInertieTrackingCardIsPlayed(boolean inertieTrackingCardIsPlayed) {
this.inertieTrackingCardIsPlayed = inertieTrackingCardIsPlayed;
}
public boolean isJetonCibleBlockPlace() {
return jetonCibleBlockPlace;
}
public void setJetonCibleBlockPlace(boolean jetonCibleBlockPlace) {
this.jetonCibleBlockPlace = jetonCibleBlockPlace;
}
public boolean isJetonCibleBlockAdjacentPlace() {
return jetonCibleBlockAdjacentPlace;
}
public void setJetonCibleBlockAdjacentPlace(boolean jetonCibleBlockAdjacentPlace) {
this.jetonCibleBlockAdjacentPlace = jetonCibleBlockAdjacentPlace;
}
public boolean isJetonCibleAdjacentPlaceMoveTraque() {
return jetonCibleAdjacentPlaceMoveTraque;
}
public void setJetonCibleAdjacentPlaceMoveTraque(boolean jetonCibleAdjacentPlaceMoveTraque) {
this.jetonCibleAdjacentPlaceMoveTraque = jetonCibleAdjacentPlaceMoveTraque;
}
}
package fr.univnantes.alma.game.item.action;
public enum ActionType{
CHOOSE_POWER, TARGET_PLAYER, MOVE_PLAYER, CHOOSE_CARD, CHOOSE_PLACE, SWAP_JETONS, MOVE_JETON, ASSOCIATE_CARDNAMES_TO_PLACES
CHOOSE_POWER, TARGET_PLAYER, MOVE_PLAYER, CHOOSE_CARD, CHOOSE_PLACE, SWAP_JETONS, MOVE_JETON, ASSOCIATE_CARDNAMES_TO_PLACES, SHOW_CARD
}
......@@ -42,6 +42,8 @@ public abstract class Card {
return card.getCardName().equals(this.cardName);
}
@Override
public String toString() {
return cardName.toString();
}
}
\ No newline at end of file
......@@ -4,13 +4,25 @@ import fr.univnantes.alma.game.item.Phase;
public abstract class PlayerCard extends Card {
protected Phase phase;
protected Phase phaseToApply;
public PlayerCard(CardName cardName, String name, String description, Phase phase){
super(cardName, name, description);
this.phase = phase;
this.phaseToApply = phase;
}
public PlayerCard(CardName cardName, String name, String description, Phase phase, Phase phaseToApply){
super(cardName, name, description);
this.phase = phase;
this.phaseToApply = phaseToApply;
}
public Phase getPhase() {
return phase;
}
public Phase getPhaseToApply() {
return phaseToApply;
}
}
......@@ -21,6 +21,16 @@ public class TrackingCard extends PlayerCard {
this.jetons = jetons;
}
public TrackingCard(CardName cardName, String name, String description, Phase phase, Phase phaseToApply){
super(cardName, name, description, phase, phaseToApply);
this.jetons = new ArrayList<>();
}
public TrackingCard(CardName cardName, String name, String description, Phase phase, List<Jeton> jetons, Phase phaseToApply){
super(cardName, name, description, phase, phaseToApply);
this.jetons = jetons;
}
public List<Jeton> getJetons() {
return jetons;
}
......
......@@ -2,6 +2,7 @@ package fr.univnantes.alma.game.item.jeton;
import fr.univnantes.alma.game.item.planet.Place;
import java.util.ArrayList;
import java.util.List;
public class PlacedJeton {
......@@ -13,6 +14,43 @@ public class PlacedJeton {