parent
0ee865358b
commit
1d9fd9b5d7
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="18" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="18" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
Binary file not shown.
@ -1,9 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.control.ButtonBar?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
|
||||||
<BorderPane fx:id="myBorderPane" style="-fx-background-color: #ecf0f1;" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.Fenetre">
|
|
||||||
|
|
||||||
|
<BorderPane fx:id="myBorderPane" style="-fx-background-color: #ecf0f1;" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.Fenetre">
|
||||||
|
<center>
|
||||||
|
<VBox fx:id="buttonContainer" BorderPane.alignment="CENTER">
|
||||||
|
<!-- Les boutons seront ajoutés ici dynamiquement -->
|
||||||
|
<Button fx:id="rollDice" mnemonicParsing="false" onAction="#onButtonRollClicked" style="-fx-background-color: #2ecc71;" text="RollDice" alignment="CENTER" />
|
||||||
|
</VBox>
|
||||||
|
</center>
|
||||||
</BorderPane>
|
</BorderPane>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,9 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.control.ButtonBar?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
|
||||||
<BorderPane fx:id="myBorderPane" style="-fx-background-color: #ecf0f1;" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.Fenetre">
|
|
||||||
|
|
||||||
|
<BorderPane fx:id="myBorderPane" style="-fx-background-color: #ecf0f1;" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.Fenetre">
|
||||||
|
<center>
|
||||||
|
<VBox fx:id="buttonContainer" BorderPane.alignment="CENTER">
|
||||||
|
<!-- Les boutons seront ajoutés ici dynamiquement -->
|
||||||
|
<Button fx:id="rollDice" mnemonicParsing="false" onAction="#onButtonRollClicked" style="-fx-background-color: #2ecc71;" text="RollDice" alignment="CENTER" />
|
||||||
|
</VBox>
|
||||||
|
</center>
|
||||||
</BorderPane>
|
</BorderPane>
|
@ -0,0 +1,44 @@
|
|||||||
|
package managers;
|
||||||
|
|
||||||
|
import models.Case;
|
||||||
|
import models.Joueur;
|
||||||
|
import models.Plateau;
|
||||||
|
|
||||||
|
public class DeplaceurJoueur {
|
||||||
|
private boolean verifPresenceJoueur(Joueur currentJoueur, int valeurDe, Plateau plateau) {
|
||||||
|
int nextIndex = (currentJoueur.getMyCase().getIdCase() + valeurDe) % plateau.getCaseList().size();
|
||||||
|
Case caseSuivante = plateau.getCaseList().get(nextIndex);
|
||||||
|
return caseSuivante.getCurrentJoueur() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void alternerJoueurs(Joueur joueur1, Joueur joueur2) {
|
||||||
|
// Échanger les positions des joueurs
|
||||||
|
Case caseJoueur1 = joueur1.getMyCase();
|
||||||
|
Case caseJoueur2 = joueur2.getMyCase();
|
||||||
|
|
||||||
|
caseJoueur1.setCurrentJoueur(joueur2);
|
||||||
|
caseJoueur2.setCurrentJoueur(joueur1);
|
||||||
|
|
||||||
|
joueur1.setMyCase(caseJoueur2);
|
||||||
|
joueur2.setMyCase(caseJoueur1);
|
||||||
|
|
||||||
|
System.out.println("Échange de positions entre le joueur " + joueur1.getIdJoueur() + " et le joueur " + joueur2.getIdJoueur());
|
||||||
|
}
|
||||||
|
public void deplacerJoueur(Joueur currentJoueur, int nbCases, Plateau plateau) {
|
||||||
|
if (verifPresenceJoueur(currentJoueur, nbCases, plateau)) {
|
||||||
|
// La case suivante est occupée ou en dehors du plateau, alterner les joueurs ou prendre une action appropriée
|
||||||
|
alternerJoueurs(currentJoueur, currentJoueur);
|
||||||
|
} else {
|
||||||
|
int positionActuelle = currentJoueur.getMyCase().getIdCase();
|
||||||
|
int nouvellePosition = (positionActuelle + nbCases) % plateau.getCaseList().size();
|
||||||
|
|
||||||
|
Case caseSuivante = plateau.getCaseList().get(nouvellePosition);
|
||||||
|
currentJoueur.getMyCase().setCurrentJoueur(null);
|
||||||
|
|
||||||
|
caseSuivante.setCurrentJoueur(currentJoueur);
|
||||||
|
currentJoueur.setMyCase(caseSuivante);
|
||||||
|
|
||||||
|
System.out.println("Le joueur " + currentJoueur.getIdJoueur() + " se déplace sur la case " + caseSuivante.getIdCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
//package models;
|
|
||||||
//
|
|
||||||
//public class DeplaceurJoueur {
|
|
||||||
// private boolean verifPresenceJoueur(Joueur currentJoueur, int valeurDe) {
|
|
||||||
// if((currentJoueur.getCurrentIdCase() + valeurDe )!= 0) {
|
|
||||||
// myPlateau.getCaseList().get(currentJoueur.getCurrentIdCase() - 1).setPresence(false);
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// private void alternerJoueurs(Joueur joueur1, Joueur joueur) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// public void avancerJoueur(Joueur currentJoueur, Plateau myPlateau) {
|
|
||||||
// currentJoueur.setCurrentIdCase();
|
|
||||||
// myPlateau.getCaseList().get(currentJoueur.getCurrentIdCase()-1).setPresence(true);
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -1,22 +1,36 @@
|
|||||||
package models;
|
package models;
|
||||||
|
|
||||||
public class Joueur {
|
public class Joueur {
|
||||||
|
private static int count = 0;
|
||||||
|
|
||||||
|
private int idJoueur;
|
||||||
private String color;
|
private String color;
|
||||||
private Case myCase = null;
|
private Case myCase = null;
|
||||||
|
|
||||||
public Joueur(String myColor) {
|
public Joueur(String myColor) {
|
||||||
|
this.idJoueur = ++count;
|
||||||
this.color = myColor;
|
this.color = myColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIdJoueur() {
|
||||||
|
return idJoueur;
|
||||||
|
}
|
||||||
|
|
||||||
public String getColor() {
|
public String getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Case getMyCase() {
|
public Case getMyCase() {
|
||||||
return this.myCase;
|
return this.myCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMyCase(Case myCase) {
|
public void setMyCase(Case myCase) {
|
||||||
this.myCase = myCase;
|
this.myCase = myCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Je suis le Joueur de couleur " + this.color + " et je suis sur la case " + this.myCase.getClass();
|
return "Je suis le Joueur " + idJoueur + " de couleur " + this.color + " et je suis sur la case " + this.myCase.getIdCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in new issue