Ajout des capacités spéciales

This commit is contained in:
Paul Gross
2020-05-13 10:35:38 +02:00
parent 80f7266ffb
commit dc3414c023
7 changed files with 146 additions and 112 deletions

View File

@@ -24,6 +24,8 @@ public class GestionnaireJeu {
private Map<Integer, Joueur> mapJoueurs;
private RessourceLoader ressourceLoader;
private static Thread lastThread;
private static Plateau plateau;
public static PlateauController pc;
@@ -165,34 +167,14 @@ public class GestionnaireJeu {
this.waitPlateau();
}
public int jouerDes(Joueur joueur, Contexte c) {
public void rollDice(Joueur joueur, int typeDice, int ... rolls){
Platform.runLater(() -> {
try {
pc.afficherLancerDes(joueur, c);
} catch (IOException e) {
e.printStackTrace();
}
pc.rollDice(joueur,typeDice,rolls, null);
});
this.waitPlateau();
final FutureTask<Integer> query = new FutureTask<Integer>(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return pc.getChoixLancerDes(joueur);
}
});
Platform.runLater(query);
try {
return query.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
return 1;
}
public Joueur choisirJoueur(Joueur joueur, List<Joueur> joueurs, Contexte contexte) {
@@ -226,10 +208,10 @@ public class GestionnaireJeu {
return null;
}
public void waitPlateau() {
Thread currentThread = Thread.currentThread();
synchronized(currentThread) {
lastThread = Thread.currentThread();
synchronized(lastThread) {
try {
currentThread.wait();
lastThread.wait();
} catch (InterruptedException e) {
}
@@ -237,9 +219,10 @@ public class GestionnaireJeu {
}
public static void notifyPlateau() {
synchronized(plateau) {
plateau.notify();
synchronized(lastThread) {
lastThread.notify();
}
lastThread = null;
}
public Type choisirCarte(Joueur joueur) {
@@ -272,10 +255,7 @@ public class GestionnaireJeu {
return null;
}
public void rollDice(Joueur joueur, int typeDice, int ... rolls){
pc.rollDice(joueur,typeDice,rolls);
}
public void setConfiguration(Configuration c) {

View File

@@ -68,10 +68,6 @@ public class Joueur {
this.stats.put(key, valeur);
}
public void setStat(String key, int valeur) {
System.out.println(this.nom+" "+this);
if(key.contentEquals(PLAYER_HP)) {
this.plateau.alerationVie(this,valeur);
}
this.stats.put(key, valeur);
updateVictoirePlateau();
updateVie();
@@ -112,7 +108,6 @@ public class Joueur {
}
public int getStat(String key) {
if(stats.containsKey(key)) {
return stats.get(key);
}else {
@@ -164,6 +159,9 @@ public class Joueur {
public void addToStat(String key, int valeur)
{
int valeurBase = this.getStat(key);
if(key.contentEquals(PLAYER_HP)) {
this.plateau.alerationVie(this,valeur);
}
this.setStat(key,valeurBase+valeur);
}
@@ -189,8 +187,6 @@ public class Joueur {
this.plateau = plateau2;
}
public void utiliserEffetLieu() {
this.carteLieu.utiliser(this);
}
@@ -246,10 +242,6 @@ public class Joueur {
return this.plateau.choisir(this, activerEffetLieu);
}
public int lancerDes(Contexte typeLancer) {
return this.plateau.lancerDes(this, typeLancer);
}
public Object choisir(List<?> list,Class cls) {
return this.plateau.choisir(this,list, cls);
}
@@ -271,14 +263,10 @@ public class Joueur {
this.plateau.retirerEquipementIHM(this,e);
}
public void utiliserCapacite() {
if(revele) {
this.cartePersonnage.utiliser();
}
}
}

View File

@@ -266,9 +266,7 @@ public class Plateau extends Thread{
System.out.println(joueurs.size());
Joueur currentJoueur = this.joueurs.get(i % nbJoueurs);
int lancer = currentJoueur.lancerDes(Contexte.LANCER_DES_4);
System.out.println("\n\n\n\n\n");
System.out.println(lancer);
System.out.println("Au tour de "+currentJoueur.getNom());
System.out.println("Lancement des dés.");
deplacer(currentJoueur);
@@ -356,7 +354,6 @@ public class Plateau extends Thread{
int roll4 =rollRandom(4);
int roll6 = rollRandom(6);
gj.rollDice(j, PlateauController.DICE_BOTH, roll4,roll6);
return Math.abs(roll4-roll6);
}
@@ -383,7 +380,12 @@ public class Plateau extends Thread{
public int sumRolls(Joueur j)
{
return roll6(j) + roll4(j);
int roll4 =rollRandom(4);
int roll6 = rollRandom(6);
int sum = Math.abs(roll4+roll6);
gj.rollDice(j, PlateauController.DICE_BOTH, roll4,roll6);
return 3;
//return Math.abs(roll4+roll6);
}
public List<Joueur> getJoueurs() {
@@ -477,8 +479,4 @@ public class Plateau extends Thread{
gj.retirerEquipement(joueur,e);
}
public int lancerDes(Joueur joueur, Contexte typeLancer) {
return gj.jouerDes(joueur, typeLancer);
}
}