diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/misc.xml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/misc.xml
index 5273917..a346fd7 100644
--- a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/misc.xml
+++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/data/Stub.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/data/Stub.class
index 6eccb67..24a280d 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/data/Stub.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/data/Stub.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/ConsoleGame.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/ConsoleGame.class
index 322463f..d7adba0 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/ConsoleGame.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/ConsoleGame.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/GraphicGame.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/GraphicGame.class
index 124d30e..2c8ca73 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/GraphicGame.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/GraphicGame.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/managers/DeplaceurJoueur.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/managers/DeplaceurJoueur.class
index 00383fb..c8a246b 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/managers/DeplaceurJoueur.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/managers/DeplaceurJoueur.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/managers/GestionnaireJoueur.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/managers/GestionnaireJoueur.class
index c032d39..ba2dd08 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/managers/GestionnaireJoueur.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/managers/GestionnaireJoueur.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Case.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Case.class
index 08b8649..a875057 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Case.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Case.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/De.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/De.class
index 95a334a..999cc44 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/De.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/De.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/DeSimple.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/DeSimple.class
index a8359e8..63c0168 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/DeSimple.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/DeSimple.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Jeu.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Jeu.class
index 787c067..7a494d8 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Jeu.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Jeu.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Joueur.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Joueur.class
index 73a1ea2..8129d96 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Joueur.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Joueur.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Plateau.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Plateau.class
index 8970663..99dd78b 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Plateau.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Plateau.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/view/Fenetre.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/view/Fenetre.class
index 32fc88b..bec48b0 100644
Binary files a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/view/Fenetre.class and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/view/Fenetre.class differ
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/managers/DeplaceurJoueur.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/managers/DeplaceurJoueur.java
index 861e6ee..6eae3e1 100644
--- a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/managers/DeplaceurJoueur.java
+++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/managers/DeplaceurJoueur.java
@@ -28,11 +28,15 @@ public class DeplaceurJoueur {
Case caseActuelle = joueurActuel.getMyCase();
Case caseSuivante = joueurSuivant.getMyCase();
+ if(caseActuelle == null) {
+ caseActuelle.setCurrentJoueur(null);
+ } else {
+ caseActuelle.setCurrentJoueur(joueurSuivant);
+ }
+ caseSuivante.setCurrentJoueur(joueurActuel);
+
joueurActuel.setMyCase(caseSuivante);
joueurSuivant.setMyCase(caseActuelle);
-
- caseActuelle.setCurrentJoueur(joueurSuivant);
- caseSuivante.setCurrentJoueur(joueurActuel);
}
// public void deplacerJoueur(Joueur currentJoueur, int nbCases, Plateau plateau) {
// if (verifPresenceJoueur(currentJoueur, nbCases, plateau)) {
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/managers/GestionnaireJoueur.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/managers/GestionnaireJoueur.java
index fd650e7..8a2317c 100644
--- a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/managers/GestionnaireJoueur.java
+++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/managers/GestionnaireJoueur.java
@@ -11,24 +11,24 @@ import java.util.List;
public class GestionnaireJoueur {
private static int index = 0;
- private ObservableList myList = FXCollections.observableArrayList();
- private ListProperty lesJoueurs = new SimpleListProperty(myList);
+ private final ObservableList myList = FXCollections.observableArrayList();
+ private final ListProperty lesJoueurs = new SimpleListProperty(myList);
public ObservableList getLesJoueurs() {
return lesJoueurs.get();
}
public ListProperty lesJoueursProperty() {
return lesJoueurs;
}
- private Joueur currentJoueur;
+ private ObjectProperty currentJoueur = new SimpleObjectProperty<>();
public Joueur getCurrentJoueur() {
+ return currentJoueur.get();
+ }
+ public ObjectProperty currentJoueurProperty() {
return currentJoueur;
}
-// public ObjectProperty currentJoueurProperty() {
-// return currentJoueur;
-// }
-// public void setCurrentJoueur(Joueur joueur) {
-// currentJoueur.set(joueur);
-// }
+ public void setCurrentJoueur(Joueur joueur) {
+ currentJoueur.set(joueur);
+ }
// private List lesJoueurs = new ArrayList<>();
// private StringProperty name = new SimpleStringProperty();
// public String getName() { return name.get(); }
@@ -42,18 +42,18 @@ public class GestionnaireJoueur {
// return currentJoueur;
// }
public Joueur getJoueurSuivant() {
- return this.myList.get((currentJoueur.getIdJoueur() + 1) % lesJoueurs.size());
+ return this.myList.get((currentJoueur.get().getIdJoueur() + 1) % lesJoueurs.size());
}
public void ajouterJoueur(Joueur joueur) {
myList.add(joueur);
if(myList.size() == 1) {
- currentJoueur = myList.get(0);
+ currentJoueur.set(myList.get(0));
}
}
public Joueur nextPlayer() {
index = (index +1) % this.myList.size();
- currentJoueur = myList.get(index);
- return currentJoueur;
+ setCurrentJoueur(myList.get(index));
+ return getCurrentJoueur();
// return myList.get((currentJoueur.getIdJoueur()) % lesJoueurs.size());
}
}
diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/view/Fenetre.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/view/Fenetre.java
index 752a39b..ab24c7d 100644
--- a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/view/Fenetre.java
+++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/view/Fenetre.java
@@ -1,6 +1,8 @@
package view;
import data.Stub;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
@@ -14,21 +16,22 @@ import models.Joueur;
public class Fenetre {
@FXML
- private BorderPane myBorderPane = new BorderPane();
+ private BorderPane myBorderPane;
@FXML
private VBox labelContainer;
@FXML
- private ListView joueursContainer = new ListView();
+ private ListView joueursContainer;
private final Jeu game = new Stub().loadPions();
Joueur currentPion = game.getMyAdminPlayer().getCurrentJoueur();
public void updateButtonLabels() {
- for (int i = 1; i < game.getPlateau().getCaseList().size(); i++) {
+ for (int i = 0; i < game.getPlateau().getCaseList().size(); i++) {
+ System.out.println((i + 1) + " " + game.getPlateau().getCaseList().size());
Label label = (Label) labelContainer.getChildren().get(i);
if (game.getPlateau().getCaseList().get(i).getCurrentJoueur() != null) {
- label.setText("Case " + (i) + "\n" + "Joueur: " + game.getPlateau().getCaseList().get(i).getCurrentJoueur().getIdJoueur());
+ label.setText("Case " + (i + 1) + "\n" + "Joueur: " + game.getPlateau().getCaseList().get(i).getCurrentJoueur().getIdJoueur());
} else {
- label.setText("Case " + (i));
+ label.setText("Case " + (i + 1));
}
}
}
@@ -41,105 +44,114 @@ public class Fenetre {
for (int i = 0; i < game.getPlateau().getCaseList().size(); i++) {
Label label = new Label();
if (game.getPlateau().getCaseList().get(i).getCurrentJoueur() != null) {
- label.setText("Case " + i + "\n" + "Joueur: " + game.getPlateau().getCaseList().get(i).getCurrentJoueur().getIdJoueur());
+ label.setText("Case " + (i+1) + "\n" + "Joueur: " + game.getPlateau().getCaseList().get(i).getCurrentJoueur().getIdJoueur());
} else {
- label.setText("Case " + i);
+ label.setText("Case " + (i+1));
}
labelContainer.getChildren().add(label);
}
joueursContainer.itemsProperty().bind(game.getMyAdminPlayer().lesJoueursProperty());
-// joueursContainer.selectionModelProperty().bind(game.getMyAdminPlayer().currentJoueurProperty());
- }
- public void initialize() {
- de.setDisable(true);
- jeu = new Jeu();
- gestionnaireJoueur = new GestionnaireJoueur();
- creationPlateau();
- gestionnaireJoueur.getJoueurList().addListener(new ListChangeListener() {
+ game.getMyAdminPlayer().currentJoueurProperty().addListener(new ChangeListener() {
@Override
- public void onChanged(Change extends Joueur> c) {
- while (c.next()) {
- if (c.wasAdded()) {
- for (Joueur joueur : c.getAddedSubList()) {
- addGridPlayer();
- }
- }
- if (c.wasUpdated()) {
- for (Joueur joueur : c.getAddedSubList()) {
- changeGridPlayer(joueur);
- }
- }
- }
+ public void changed(ObservableValue extends Joueur> observable, Joueur oldValue, Joueur newValue) {
+ joueursContainer.getSelectionModel().select(newValue);
}
});
+// == > se transforme en ça :
+ game.getMyAdminPlayer().currentJoueurProperty().addListener((__, ___, newValue) -> joueursContainer.getSelectionModel().select(newValue));
}
-
- public void creationPlateau() {
- int nombreColonnes = 16;
-
- for (int i = 0; i < jeu.getPlateau().getSizeplateau(); i++) {
- Text text = new Text(String.valueOf(i + 1));
- text.setStyle("-fx-font-size: 35;");
- int row = i / nombreColonnes;
- int col = i % nombreColonnes;
-
- gridPanel.add(text, col, row);
- gridPanel.setMargin(text, new Insets(30, 25, 50, 0));
- gridPanel.setAlignment(Pos.CENTER);
- }
- }
-
- public void addPlayer(){
- gestionnaireJoueur.ajouterJoueur();
- }
-
- public void addGridPlayer(){
- int rowIndex = gestionnaireJoueur.getJoueurList().size();
- Joueur joueur = gestionnaireJoueur.getJoueurList().get(rowIndex - 1);
-
- Label idJoueurLabel = new Label("Joueur numéro " + joueur.getId());
- gridPlayer.add(idJoueurLabel, 0, rowIndex);
-
- Label caseJoueurLabel = new Label();
- caseJoueurLabel.setText("Case numéro: N/A");
-
-
- gridPlayer.add(caseJoueurLabel, 1, rowIndex);
-
- }
-
- public void changeGridPlayer(Joueur joueur){
- Label caseJoueurLabel = (Label) gridPlayer.getChildren().get(joueur.getId());
- if (joueur.getCurrentCase() != null) {
- caseJoueurLabel.textProperty().bind(Bindings.concat("Case numéro " + joueur.getCurrentCase().getNum()));
- } else {
- caseJoueurLabel.textProperty().bind(Bindings.concat("Case numéro: N/A"));
- }
-
- }
-
- public void start() {
- addPlay.setDisable(true);
- de.setDisable(false);
- btStart.setDisable(true);
- gestionnaireJoueur.InitaliseJoueur();
- currentJoueur = gestionnaireJoueur.getCurrentJoueur();
- }
-
-
-
- public void lanceDe() {
- idPlayer.textProperty().bind(currentJoueur.idProperty().asString());
- deSimple.lancer();
- idValeur.textProperty().bind(deSimple.valProperty().asString());
- if (deSimple.getVal() == 0){
- return;
- }
- System.out.println("Current Joueur = " + currentJoueur);
- jeu.CaseDeplacer(currentJoueur,deSimple.getVal() );
- currentJoueur = gestionnaireJoueur.switchCurrentPlayer();
- System.out.println();
- }
+// public void initialize() {
+// de.setDisable(true);
+// jeu = new Jeu();
+// gestionnaireJoueur = new GestionnaireJoueur();
+// creationPlateau();
+// gestionnaireJoueur.getJoueurList().addListener(new ListChangeListener() {
+// @Override
+// public void onChanged(Change extends Joueur> c) {
+// while (c.next()) {
+// if (c.wasAdded()) {
+// for (Joueur joueur : c.getAddedSubList()) {
+// addGridPlayer();
+// }
+// }
+// if (c.wasUpdated()) {
+// for (Joueur joueur : c.getAddedSubList()) {
+// changeGridPlayer(joueur);
+// }
+// }
+// }
+// }
+// });
+//
+//
+// }
+//
+// public void creationPlateau() {
+// int nombreColonnes = 16;
+//
+// for (int i = 0; i < jeu.getPlateau().getSizeplateau(); i++) {
+// Text text = new Text(String.valueOf(i + 1));
+// text.setStyle("-fx-font-size: 35;");
+// int row = i / nombreColonnes;
+// int col = i % nombreColonnes;
+//
+// gridPanel.add(text, col, row);
+// gridPanel.setMargin(text, new Insets(30, 25, 50, 0));
+// gridPanel.setAlignment(Pos.CENTER);
+// }
+// }
+//
+// public void addPlayer(){
+// gestionnaireJoueur.ajouterJoueur();
+// }
+//
+// public void addGridPlayer(){
+// int rowIndex = gestionnaireJoueur.getJoueurList().size();
+// Joueur joueur = gestionnaireJoueur.getJoueurList().get(rowIndex - 1);
+//
+// Label idJoueurLabel = new Label("Joueur numéro " + joueur.getId());
+// gridPlayer.add(idJoueurLabel, 0, rowIndex);
+//
+// Label caseJoueurLabel = new Label();
+// caseJoueurLabel.setText("Case numéro: N/A");
+//
+//
+// gridPlayer.add(caseJoueurLabel, 1, rowIndex);
+//
+// }
+//
+// public void changeGridPlayer(Joueur joueur){
+// Label caseJoueurLabel = (Label) gridPlayer.getChildren().get(joueur.getId());
+// if (joueur.getCurrentCase() != null) {
+// caseJoueurLabel.textProperty().bind(Bindings.concat("Case numéro " + joueur.getCurrentCase().getNum()));
+// } else {
+// caseJoueurLabel.textProperty().bind(Bindings.concat("Case numéro: N/A"));
+// }
+//
+// }
+//
+// public void start() {
+// addPlay.setDisable(true);
+// de.setDisable(false);
+// btStart.setDisable(true);
+// gestionnaireJoueur.InitaliseJoueur();
+// currentJoueur = gestionnaireJoueur.getCurrentJoueur();
+// }
+//
+//
+//
+// public void lanceDe() {
+// idPlayer.textProperty().bind(currentJoueur.idProperty().asString());
+// deSimple.lancer();
+// idValeur.textProperty().bind(deSimple.valProperty().asString());
+// if (deSimple.getVal() == 0){
+// return;
+// }
+// System.out.println("Current Joueur = " + currentJoueur);
+// jeu.CaseDeplacer(currentJoueur,deSimple.getVal() );
+// currentJoueur = gestionnaireJoueur.switchCurrentPlayer();
+// System.out.println();
+// }
}
\ No newline at end of file