From 6421ad9e3701202f5bed8e0ce1f3e2336b50f14b Mon Sep 17 00:00:00 2001 From: "antoine.perederii" Date: Fri, 19 Jan 2024 18:15:30 +0100 Subject: [PATCH] updates java's tp --- .../tp/JavaFX/tpJeuDeL_oie/Oie/.idea/misc.xml | 2 +- .../Oie/out/production/Oie/data/Stub.class | Bin 673 -> 673 bytes .../production/Oie/launcher/ConsoleGame.class | Bin 1080 -> 1080 bytes .../production/Oie/launcher/GraphicGame.class | Bin 1090 -> 1090 bytes .../Oie/managers/DeplaceurJoueur.class | Bin 1080 -> 1118 bytes .../Oie/managers/GestionnaireJoueur.class | Bin 2059 -> 2650 bytes .../Oie/out/production/Oie/models/Case.class | Bin 1367 -> 1367 bytes .../Oie/out/production/Oie/models/De.class | Bin 682 -> 682 bytes .../out/production/Oie/models/DeSimple.class | Bin 673 -> 673 bytes .../Oie/out/production/Oie/models/Jeu.class | Bin 1562 -> 1562 bytes .../out/production/Oie/models/Joueur.class | Bin 1464 -> 1464 bytes .../out/production/Oie/models/Plateau.class | Bin 1512 -> 1512 bytes .../Oie/out/production/Oie/view/Fenetre.class | Bin 3011 -> 4168 bytes .../Oie/src/managers/DeplaceurJoueur.java | 10 +- .../Oie/src/managers/GestionnaireJoueur.java | 26 +-- .../tpJeuDeL_oie/Oie/src/view/Fenetre.java | 202 ++++++++++-------- 16 files changed, 128 insertions(+), 112 deletions(-) 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 6eccb6773966effe983de2b2b2e2ee4a4d5b8d0e..24a280d482c816cf03352d8356e458f49b90f77e 100644 GIT binary patch delta 17 ZcmZ3;x{#IQ)W2Q(7#JArHge2l0suV81}6Xj delta 17 ZcmZ3;x{#IQ)W2Q(7#J8FH*(Bm0suVN1}Xpm 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 322463fe5602e42c73adec10a25a5a908dc49d53..d7adba0a959301921f0541ef1a181636f354a485 100644 GIT binary patch delta 17 ZcmdnNv4ex-)W2Q(7#JArHgXuS002KT1@r&_ delta 17 ZcmdnNv4ex-)W2Q(7#J8FH*y%T002Ki1@`~| 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 124d30e62ca5fd668099792fda260134a67c3275..2c8ca730da193b4fe413c3fd6349102181f44576 100644 GIT binary patch delta 17 ZcmX@aafpNC)W2Q(7#JArHgZ_8002OT1`+@O delta 17 ZcmX@aafpNC)W2Q(7#J8FH*#39002Oi1{DAR 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 00383fb0569943ca7808e826c3369ea48ab532e5..c8a246b7242018b670c01d68a07554a0eb1a34ef 100644 GIT binary patch delta 383 zcmZ8c%`O8`7(MfsUYWTwXqhyvD6K(frnIq;qNxNsKM5}|EQwfHSYdB9nTL?r)nXzR zmLwj+#&cAhTRXWo=YIE|?>pz*7x5*;=g;dKfLIxCuisT$<;}6dXd%iqwHS4xqF5ViyEykN8unMbj|n!cC6))j}S4RWZ5Ju z!?Ky97{!DECk)IJ1B?-?)R=*dS$L?yCsRd(7+?vDh>3M}t^GNXS>TPH2)d-TQK=eL zlx40a#chs+tV~4Y9q2>&1-RTMCt|d+2cv!{8O(o&(~MM+qoU5D`i9E=KjsG2HtDfN qy&g*Fqk?V5*`eny+Stp6hTmABtIE{D>L`=)w_sSV$LBULIy%2pL^Wst delta 365 zcmX|*zfQt%6oo(95^5-55g`Oo{wN9*m1-gqO~4%&eE~F18sp&PAaQpgJPAu<986ps zdkYRE9UQK3MN|19{CO>`Z#j^A7 zL2R~XjMAyI`|;)VXnc1*zPP!XJsJ;_XAI&BskH+Vr=Fy5wTo6j%Iiov>bONqLwBxU z1~us_3F(UV$|PCCr9xhl5_PJqOJV;nRn>+n<2eZ5RkQ>C cKa|h5u7*%PI}y~bd>k{LPG;2asxt6@0d0vd{{R30 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 c032d391a73ffb543497d955607ce4912dbf8897..ba2dd08b4ed15774871b1df7fa0b7205f702c6f3 100644 GIT binary patch literal 2650 zcma)8ZC4sc6n+L!6c$YIwKayks09>BT8*(-TT5$dO4OFr#MHJ~U_#cy!dbwh{Wbjw zeG_YYPES7fNA>hxc7a`rmM_cB?A+&N?%X^4{m&nN0oZ`%g9~miJPHOdC~)maJysJ% zRWBrVvqv&l6Bu0Abgi}_;EqK1eHg;97d{1kC<3>5`Kyyeu3RkAVy&!K6I;(yosqz3 zIa`&+v6?N)O~X)6(^{24=OWQ`kJ#PzT3(hMMi3)jTvKozA%W?Vs;dQQR1=S6mC1Bf zGvwoPUDgfKS+cP2_JQohm_Wo*kd-Rwt{CNtG-{`bj8>`?B@5WIrhFL11ncd^>}l3vUR#IBNOW~U?Y2HZ?}OTlg25eVe!h9UJ@ zYjfr=VRgbJeVE0Z7xN0b_z<{Rb<%xhG z)*wDpu#Lx5exyC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bcl-bV 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 08b8649c0057ab2a7553ad2c503e66a0b2f590d1..a875057e03019f1755c2dd4c72c34e72de0db544 100644 GIT binary patch delta 92 zcmcc4b)Adj)W2Q(7#JArHgYI33G%Zs7;rHdG8nNl81pblGMG&EWjZ9x!C=P7z{04& r$i=~6!N|bOsKB+EpIMhlTAzWD!IS|+nlo4e4dDW^tQc$<>=+~gCbkUx delta 91 zcmcc4b)Adj)W2Q(7#J8FH*zR4scj1Ff%G}@v||Qa50!Nn6WdM q^Dsy 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 a8359e8d6cce415a1db277cbf501f09dbcc79aec..63c01683ad0164794908e245f20c728a87565dce 100644 GIT binary patch delta 17 ZcmZ3;x{#IQ)W2Q(7#JArHge2l0suV81}6Xj delta 17 ZcmZ3;x{#IQ)W2Q(7#J8FH*(Bm0suVN1}Xpm 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 787c0672388a5aafb8786c306acd4790bef8b1c1..7a494d8842af906e52f071fa30b37b658f202a63 100644 GIT binary patch delta 17 ZcmbQmGmD4g)W2Q(7#JArHgX8D0RTI(1*8A~ delta 17 ZcmbQmGmD4g)W2Q(7#J8FH*yHE0RTI|1*ZT2 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 73a1ea2fc48f5537fcda9ca06ce0451ee80362d0..8129d96eb32615e172d88b32996a0c75dbb90325 100644 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6lkvLFSMVA~f?$$V60)7}RMta=U3)6~0O~X&PuWXVjYDX6|sfQ*#$v z%x9`8*vvME?V26zG{32cShi?d*=2sVHU{tEUWYc#ecW$y?ats{9&p&Fd60H9V7IDH zbJ;G7Hhbzris0aIpF5DKYl$b^00)Q#=;n~a!z-R!L(A zc96Y{Xhs=R*zrE`T3EfOKRyw!6O&_g`+EA_-sF~=LtX`vnsFvfX?C-(hDpuioHjk# zJAzN}q{CC16i=Javk#hSXOppfpPF6%^|lXV+5?55HxxNuh7pyQ!&?E~<{gK3y?Ea< z=ltImN&~bF4Y^}21Mx({O*nk0s4`#ptE3G+R)l34PKl2_!^0=XM<|yxENQE38Kr$B z_p`Fgk@*>!Ew2>+(xh>2(F(loko$N=moZDuvol`K$!-)|_OLm21r@u7lj^>Lf0lr( z^JQ5u%W_$+lx0bpRkMU+v9AcHsYp{j%ZAHhYjIx2BJqkunI#bOSive$s-;z*6;;o_ z!E-z>JH_DQ`@hP4TeOL+t)YzL6!mGEuCi5ekzSGRPP037l|2^U(6M*^aqo&~`#tSI zny&Aushu~^ST8+Fb8wDFAWi%d%W6Y&xS7p)r7rz7?S*e=!Vk;m3MHfpCGx0zUE3*@ zt7Qy}I8H?-kBD53(#8wCC|O%1c!>*{+$I)sds&O9;uA{#2ET_8?*IS* 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 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 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 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