Prise en compte des zones joueurs
This commit is contained in:
@@ -4,9 +4,13 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import effet.Effet;
|
||||
import ihm.controller.PlateauController;
|
||||
import javafx.application.Platform;
|
||||
|
||||
public class GestionnaireJeu {
|
||||
|
||||
@@ -16,12 +20,12 @@ public class GestionnaireJeu {
|
||||
|
||||
private Map<Integer, Joueur> mapJoueurs;
|
||||
|
||||
private Plateau plateau;
|
||||
private PlateauController pc;
|
||||
private static Plateau plateau;
|
||||
private static PlateauController pc;
|
||||
|
||||
private GestionnaireJeu() {}
|
||||
|
||||
public static synchronized GestionnaireJeu getGestionnaireJeu(){
|
||||
public static GestionnaireJeu getGestionnaireJeu(){
|
||||
if(gj == null){
|
||||
gj = new GestionnaireJeu();
|
||||
}
|
||||
@@ -34,7 +38,7 @@ public class GestionnaireJeu {
|
||||
}
|
||||
|
||||
public void lancerPartie() {
|
||||
this.plateau.jeu();
|
||||
plateau.start();
|
||||
}
|
||||
|
||||
public void jouer(Configuration c) {
|
||||
@@ -60,15 +64,62 @@ public class GestionnaireJeu {
|
||||
}
|
||||
|
||||
public boolean choisir(Joueur joueur) {
|
||||
|
||||
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
pc.afficherChoisir(joueur);
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.waitPlateau();
|
||||
|
||||
final FutureTask<Boolean> query = new FutureTask<Boolean>(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
return pc.getChoix(joueur);
|
||||
}
|
||||
});
|
||||
|
||||
Platform.runLater(query);
|
||||
|
||||
try {
|
||||
return pc.choisir(joueur);
|
||||
} catch (IOException e) {
|
||||
return query.get().booleanValue();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Platform.runLater(() -> {
|
||||
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void waitPlateau() {
|
||||
|
||||
synchronized(plateau) {
|
||||
try {
|
||||
plateau.wait();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void notifyPlateau() {
|
||||
|
||||
synchronized(plateau) {
|
||||
plateau.notify();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void rollDice(Joueur joueur, int typeDice, int ... rolls){
|
||||
|
||||
pc.rollDice(joueur,typeDice,rolls);
|
||||
@@ -103,4 +154,6 @@ public class GestionnaireJeu {
|
||||
this.pc = pc2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import personnage.CartePersonnage;
|
||||
import personnage.Franklin;
|
||||
import personnage.Vampire;
|
||||
|
||||
public class Plateau {
|
||||
public class Plateau extends Thread{
|
||||
|
||||
private GestionnaireJeu gj;
|
||||
private List<Joueur> joueurs;
|
||||
@@ -121,6 +121,7 @@ public class Plateau {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void initCartePersonnage(List<CartePersonnage> cps) throws Exception {
|
||||
|
||||
|
||||
@@ -167,8 +168,6 @@ public class Plateau {
|
||||
int nbHunter = nbEquipeShadowHunter;
|
||||
int nbNeutre = nbNeutres;
|
||||
|
||||
|
||||
|
||||
for(CartePersonnage cp : cps) {
|
||||
|
||||
|
||||
@@ -190,11 +189,11 @@ public class Plateau {
|
||||
return lcp;
|
||||
}
|
||||
|
||||
public void jeu() {
|
||||
public void run() {
|
||||
|
||||
int nbJoueurs = this.joueurs.size()-1;
|
||||
int i = 1;
|
||||
|
||||
System.out.println(nbJoueurs);
|
||||
while(true) {
|
||||
|
||||
Joueur currentJoueur = this.joueurs.get(nbJoueurs % i);
|
||||
|
||||
@@ -2,21 +2,26 @@ package main;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ihm.controller.PlateauController;
|
||||
|
||||
public class View{
|
||||
|
||||
private PlateauController plateauController;
|
||||
|
||||
public static void initPartie(List<Joueur> joueurs) {
|
||||
|
||||
}
|
||||
|
||||
public static void lancerPartie() {
|
||||
|
||||
}
|
||||
|
||||
public static void menu() throws Exception {
|
||||
public View() {
|
||||
|
||||
}
|
||||
|
||||
public void setPlateauController(PlateauController plateauController) {
|
||||
this.plateauController = plateauController;
|
||||
}
|
||||
|
||||
public void afficherChoisir(Joueur j) throws Exception {
|
||||
if(this.plateauController != null) {
|
||||
//this.plateauController.afficherChoisir(j);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyConfiguration(Configuration c) {
|
||||
|
||||
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
|
||||
|
||||
Reference in New Issue
Block a user