changements et reglé erreurs
This commit is contained in:
@@ -1,13 +0,0 @@
|
|||||||
package carte;
|
|
||||||
|
|
||||||
import main.Joueur;
|
|
||||||
import main.Type;
|
|
||||||
|
|
||||||
|
|
||||||
public class Equipement extends CartePiochable<Type>{
|
|
||||||
|
|
||||||
|
|
||||||
public void utiliser(Joueur j) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package condition;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import main.Joueur;
|
|
||||||
|
|
||||||
|
|
||||||
public class ConditionType extends Condition{
|
|
||||||
|
|
||||||
private List<Joueur.Equipe> equipes;
|
|
||||||
|
|
||||||
public ConditionType(List<Joueur.Equipe> equipes){
|
|
||||||
|
|
||||||
this.equipes = new ArrayList<Joueur.Equipe>();
|
|
||||||
this.equipes.addAll(equipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vérifie qu'il existe au moins une classe qui correspond à l'équipe du Joueur.
|
|
||||||
* <br><br>
|
|
||||||
* exemple :
|
|
||||||
*
|
|
||||||
* classes = { NEUTRE,SHADOW,HUNTER }
|
|
||||||
* <br>
|
|
||||||
* Si l'équipe du joueur correspond à un des élements dans la liste des équipes alors on renvoie vrai.
|
|
||||||
*
|
|
||||||
* @param joueur Le joueur sur lequel on vérifie les conditions.
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isTrue(Joueur joueur)
|
|
||||||
{
|
|
||||||
Joueur.Equipe equipeJoueur = joueur.getEquipe();
|
|
||||||
|
|
||||||
for(Joueur.Equipe equipe : equipes) {
|
|
||||||
|
|
||||||
if(equipeJoueur == equipe) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -41,7 +41,7 @@ import personnage.Vampire;
|
|||||||
|
|
||||||
public class CreatingCardsTest {
|
public class CreatingCardsTest {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void init() {
|
||||||
|
|
||||||
// Lumière
|
// Lumière
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package effet;
|
|
||||||
|
|
||||||
import main.Joueur;
|
|
||||||
|
|
||||||
public class ActionAttaquer extends Action {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lance l'action d'attaquer
|
|
||||||
* @param j1 Le joueur qui attaque
|
|
||||||
* @param j2 Le joueur qui subit l'attaque
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void affecte(Joueur j1, Joueur j2) {
|
|
||||||
j1.attaquer(j2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package effet;
|
|
||||||
|
|
||||||
import main.Joueur;
|
|
||||||
|
|
||||||
public class ActionPiocher extends Action{
|
|
||||||
|
|
||||||
public ActionPiocher() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lance l'action de piocher une carte.
|
|
||||||
* @param j1 Le joueur qui lance l'action
|
|
||||||
* @param j2 Le joueur qui subit l'action
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void affecte(Joueur j1, Joueur j2) {
|
|
||||||
j2.piocher();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package effet;
|
|
||||||
|
|
||||||
import main.Equipement;
|
|
||||||
import main.Joueur;
|
|
||||||
|
|
||||||
public class ActionVoler extends Action{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lance l'action de voler une carte équipement.
|
|
||||||
* @param j1 Le joueur qui vol
|
|
||||||
* @param j2 Le joueur volé
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void affecte(Joueur j1, Joueur j2) {
|
|
||||||
|
|
||||||
Equipement[] equipements = j2.getEquipements();
|
|
||||||
|
|
||||||
// J1 choisit quel équipement voler
|
|
||||||
Equipement equipement = j1.choisir(equipements);
|
|
||||||
|
|
||||||
j1.voler(j2,equipement);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@ import java.net.URL;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import database.CreatingCardsTest;
|
||||||
import database.RessourceLoader;
|
import database.RessourceLoader;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
@@ -40,9 +41,8 @@ public class Main extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
CreatingCardsTest.init();
|
||||||
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
|
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
|
||||||
|
|
||||||
RessourceLoader rl = new RessourceLoader();
|
RessourceLoader rl = new RessourceLoader();
|
||||||
rl.loadRessources();
|
rl.loadRessources();
|
||||||
gj.setRessourceLoader(rl);
|
gj.setRessourceLoader(rl);
|
||||||
|
|||||||
@@ -626,4 +626,9 @@ public class PlateauController implements Initializable {
|
|||||||
jihm.reveler();
|
jihm.reveler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void utiliserCapacite(Joueur joueur) {
|
||||||
|
JoueurIHM jihm = getJoueurIHM(joueur);
|
||||||
|
jihm.getRevealButton().fire();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -371,4 +371,10 @@ public class GestionnaireJeu {
|
|||||||
pc.revealJoueur(joueur);
|
pc.revealJoueur(joueur);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void utiliserCapacite(Joueur joueur) {
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
pc.utiliserCapacite(joueur);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ public class JoueurVirtuel extends Joueur {
|
|||||||
res = choisirJoueurAmi(joueurs);
|
res = choisirJoueurAmi(joueurs);
|
||||||
break;
|
break;
|
||||||
case CHOISIR_VISION:
|
case CHOISIR_VISION:
|
||||||
res = joueurs.get((int) Math.floor(Math.random() * joueurs.size())); // a revoir inshallah
|
res = choisirJoueurEnnemi(joueurs); // a revoir inshallah
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = null; // faire exception?
|
res = choisirJoueurEnnemi(joueurs); // faire exception?
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import personnage.CartePersonnage.Equipe;
|
|||||||
import personnage.Franklin;
|
import personnage.Franklin;
|
||||||
import personnage.Vampire;
|
import personnage.Vampire;
|
||||||
|
|
||||||
public class Plateau extends Thread{
|
public class Plateau extends Thread {
|
||||||
|
|
||||||
private GestionnaireJeu gj;
|
private GestionnaireJeu gj;
|
||||||
private List<Joueur> joueurs;
|
private List<Joueur> joueurs;
|
||||||
@@ -55,7 +55,6 @@ public class Plateau extends Thread{
|
|||||||
joueurs.forEach(x -> x.setPlateau(this));
|
joueurs.forEach(x -> x.setPlateau(this));
|
||||||
this.joueurs = joueurs;
|
this.joueurs = joueurs;
|
||||||
|
|
||||||
|
|
||||||
this.stats.put(NB_MORTS, 0);
|
this.stats.put(NB_MORTS, 0);
|
||||||
this.stats.put(NB_MORTS_NEUTRAL, 0);
|
this.stats.put(NB_MORTS_NEUTRAL, 0);
|
||||||
this.stats.put(NB_MORTS_HUNTER, 0);
|
this.stats.put(NB_MORTS_HUNTER, 0);
|
||||||
@@ -69,13 +68,13 @@ public class Plateau extends Thread{
|
|||||||
List<CartePiochable> list1 = new ArrayList<>();
|
List<CartePiochable> list1 = new ArrayList<>();
|
||||||
List<CartePiochable> list2 = new ArrayList<>();
|
List<CartePiochable> list2 = new ArrayList<>();
|
||||||
|
|
||||||
for(int i = 0; i < 60; i++) {
|
for (int i = 0; i < 60; i++) {
|
||||||
|
|
||||||
CartePiochable carte1 = new CartePiochable(CartePiochable.Type.LUMIERE,"Eau bénite", "Soin 2");
|
CartePiochable carte1 = new CartePiochable(CartePiochable.Type.LUMIERE, "Eau bénite", "Soin 2");
|
||||||
carte1.setEffet(new EffetSelf(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_HP, 2, true)));
|
carte1.setEffet(new EffetSelf(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_HP, 2, true)));
|
||||||
list1.add(carte1);
|
list1.add(carte1);
|
||||||
|
|
||||||
CartePiochable carte2 = new CartePiochable(CartePiochable.Type.TENEBRE,"Eau maudite", "Damage 2");
|
CartePiochable carte2 = new CartePiochable(CartePiochable.Type.TENEBRE, "Eau maudite", "Damage 2");
|
||||||
carte2.setEffet(new EffetSelf(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_HP, -2, true)));
|
carte2.setEffet(new EffetSelf(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_HP, -2, true)));
|
||||||
list2.add(carte2);
|
list2.add(carte2);
|
||||||
}
|
}
|
||||||
@@ -83,15 +82,20 @@ public class Plateau extends Thread{
|
|||||||
Pioche piocheLumiere = new Pioche(list1);
|
Pioche piocheLumiere = new Pioche(list1);
|
||||||
Pioche piocheTenebre = new Pioche(list2);
|
Pioche piocheTenebre = new Pioche(list2);
|
||||||
|
|
||||||
CarteLieu lieu1 = new CarteLieuType(CartePiochable.Type.TENEBRE,"Antre de l'Ermite","desc",new Point(2,3),piocheTenebre);
|
CarteLieu lieu1 = new CarteLieuType(CartePiochable.Type.TENEBRE, "Antre de l'Ermite", "desc", new Point(2, 3),
|
||||||
CarteLieu lieu2 = new CarteLieuType(CartePiochable.Type.TENEBRE,"Cimetière","desc",new Point(-1,8),piocheTenebre);
|
piocheTenebre);
|
||||||
CarteLieu lieu3 = new CarteLieu("Forêt hantée","desc",new Point(-1,9));
|
CarteLieu lieu2 = new CarteLieuType(CartePiochable.Type.TENEBRE, "Cimetière", "desc", new Point(-1, 8),
|
||||||
lieu3.setEffet(new EffetChoisirEffet(new EffetChoisirCible(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_HP,-2,true)),
|
piocheTenebre);
|
||||||
new EffetChoisirCible(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_HP,1,true))));
|
CarteLieu lieu3 = new CarteLieu("Forêt hantée", "desc", new Point(-1, 9));
|
||||||
CarteLieu lieu4 = new CarteLieuType(CartePiochable.Type.LUMIERE,"Monastère","desc",new Point(-1,6),piocheLumiere);
|
lieu3.setEffet(new EffetChoisirEffet(
|
||||||
|
new EffetChoisirCible(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_HP, -2, true)),
|
||||||
|
new EffetChoisirCible(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_HP, 1, true))));
|
||||||
|
CarteLieu lieu4 = new CarteLieuType(CartePiochable.Type.LUMIERE, "Monastère", "desc", new Point(-1, 6),
|
||||||
|
piocheLumiere);
|
||||||
|
|
||||||
CarteLieu lieu5 = new CarteLieuType(CartePiochable.Type.TENEBRE,"Sanctuaire Ancien","desc",new Point(4,5),piocheTenebre);
|
CarteLieu lieu5 = new CarteLieuType(CartePiochable.Type.TENEBRE, "Sanctuaire Ancien", "desc", new Point(4, 5),
|
||||||
CarteLieu lieu6 = new CarteLieu("Sanctuaire Ancien","desc",new Point(-1,9));
|
piocheTenebre);
|
||||||
|
CarteLieu lieu6 = new CarteLieu("Sanctuaire Ancien", "desc", new Point(-1, 9));
|
||||||
lieu6.setEffet(new EffetChoisirCible(new ActionVoler(ActionVoler.VOLER)));
|
lieu6.setEffet(new EffetChoisirCible(new ActionVoler(ActionVoler.VOLER)));
|
||||||
|
|
||||||
List<CarteLieu> cls = new ArrayList<CarteLieu>();
|
List<CarteLieu> cls = new ArrayList<CarteLieu>();
|
||||||
@@ -104,14 +108,13 @@ public class Plateau extends Thread{
|
|||||||
|
|
||||||
List<CartePersonnage> personnages = new ArrayList<CartePersonnage>();
|
List<CartePersonnage> personnages = new ArrayList<CartePersonnage>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
for(int i = 0 ; i <3 ; i++) {
|
|
||||||
|
|
||||||
personnages.add(new Franklin());
|
personnages.add(new Franklin());
|
||||||
personnages.add(new Vampire());
|
personnages.add(new Vampire());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
personnages.add(new Allie());
|
personnages.add(new Allie());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,33 +146,31 @@ public class Plateau extends Thread{
|
|||||||
this.stats.put(NB_SHADOWS, 0);
|
this.stats.put(NB_SHADOWS, 0);
|
||||||
this.stats.put(NB_NEUTRES, 0);
|
this.stats.put(NB_NEUTRES, 0);
|
||||||
|
|
||||||
|
|
||||||
joueurs.forEach(x -> x.setPlateau(this));
|
joueurs.forEach(x -> x.setPlateau(this));
|
||||||
|
|
||||||
|
|
||||||
List<CartePiochable> lumiere = RessourceLoader.getCartesType(CartePiochable.Type.LUMIERE, cartes);
|
List<CartePiochable> lumiere = RessourceLoader.getCartesType(CartePiochable.Type.LUMIERE, cartes);
|
||||||
List<CartePiochable> tenebre = RessourceLoader.getCartesType(CartePiochable.Type.TENEBRE, cartes);
|
List<CartePiochable> tenebre = RessourceLoader.getCartesType(CartePiochable.Type.TENEBRE, cartes);
|
||||||
List<CartePiochable> vision = RessourceLoader.getCartesType(CartePiochable.Type.VISION, cartes);
|
List<CartePiochable> vision = RessourceLoader.getCartesType(CartePiochable.Type.VISION, cartes);
|
||||||
|
|
||||||
System.out.println("VISION "+vision);
|
System.out.println("VISION " + vision);
|
||||||
Map<CartePiochable.Type, List<CartePiochable>> map = new HashMap<CartePiochable.Type, List<CartePiochable>>();
|
Map<CartePiochable.Type, List<CartePiochable>> map = new HashMap<CartePiochable.Type, List<CartePiochable>>();
|
||||||
map.put(CartePiochable.Type.LUMIERE,lumiere);
|
map.put(CartePiochable.Type.LUMIERE, lumiere);
|
||||||
map.put(CartePiochable.Type.TENEBRE,tenebre);
|
map.put(CartePiochable.Type.TENEBRE, tenebre);
|
||||||
map.put(CartePiochable.Type.VISION,vision);
|
map.put(CartePiochable.Type.VISION, vision);
|
||||||
|
|
||||||
List<CarteLieu> lieux = RessourceLoader.getCartesType(cartes);
|
List<CarteLieu> lieux = RessourceLoader.getCartesType(cartes);
|
||||||
|
|
||||||
lieux.forEach(x -> {
|
lieux.forEach(x -> {
|
||||||
|
|
||||||
if(x instanceof CarteLieuType) {
|
if (x instanceof CarteLieuType) {
|
||||||
CarteLieuType clt = (CarteLieuType)x;
|
CarteLieuType clt = (CarteLieuType) x;
|
||||||
System.out.println(clt.getType());
|
System.out.println(clt.getType());
|
||||||
System.out.println("Oui "+ map.get(clt.getType()));
|
System.out.println("Oui " + map.get(clt.getType()));
|
||||||
clt.setPioche(new Pioche(map.get(clt.getType())));
|
clt.setPioche(new Pioche(map.get(clt.getType())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x instanceof CarteLieuMultiple) {
|
if (x instanceof CarteLieuMultiple) {
|
||||||
CarteLieuMultiple clm = (CarteLieuMultiple)x;
|
CarteLieuMultiple clm = (CarteLieuMultiple) x;
|
||||||
|
|
||||||
List<Pioche> lp = new ArrayList<Pioche>();
|
List<Pioche> lp = new ArrayList<Pioche>();
|
||||||
lp.add(new Pioche(map.get(CartePiochable.Type.LUMIERE)));
|
lp.add(new Pioche(map.get(CartePiochable.Type.LUMIERE)));
|
||||||
@@ -179,8 +180,6 @@ public class Plateau extends Thread{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<CartePersonnage> personnages = RessourceLoader.getCartesPersonnages(cartes);
|
List<CartePersonnage> personnages = RessourceLoader.getCartesPersonnages(cartes);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -197,29 +196,29 @@ public class Plateau extends Thread{
|
|||||||
int nbJoueurs = this.joueurs.size();
|
int nbJoueurs = this.joueurs.size();
|
||||||
List<CartePersonnage> lcp = new ArrayList<>(nbJoueurs);
|
List<CartePersonnage> lcp = new ArrayList<>(nbJoueurs);
|
||||||
|
|
||||||
switch(nbJoueurs) {
|
switch (nbJoueurs) {
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
lcp = getRandomListPersonnages(cps,2,0);
|
lcp = getRandomListPersonnages(cps, 2, 0);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
lcp = getRandomListPersonnages(cps,2,1);
|
lcp = getRandomListPersonnages(cps, 2, 1);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
lcp = getRandomListPersonnages(cps,2,2);
|
lcp = getRandomListPersonnages(cps, 2, 2);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
lcp = getRandomListPersonnages(cps,2,3);
|
lcp = getRandomListPersonnages(cps, 2, 3);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
lcp = getRandomListPersonnages(cps,3,2);
|
lcp = getRandomListPersonnages(cps, 3, 2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(lcp);
|
System.out.println(lcp);
|
||||||
for(int i = 0; i< nbJoueurs; i++) {
|
for (int i = 0; i < nbJoueurs; i++) {
|
||||||
|
|
||||||
Joueur j = joueurs.get(i);
|
Joueur j = joueurs.get(i);
|
||||||
j.setCartePersonnage(lcp.get(i));
|
j.setCartePersonnage(lcp.get(i));
|
||||||
@@ -227,7 +226,8 @@ public class Plateau extends Thread{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CartePersonnage> getRandomListPersonnages(List<CartePersonnage> cps,int nbEquipeShadowHunter, int nbNeutres) {
|
private List<CartePersonnage> getRandomListPersonnages(List<CartePersonnage> cps, int nbEquipeShadowHunter,
|
||||||
|
int nbNeutres) {
|
||||||
|
|
||||||
List<CartePersonnage> lcp = new ArrayList<CartePersonnage>();
|
List<CartePersonnage> lcp = new ArrayList<CartePersonnage>();
|
||||||
|
|
||||||
@@ -237,20 +237,19 @@ public class Plateau extends Thread{
|
|||||||
int nbHunter = nbEquipeShadowHunter;
|
int nbHunter = nbEquipeShadowHunter;
|
||||||
int nbNeutre = nbNeutres;
|
int nbNeutre = nbNeutres;
|
||||||
|
|
||||||
for(CartePersonnage cp : cps) {
|
for (CartePersonnage cp : cps) {
|
||||||
|
|
||||||
|
if (nbHunter > 0 && cp.getEquipe() == CartePersonnage.Equipe.HUNTER) {
|
||||||
if(nbHunter > 0 && cp.getEquipe() == CartePersonnage.Equipe.HUNTER) {
|
|
||||||
nbHunter--;
|
nbHunter--;
|
||||||
lcp.add(cp);
|
lcp.add(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nbNeutre > 0 && cp.getEquipe() == CartePersonnage.Equipe.NEUTRE) {
|
if (nbNeutre > 0 && cp.getEquipe() == CartePersonnage.Equipe.NEUTRE) {
|
||||||
nbNeutre--;
|
nbNeutre--;
|
||||||
lcp.add(cp);
|
lcp.add(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nbShadow > 0 && cp.getEquipe() == CartePersonnage.Equipe.SHADOW) {
|
if (nbShadow > 0 && cp.getEquipe() == CartePersonnage.Equipe.SHADOW) {
|
||||||
nbShadow--;
|
nbShadow--;
|
||||||
lcp.add(cp);
|
lcp.add(cp);
|
||||||
}
|
}
|
||||||
@@ -264,28 +263,46 @@ public class Plateau extends Thread{
|
|||||||
int nbJoueurs = this.joueurs.size();
|
int nbJoueurs = this.joueurs.size();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while(!isPartieTerminee()) {
|
while (!isPartieTerminee()) {
|
||||||
|
|
||||||
Joueur currentJoueur = this.joueurs.get(i % nbJoueurs);
|
Joueur currentJoueur = this.joueurs.get(i % nbJoueurs);
|
||||||
|
|
||||||
if(!currentJoueur.isDead()) {
|
if (!currentJoueur.isDead()) {
|
||||||
|
if (currentJoueur instanceof JoueurVirtuel) {
|
||||||
deplacer(currentJoueur);
|
if (checkrevealIAtour((JoueurVirtuel) currentJoueur))
|
||||||
if(isPartieTerminee()) break;
|
currentJoueur.reveal();
|
||||||
gj.afficherLieu(currentJoueur);
|
currentJoueur.utiliserCapacite();
|
||||||
|
|
||||||
if(currentJoueur.choisir(Contexte.ACTIVER_EFFET_LIEU)) {
|
|
||||||
currentJoueur.utiliserEffetLieu();
|
|
||||||
if(isPartieTerminee()) break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentJoueur.choisir(Contexte.ATTAQUER)){
|
deplacer(currentJoueur);
|
||||||
if(currentJoueur.hasOpponents()) {
|
if (isPartieTerminee())
|
||||||
|
break;
|
||||||
|
gj.afficherLieu(currentJoueur);
|
||||||
|
|
||||||
|
if (currentJoueur.choisir(Contexte.ACTIVER_EFFET_LIEU)) {
|
||||||
|
currentJoueur.utiliserEffetLieu();
|
||||||
|
if (isPartieTerminee())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentJoueur.choisir(Contexte.ATTAQUER)) {
|
||||||
|
if (currentJoueur.hasOpponents()) {
|
||||||
List<Joueur> adjacents = currentJoueur.getJoueursRange();
|
List<Joueur> adjacents = currentJoueur.getJoueursRange();
|
||||||
Joueur cible = (Joueur) currentJoueur.choisir(adjacents,Contexte.ATTAQUER);
|
Joueur cible = (Joueur) currentJoueur.choisir(adjacents, Contexte.ATTAQUER);
|
||||||
attaquer(currentJoueur,cible);
|
if (currentJoueur instanceof JoueurVirtuel) {
|
||||||
if(isPartieTerminee()) break;
|
if (checkrevealIAattaque((JoueurVirtuel) currentJoueur, cible))
|
||||||
}else {
|
currentJoueur.reveal();
|
||||||
|
currentJoueur.utiliserCapacite();
|
||||||
|
}
|
||||||
|
if (currentJoueur instanceof JoueurVirtuel) {
|
||||||
|
if (checkrevealIAattaquee((JoueurVirtuel) cible, currentJoueur))
|
||||||
|
cible.reveal();
|
||||||
|
cible.utiliserCapacite();
|
||||||
|
}
|
||||||
|
attaquer(currentJoueur, cible);
|
||||||
|
if (isPartieTerminee())
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
System.out.println("Il n'y a personne a attaquer.");
|
System.out.println("Il n'y a personne a attaquer.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,27 +313,78 @@ public class Plateau extends Thread{
|
|||||||
List<Joueur> gagnants = new ArrayList<Joueur>();
|
List<Joueur> gagnants = new ArrayList<Joueur>();
|
||||||
|
|
||||||
System.out.println(this.stats);
|
System.out.println(this.stats);
|
||||||
for(Joueur j : joueurs) {
|
for (Joueur j : joueurs) {
|
||||||
if(j.victoire()) {
|
if (j.victoire()) {
|
||||||
gagnants.add(j);
|
gagnants.add(j);
|
||||||
System.out.println("CartePersonnage "+j.getCartePersonnage()+" Stats "+j.getStats());
|
System.out.println("CartePersonnage " + j.getCartePersonnage() + " Stats " + j.getStats());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkrevealIAtour(JoueurVirtuel jIA) {
|
||||||
|
ControleurIA cIA = new ControleurIA();
|
||||||
|
switch (jIA.getCartePersonnage().getNom()) {
|
||||||
|
case "ALLIE":
|
||||||
|
return cIA.devoilerIAAllie(jIA);
|
||||||
|
case "DANIEL":
|
||||||
|
return false;
|
||||||
|
case "FRANKLIN":
|
||||||
|
return cIA.devoilerIAFranklin(jIA, joueurs);
|
||||||
|
case "GEORGES":
|
||||||
|
return cIA.devoilerIAGeorges(jIA, joueurs);
|
||||||
|
case "EMI":
|
||||||
|
return cIA.devoilerIAEmi(jIA, jIA.getCarteLieu());
|
||||||
|
case "METAMORPHE":
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkrevealIAattaque(JoueurVirtuel jIA, Joueur jAttaquee) {
|
||||||
|
ControleurIA cIA = new ControleurIA();
|
||||||
|
switch (jIA.getCartePersonnage().getNom()) {
|
||||||
|
case "ALLIE":
|
||||||
|
return cIA.devoilerIAAllie(jIA);
|
||||||
|
case "BOB":
|
||||||
|
return cIA.devoilerIABob(jIA, jAttaquee);
|
||||||
|
case "VAMPIRE":
|
||||||
|
return cIA.devoilerIAVampire(jIA, jAttaquee);
|
||||||
|
case "CHARLES":
|
||||||
|
return cIA.devoilerIACharles(jIA, jAttaquee);
|
||||||
|
case "FRANKLIN":
|
||||||
|
return cIA.devoilerIAFranklin(jIA, joueurs);
|
||||||
|
case "GEORGES":
|
||||||
|
return cIA.devoilerIAGeorges(jIA, joueurs);
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkrevealIAattaquee(JoueurVirtuel jIA, Joueur jAttaquant) {
|
||||||
|
ControleurIA cIA = new ControleurIA();
|
||||||
|
switch (jIA.getCartePersonnage().getNom()) {
|
||||||
|
case "LOUP-GAROU":
|
||||||
|
return cIA.devoilerIALoupGarou(jIA, jAttaquant);
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPartieTerminee() {
|
public boolean isPartieTerminee() {
|
||||||
return this.getStat(PARTIE_FINIE) == 1;
|
return false;
|
||||||
|
// return this.getStat(PARTIE_FINIE) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deplacer(Joueur currentJoueur) {
|
public void deplacer(Joueur currentJoueur) {
|
||||||
|
|
||||||
boolean attributed = false;
|
boolean attributed = false;
|
||||||
|
|
||||||
while(!attributed) {
|
while (!attributed) {
|
||||||
int roll = sumRolls(currentJoueur);
|
int roll = sumRolls(currentJoueur);
|
||||||
|
|
||||||
for(CarteLieu cl : lieux) {
|
for (CarteLieu cl : lieux) {
|
||||||
if(cl.coordinatesContains(roll) && currentJoueur.getCarteLieu() != cl){
|
if (cl.coordinatesContains(roll) && currentJoueur.getCarteLieu() != cl) {
|
||||||
currentJoueur.deplacer(cl);
|
currentJoueur.deplacer(cl);
|
||||||
attributed = true;
|
attributed = true;
|
||||||
break;
|
break;
|
||||||
@@ -330,11 +398,11 @@ public class Plateau extends Thread{
|
|||||||
|
|
||||||
int attaque = diffRolls(joueur1);
|
int attaque = diffRolls(joueur1);
|
||||||
|
|
||||||
if(attaque != 0) {
|
if (attaque != 0) {
|
||||||
System.out.println(joueur1.getNom()+" attaque "+joueur2.getNom());
|
System.out.println(joueur1.getNom() + " attaque " + joueur2.getNom());
|
||||||
System.out.println(joueur2.getNom()+" a "+joueur2.getStat(Joueur.PLAYER_HP)+" pv");
|
System.out.println(joueur2.getNom() + " a " + joueur2.getStat(Joueur.PLAYER_HP) + " pv");
|
||||||
joueur1.attaquer(joueur2,attaque);
|
joueur1.attaquer(joueur2, attaque);
|
||||||
System.out.println(joueur2.getNom()+" passe à "+joueur2.getStat(Joueur.PLAYER_HP)+" pv");
|
System.out.println(joueur2.getNom() + " passe à " + joueur2.getStat(Joueur.PLAYER_HP) + " pv");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,10 +412,10 @@ public class Plateau extends Thread{
|
|||||||
|
|
||||||
public int diffRolls(Joueur j) {
|
public int diffRolls(Joueur j) {
|
||||||
|
|
||||||
int roll4 =rollRandom(4);
|
int roll4 = rollRandom(4);
|
||||||
int roll6 = rollRandom(6);
|
int roll6 = rollRandom(6);
|
||||||
gj.rollDice(j, PlateauController.DICE_BOTH, roll4,roll6);
|
gj.rollDice(j, PlateauController.DICE_BOTH, roll4, roll6);
|
||||||
return Math.abs(roll4-roll6);
|
return Math.abs(roll4 - roll6);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int roll4(Joueur j) {
|
public int roll4(Joueur j) {
|
||||||
@@ -365,22 +433,21 @@ public class Plateau extends Thread{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int rollRandom(int nb) {
|
private int rollRandom(int nb) {
|
||||||
Random r= new Random();
|
Random r = new Random();
|
||||||
int roll = r.nextInt(nb)+1;
|
int roll = r.nextInt(nb) + 1;
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int sumRolls(Joueur j)
|
public int sumRolls(Joueur j) {
|
||||||
{
|
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
int roll4 = 0;
|
int roll4 = 0;
|
||||||
int roll6 = 0;
|
int roll6 = 0;
|
||||||
|
|
||||||
roll4 = rollRandom(4);
|
roll4 = rollRandom(4);
|
||||||
roll6 = rollRandom(6);
|
roll6 = rollRandom(6);
|
||||||
sum = Math.abs(roll4+roll6);
|
sum = Math.abs(roll4 + roll6);
|
||||||
|
|
||||||
gj.rollDice(j, PlateauController.DICE_BOTH, roll4,roll6);
|
gj.rollDice(j, PlateauController.DICE_BOTH, roll4, roll6);
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,25 +461,24 @@ public class Plateau extends Thread{
|
|||||||
|
|
||||||
public int getStat(String key) {
|
public int getStat(String key) {
|
||||||
|
|
||||||
if(this.stats.containsKey(key))
|
if (this.stats.containsKey(key)) {
|
||||||
{
|
|
||||||
return this.stats.get(key);
|
return this.stats.get(key);
|
||||||
}else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shuffleLieux(){
|
public void shuffleLieux() {
|
||||||
|
|
||||||
this.lieux.forEach(x -> x.setVoisin(null));
|
this.lieux.forEach(x -> x.setVoisin(null));
|
||||||
|
|
||||||
if(lieux.size() % 2 == 0) {
|
if (lieux.size() % 2 == 0) {
|
||||||
|
|
||||||
Collections.shuffle(lieux);
|
Collections.shuffle(lieux);
|
||||||
|
|
||||||
for(int i = 0; i < lieux.size(); i += 2) {
|
for (int i = 0; i < lieux.size(); i += 2) {
|
||||||
lieux.get(i).setVoisin(lieux.get(i+1));
|
lieux.get(i).setVoisin(lieux.get(i + 1));
|
||||||
lieux.get(i+1).setVoisin(lieux.get(i));
|
lieux.get(i + 1).setVoisin(lieux.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,7 +492,6 @@ public class Plateau extends Thread{
|
|||||||
return this.lieux;
|
return this.lieux;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean choisir(Joueur joueur, Contexte contexte) {
|
public boolean choisir(Joueur joueur, Contexte contexte) {
|
||||||
return gj.choisir(joueur, contexte);
|
return gj.choisir(joueur, contexte);
|
||||||
}
|
}
|
||||||
@@ -443,13 +508,12 @@ public class Plateau extends Thread{
|
|||||||
return (Joueur) gj.choisir(joueur, joueurs, Joueur.class);
|
return (Joueur) gj.choisir(joueur, joueurs, Joueur.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void removeDeads(List<Joueur> joueurs) {
|
private void removeDeads(List<Joueur> joueurs) {
|
||||||
|
|
||||||
List<Joueur> toRemove = new ArrayList<Joueur>();
|
List<Joueur> toRemove = new ArrayList<Joueur>();
|
||||||
for(Joueur j : joueurs) {
|
for (Joueur j : joueurs) {
|
||||||
|
|
||||||
if(j.isDead()) {
|
if (j.isDead()) {
|
||||||
toRemove.add(j);
|
toRemove.add(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,25 +529,25 @@ public class Plateau extends Thread{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateVieJoueur(Joueur joueur, int damage) {
|
public void updateVieJoueur(Joueur joueur, int damage) {
|
||||||
gj.updateVieJoueur(joueur,damage);
|
gj.updateVieJoueur(joueur, damage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object choisir(Joueur joueur, List<?> list, Class cls) {
|
public Object choisir(Joueur joueur, List<?> list, Class cls) {
|
||||||
return gj.choisir(joueur,list,cls);
|
return gj.choisir(joueur, list, cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alerationVie(Joueur joueur, int valeur) {
|
public void alerationVie(Joueur joueur, int valeur) {
|
||||||
gj.alterationVie(joueur,valeur);
|
gj.alterationVie(joueur, valeur);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ajouterEquipementIHM(Joueur joueur, CarteEquipement e) {
|
public void ajouterEquipementIHM(Joueur joueur, CarteEquipement e) {
|
||||||
gj.ajouterEquipement(joueur,e);
|
gj.ajouterEquipement(joueur, e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retirerEquipementIHM(Joueur joueur, CarteEquipement e) {
|
public void retirerEquipementIHM(Joueur joueur, CarteEquipement e) {
|
||||||
gj.retirerEquipement(joueur,e);
|
gj.retirerEquipement(joueur, e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,33 +559,34 @@ public class Plateau extends Thread{
|
|||||||
|
|
||||||
Equipe ej = joueur.getEquipe();
|
Equipe ej = joueur.getEquipe();
|
||||||
|
|
||||||
switch(ej) {
|
switch (ej) {
|
||||||
case SHADOW:
|
case SHADOW:
|
||||||
this.updateStat(NB_MORTS_SHADOW,1,true);
|
this.updateStat(NB_MORTS_SHADOW, 1, true);
|
||||||
break;
|
break;
|
||||||
case HUNTER:
|
case HUNTER:
|
||||||
this.updateStat(NB_MORTS_HUNTER,1,true);
|
this.updateStat(NB_MORTS_HUNTER, 1, true);
|
||||||
break;
|
break;
|
||||||
case NEUTRE:
|
case NEUTRE:
|
||||||
this.updateStat(NB_MORTS_NEUTRAL,1,true);
|
this.updateStat(NB_MORTS_NEUTRAL, 1, true);
|
||||||
break;}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
this.updateStat(NB_MORTS,1,true);
|
this.updateStat(NB_MORTS, 1, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStat(String key , int value, boolean ajouter) {
|
private void updateStat(String key, int value, boolean ajouter) {
|
||||||
if(ajouter) {
|
if (ajouter) {
|
||||||
int valeurBase = this.getStat(key);
|
int valeurBase = this.getStat(key);
|
||||||
this.setStat(key, valeurBase+value);
|
this.setStat(key, valeurBase + value);
|
||||||
}else {
|
} else {
|
||||||
this.setStat(key, value);
|
this.setStat(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void victoire(Joueur joueur) {
|
public void victoire(Joueur joueur) {
|
||||||
if(joueur.victoire()) {
|
if (joueur.victoire()) {
|
||||||
this.updateStat(PARTIE_FINIE, 1, false);
|
this.updateStat(PARTIE_FINIE, 1, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user