From 51b6e80e45bd534e8664a19673b2d9ef8539ba62 Mon Sep 17 00:00:00 2001 From: Paul Gross Date: Fri, 24 Apr 2020 10:09:30 +0200 Subject: [PATCH] Demo Rey --- src/carte/CarteCondition.java | 7 +- src/carte/CarteLieu.java | 4 + src/ihm/Main.java | 2 - src/ihm/PopUp.java | 15 +-- src/ihm/PopUpBoolean.java | 75 ++++++++++++++ src/ihm/controller/ChoisirBoolean.java | 45 ++++++++ src/ihm/controller/MenuController.java | 3 +- src/ihm/controller/PlateauController.java | 26 ++++- src/ihm/controller/PlayersController.java | 15 ++- src/ihm/ressources/choisirBoolean.fxml | 23 +++++ src/main/Configuration.java | 38 ++++--- src/main/GestionnaireJeu.java | 57 +++++++--- src/main/Joueur.java | 28 +++-- src/main/Plateau.java | 120 ++++++++++++++++++++-- 14 files changed, 386 insertions(+), 72 deletions(-) create mode 100644 src/ihm/PopUpBoolean.java create mode 100644 src/ihm/controller/ChoisirBoolean.java create mode 100644 src/ihm/ressources/choisirBoolean.fxml diff --git a/src/carte/CarteCondition.java b/src/carte/CarteCondition.java index 313e6e4..a42d513 100644 --- a/src/carte/CarteCondition.java +++ b/src/carte/CarteCondition.java @@ -18,7 +18,12 @@ public abstract class CarteCondition extends CarteEffet{ */ @Override public void utiliser(Joueur j) { - if(this.condition.isTrue(j)) { + if(this.condition != null) { + + if(this.condition.isTrue(j)) { + super.utiliser(j); + } + }else { super.utiliser(j); } } diff --git a/src/carte/CarteLieu.java b/src/carte/CarteLieu.java index 841b8af..0c45102 100644 --- a/src/carte/CarteLieu.java +++ b/src/carte/CarteLieu.java @@ -55,6 +55,10 @@ public class CarteLieu extends CarteEffet{ return this.coordinates; } + public void ajouterJoueur(Joueur joueur) { + this.listeJoueurs.add(joueur); + } + diff --git a/src/ihm/Main.java b/src/ihm/Main.java index 564545f..665db62 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -21,6 +21,4 @@ public class Main extends Application{ public static void main(String[] args) { launch(args); } - - } diff --git a/src/ihm/PopUp.java b/src/ihm/PopUp.java index 7c2c647..7bcc2f6 100644 --- a/src/ihm/PopUp.java +++ b/src/ihm/PopUp.java @@ -1,11 +1,6 @@ package ihm; -import java.awt.Window.Type; - -import javax.swing.JFrame; - -import javafx.embed.swing.JFXPanel; import javafx.event.EventHandler; import javafx.scene.Parent; import javafx.scene.Scene; @@ -65,11 +60,7 @@ public class PopUp{ popup.hide(); } - }); - - - - + }); } public void display() { @@ -78,8 +69,6 @@ public class PopUp{ popup.showAndWait(); + } - - - } diff --git a/src/ihm/PopUpBoolean.java b/src/ihm/PopUpBoolean.java new file mode 100644 index 0000000..9d98bc3 --- /dev/null +++ b/src/ihm/PopUpBoolean.java @@ -0,0 +1,75 @@ +package ihm; + + +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.Pane; +import javafx.stage.Modality; +import javafx.stage.Stage; +import javafx.stage.StageStyle; + +public class PopUpBoolean { + + + @FXML private Pane rootPane; + private Scene scene; + private Stage popup; + public static boolean result; + private double xOffSet = 0; + private double yOffSet = 0; + + + + + + public PopUpBoolean (Parent p, String titre) { + + + popup = new Stage(); + + popup.initModality(Modality.WINDOW_MODAL); + + popup.initStyle(StageStyle.UNDECORATED); + + popup.setTitle(titre); + + scene = new Scene(p); + + p.setOnMousePressed(new EventHandler() { + + @Override + public void handle(MouseEvent event){ + + xOffSet = event.getSceneX(); + yOffSet = event.getSceneY(); + } + + }); + + p.setOnMouseDragged(new EventHandler() { + + @Override + public void handle(MouseEvent event){ + + popup.setX(event.getScreenX() - xOffSet); + popup.setY(event.getScreenY() - yOffSet); + + } + + }); + } + + + + public boolean display() { + + popup.setScene(scene); + + popup.showAndWait(); + + return result; + } +} diff --git a/src/ihm/controller/ChoisirBoolean.java b/src/ihm/controller/ChoisirBoolean.java new file mode 100644 index 0000000..57c3f45 --- /dev/null +++ b/src/ihm/controller/ChoisirBoolean.java @@ -0,0 +1,45 @@ +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.layout.Pane; +import javafx.stage.Stage; + +public class ChoisirBoolean implements Initializable{ + @FXML private Pane rootPane; + + @FXML private Button ouiButton; + @FXML private Button nonButton; + + @Override + public void initialize(URL arg0, ResourceBundle arg1) { + + } + @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(); + return; + + } + + @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(); + return; + } +} diff --git a/src/ihm/controller/MenuController.java b/src/ihm/controller/MenuController.java index 57e7d2a..90a4cd8 100644 --- a/src/ihm/controller/MenuController.java +++ b/src/ihm/controller/MenuController.java @@ -28,6 +28,7 @@ public class MenuController implements Initializable{ input = new FileInputStream("src\\ihm\\ressources\\img\\logo.png"); Image image = new Image(input); titre.setImage(image); + } catch (FileNotFoundException e) { e.printStackTrace(); } @@ -35,7 +36,7 @@ public class MenuController implements Initializable{ @FXML public void commencerPartie(MouseEvent mouseEvent) throws IOException{ - System.out.println("Passage à  l'écran de choix des joueurs"); + System.out.println("Passage � l'�cran de choix des joueurs"); AnchorPane pane = FXMLLoader.load(getClass().getResource("../ressources/Choix_joueur.fxml")); Scene scene = new Scene(pane); Stage appStage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow(); diff --git a/src/ihm/controller/PlateauController.java b/src/ihm/controller/PlateauController.java index 590e3f5..4942652 100644 --- a/src/ihm/controller/PlateauController.java +++ b/src/ihm/controller/PlateauController.java @@ -4,20 +4,21 @@ package ihm.controller; import java.io.IOException; import java.net.URL; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.ResourceBundle; -import ihm.Couple; import ihm.PopUp; +import ihm.PopUpBoolean; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.Parent; import javafx.scene.control.Button; import javafx.scene.control.Label; -import javafx.scene.layout.VBox; import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import main.GestionnaireJeu; import main.Joueur; import main.View; @@ -45,6 +46,11 @@ public class PlateauController implements Initializable { @Override public void initialize(URL arg0, ResourceBundle arg1) { //initialisation des attributs des joueurs + + + + + this.vboxJoueur.add(joueur1); this.vboxJoueur.add(joueur2); this.vboxJoueur.add(joueur3); @@ -105,6 +111,17 @@ 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(); + + + } + /** * Permet de consulter sa carte perssonage en cas d'oublie * @@ -122,8 +139,9 @@ public class PlateauController implements Initializable { popup.display(); } - public void showInformation(HashMap j) { + public void showInformation(Map j) { System.out.println("\tplacement des joueurs"); + for (int i=0; i map = GestionnaireJeu.getJoueursMap(new Configuration(this.joueurs)); + + + pc.showInformation(map); Scene scene = new Scene(root); Stage appStage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow(); appStage.setScene(scene); appStage.show(); + GestionnaireJeu.lancerPartie(); } } diff --git a/src/ihm/ressources/choisirBoolean.fxml b/src/ihm/ressources/choisirBoolean.fxml new file mode 100644 index 0000000..28c2a49 --- /dev/null +++ b/src/ihm/ressources/choisirBoolean.fxml @@ -0,0 +1,23 @@ + + + + + + + + + + +