Prise en compte des zones joueurs
This commit is contained in:
parent
861b66f439
commit
2ab87b04b2
@ -9,11 +9,11 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import main.GestionnaireJeu;
|
||||
|
||||
public class Main extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
System.out.println("Lancement de l'application");
|
||||
|
||||
final URL fxmlURL = getClass().getResource("ressources/parametre.fxml"); // "ressources/Jouer_tour(1)lancer_des.fxml"
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
@ -28,6 +28,8 @@ public class Main extends Application {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
|
||||
launch(args);
|
||||
|
||||
}
|
||||
}
|
22
src/ihm/ZoneJoueurThread.java
Normal file
22
src/ihm/ZoneJoueurThread.java
Normal file
@ -0,0 +1,22 @@
|
||||
package ihm;
|
||||
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
public class ZoneJoueurThread extends Thread {
|
||||
|
||||
private boolean finished;
|
||||
|
||||
|
||||
|
||||
public ZoneJoueurThread(AnchorPane anchorPane, Pane pane) {
|
||||
this.finished = false;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while(!finished) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,43 +1,42 @@
|
||||
package ihm.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import ihm.PopUpBoolean;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import main.GestionnaireJeu;
|
||||
|
||||
public class ChoisirBoolean implements Initializable {
|
||||
|
||||
public class ChoisirBoolean implements Initializable{
|
||||
@FXML private Pane rootPane;
|
||||
|
||||
@FXML private Button ouiButton;
|
||||
@FXML private Button nonButton;
|
||||
|
||||
private boolean result;
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
|
||||
ouiButton.setOnAction(x -> {
|
||||
|
||||
this.result = true;
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
|
||||
});
|
||||
|
||||
nonButton.setOnAction(x -> {
|
||||
|
||||
this.result = false;
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void choixOui(MouseEvent mouseEvent) throws IOException{
|
||||
PopUpBoolean.result = true;
|
||||
final Node source = (Node) mouseEvent.getSource();
|
||||
final Stage stage = (Stage) source.getScene().getWindow();
|
||||
stage.close();
|
||||
public boolean getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void choixNon(MouseEvent mouseEvent) throws IOException{
|
||||
|
||||
PopUpBoolean.result = false;
|
||||
final Node source = (Node) mouseEvent.getSource();
|
||||
final Stage stage = (Stage) source.getScene().getWindow();
|
||||
stage.close();
|
||||
}
|
||||
}
|
||||
|
@ -18,19 +18,19 @@ public class JoueurIHM {
|
||||
|
||||
private int position;
|
||||
private Joueur joueur;
|
||||
private Pane pane;
|
||||
private Pane zoneJoueur;
|
||||
private GestionnaireDePions gestionnaireDePions;
|
||||
private Color color;
|
||||
|
||||
public JoueurIHM(int i, Joueur joueur, Pane pane, Color color, GridPane gridPaneVie) {
|
||||
public JoueurIHM(int i, Joueur joueur, Pane zoneJoueur, Color color, GridPane gridPaneVie) {
|
||||
|
||||
this.setPosition(i);
|
||||
this.setJoueur(joueur);
|
||||
this.pane = pane;
|
||||
this.zoneJoueur = zoneJoueur;
|
||||
this.color = color;
|
||||
this.gestionnaireDePions = new GestionnaireDePions(this.color,gridPaneVie);
|
||||
|
||||
pane.setBorder(new Border(new BorderStroke(color, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(5))));
|
||||
zoneJoueur.setBorder(new Border(new BorderStroke(color, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(5))));
|
||||
|
||||
String name = joueur.getNom();
|
||||
setLabelJoueur(name);
|
||||
@ -53,21 +53,32 @@ public class JoueurIHM {
|
||||
}
|
||||
|
||||
public Button getRevealButton() {
|
||||
Pane p = (Pane) pane.getChildren().get(1);
|
||||
Pane p = (Pane) zoneJoueur.getChildren().get(1);
|
||||
return (Button) p.getChildren().get(1);
|
||||
}
|
||||
|
||||
public ImageView getCartePersonnage() {
|
||||
Pane p = (Pane) pane.getChildren().get(1);
|
||||
Pane p = (Pane) zoneJoueur.getChildren().get(1);
|
||||
return (ImageView) p.getChildren().get(0);
|
||||
}
|
||||
|
||||
public AnchorPane getZoneJoueur() {
|
||||
return (AnchorPane) pane.getChildren().get(0);
|
||||
return (AnchorPane) zoneJoueur.getChildren().get(0);
|
||||
}
|
||||
|
||||
public void setZoneJoueur(Pane p) {
|
||||
AnchorPane ap = (AnchorPane) zoneJoueur.getChildren().get(0);
|
||||
ap.getChildren().setAll(p);
|
||||
AnchorPane.getBottomAnchor(p);
|
||||
AnchorPane.getLeftAnchor(p);
|
||||
AnchorPane.getRightAnchor(p);
|
||||
AnchorPane.getTopAnchor(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Label getLabelJoueur() {
|
||||
Pane p = (Pane) pane.getChildren().get(2);
|
||||
Pane p = (Pane) zoneJoueur.getChildren().get(2);
|
||||
return (Label) p.getChildren().get(0);
|
||||
}
|
||||
|
||||
@ -77,7 +88,7 @@ public class JoueurIHM {
|
||||
}
|
||||
|
||||
public Label getPaneEquipement() {
|
||||
Pane p = (Pane) pane.getChildren().get(2);
|
||||
Pane p = (Pane) zoneJoueur.getChildren().get(2);
|
||||
return (Label) p.getChildren().get(1);
|
||||
}
|
||||
|
||||
@ -101,4 +112,9 @@ public class JoueurIHM {
|
||||
this.gestionnaireDePions.deplacerPionVie(damage);
|
||||
}
|
||||
|
||||
public void choisir() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import ihm.PopUp;
|
||||
import ihm.PopUpBoolean;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
@ -209,15 +209,18 @@ public class PlateauController implements Initializable {
|
||||
popup.display();
|
||||
}
|
||||
|
||||
public boolean choisir(Joueur j) throws IOException {
|
||||
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("../ressources/choisirBoolean.fxml"));
|
||||
Parent root = loader.load();
|
||||
|
||||
PopUpBoolean popup = new PopUpBoolean(root, "Consulter sa carte");
|
||||
return popup.display();
|
||||
public JoueurIHM getJoueurIHM(Joueur j) {
|
||||
|
||||
for(JoueurIHM joueurIHM : joueursIHM) {
|
||||
if(joueurIHM.getJoueur().equals(j)) return joueurIHM;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permet de consulter sa carte perssonage en cas d'oublie
|
||||
*
|
||||
@ -260,4 +263,19 @@ public class PlateauController implements Initializable {
|
||||
|
||||
}
|
||||
|
||||
public void afficherChoisir(Joueur j) throws IOException {
|
||||
final URL fxmlURL = getClass().getResource("../ressources/choisirBoolean.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
Pane root = (Pane)fxmlLoader.load();
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.setZoneJoueur(root);
|
||||
|
||||
}
|
||||
|
||||
public boolean getChoix(Joueur joueur) {
|
||||
JoueurIHM jihm = getJoueurIHM(joueur);
|
||||
jihm.getZoneJoueur().getChildren().setAll();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -138,7 +138,7 @@ public class PlayersController implements Initializable{
|
||||
Stage appStage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow();
|
||||
appStage.setScene(scene);
|
||||
appStage.show();
|
||||
//GestionnaireJeu.lancerPartie();
|
||||
gj.lancerPartie();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,20 +5,19 @@
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="334.0" prefWidth="449.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ChoisirBoolean">
|
||||
<AnchorPane fx:id="root" minHeight="0.0" minWidth="0.0" prefHeight="334.0" prefWidth="449.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ChoisirBoolean">
|
||||
<children>
|
||||
<Label layoutX="8.0" layoutY="32.0" text="Voulez vous faire cette action ?" AnchorPane.bottomAnchor="215.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="7.0" AnchorPane.topAnchor="32.0">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button fx:id="ouiButton" layoutX="68.0" layoutY="147.0" mnemonicParsing="false" onMouseClicked="#choixOui" text="Oui" AnchorPane.bottomAnchor="71.0" AnchorPane.leftAnchor="68.0" AnchorPane.rightAnchor="268.0" AnchorPane.topAnchor="147.0" />
|
||||
<Button fx:id="ouiButton" layoutX="68.0" layoutY="147.0" mnemonicParsing="false" text="Oui" AnchorPane.bottomAnchor="71.0" AnchorPane.leftAnchor="68.0" AnchorPane.rightAnchor="268.0" AnchorPane.topAnchor="147.0" />
|
||||
<Label layoutX="377.0" layoutY="245.0" AnchorPane.bottomAnchor="187.0" AnchorPane.leftAnchor="181.0" AnchorPane.rightAnchor="312.0" AnchorPane.topAnchor="60.0">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button fx:id="nonButton" layoutX="286.0" layoutY="147.0" mnemonicParsing="false" onMouseClicked="#choixNon" text="Non" AnchorPane.bottomAnchor="71.0" AnchorPane.leftAnchor="286.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="147.0" />
|
||||
<Button fx:id="nonButton" layoutX="286.0" layoutY="147.0" mnemonicParsing="false" text="Non" AnchorPane.bottomAnchor="71.0" AnchorPane.leftAnchor="286.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="147.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
@ -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 {
|
||||
return pc.choisir(joueur);
|
||||
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 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,19 +2,24 @@ package main;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ihm.controller.PlateauController;
|
||||
|
||||
public class View{
|
||||
|
||||
private PlateauController plateauController;
|
||||
|
||||
public static void initPartie(List<Joueur> joueurs) {
|
||||
public View() {
|
||||
|
||||
}
|
||||
|
||||
public static void lancerPartie() {
|
||||
|
||||
public void setPlateauController(PlateauController plateauController) {
|
||||
this.plateauController = plateauController;
|
||||
}
|
||||
|
||||
public static void menu() throws Exception {
|
||||
|
||||
public void afficherChoisir(Joueur j) throws Exception {
|
||||
if(this.plateauController != null) {
|
||||
//this.plateauController.afficherChoisir(j);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyConfiguration(Configuration c) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user