Merge branch 'development' of https://github.com/PTE-SH/ShadowHunterGame into development
This commit is contained in:
@ -3,10 +3,17 @@ package ihm;
|
||||
public class Couple {
|
||||
private String nom;
|
||||
private boolean ia; // true -> joueur virtuel
|
||||
private int lvlIa;
|
||||
|
||||
public Couple (String nom, boolean ia) {
|
||||
public Couple (String nom) {
|
||||
this.nom = nom;
|
||||
this.ia = ia;
|
||||
this.ia = false;
|
||||
}
|
||||
|
||||
public Couple (String nom, int niveau) {
|
||||
this.nom = nom;
|
||||
this.lvlIa = niveau;
|
||||
this.ia = true;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
@ -17,6 +24,7 @@ public class Couple {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
|
||||
public boolean isIa() {
|
||||
return ia;
|
||||
}
|
||||
@ -25,4 +33,14 @@ public class Couple {
|
||||
this.ia = ia;
|
||||
}
|
||||
|
||||
public int getLvlIa() {
|
||||
return lvlIa;
|
||||
}
|
||||
|
||||
public void setLvlIa(int lvlIa) {
|
||||
this.lvlIa = lvlIa;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package ihm;
|
||||
|
||||
import carte.CarteEquipement;
|
||||
import ihm.controller.PlateauController;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
public class ImageViewEquipement extends ImageView{
|
||||
@ -9,6 +11,8 @@ public class ImageViewEquipement extends ImageView{
|
||||
|
||||
public ImageViewEquipement(CarteEquipement ce) {
|
||||
this.ce = ce;
|
||||
Image im = PlateauController.getImageCarte(ce);
|
||||
this.setImage(im);
|
||||
}
|
||||
|
||||
public CarteEquipement getCp() {
|
||||
|
@ -1,7 +1,4 @@
|
||||
package ihm;
|
||||
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
@ -49,7 +46,6 @@ public class Main extends Application {
|
||||
RessourceLoader rl = new RessourceLoader();
|
||||
rl.loadRessources();
|
||||
gj.setRessourceLoader(rl);
|
||||
|
||||
launch(args);
|
||||
}
|
||||
}
|
@ -1,33 +1,45 @@
|
||||
package ihm.controller;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.util.Duration;
|
||||
import main.Contexte;
|
||||
import main.ControleurIA;
|
||||
import main.GestionnaireJeu;
|
||||
import main.Joueur;
|
||||
import main.JoueurVirtuel;
|
||||
|
||||
public class ChoisirBoolean implements Initializable {
|
||||
@FXML private Button ouiButton;
|
||||
@FXML private Button nonButton;
|
||||
@FXML private Label titre;
|
||||
@FXML
|
||||
private Button ouiButton;
|
||||
@FXML
|
||||
private Button nonButton;
|
||||
@FXML
|
||||
private Label titre;
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public boolean getResult() {
|
||||
@ -49,12 +61,72 @@ public class ChoisirBoolean implements Initializable {
|
||||
public void setNonButton(Button nonButton) {
|
||||
this.nonButton = nonButton;
|
||||
}
|
||||
|
||||
|
||||
public Label getTitre() {
|
||||
return titre;
|
||||
}
|
||||
|
||||
public void setTitre(Label titre) {
|
||||
this.titre = titre;
|
||||
public void setTitre(Contexte c) {
|
||||
switch(c) {
|
||||
case ATTAQUER:
|
||||
titre.setText("Souhaitez-vous attaquer quelqu'un?");
|
||||
break;
|
||||
case ACTIVER_EFFET_LIEU :
|
||||
titre.setText("Souhaitez-vous activer l'effet du lieu?");
|
||||
break;
|
||||
case CHOISIR_VISION :
|
||||
titre.setText("Souhaitez-vous activer l'effet de la carte vision");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void fireBtnIAEffetLieu() {
|
||||
ControleurIA cIA = new ControleurIA();
|
||||
ouiButton.setDisable(true);
|
||||
nonButton.setDisable(true);
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(2000), ae -> {
|
||||
if (cIA.choixUtiliserPouvoirLieu()) {
|
||||
ouiButton.setDisable(false);
|
||||
ouiButton.fire();
|
||||
} else {
|
||||
nonButton.setDisable(false);
|
||||
nonButton.fire();
|
||||
}
|
||||
}));
|
||||
timeline.play();
|
||||
}
|
||||
|
||||
public void fireBtnIAVision() {
|
||||
ControleurIA cIA = new ControleurIA();
|
||||
ouiButton.setDisable(true);
|
||||
nonButton.setDisable(true);
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(2000), ae -> {
|
||||
if (cIA.mentirIAMetamorphe()) {
|
||||
ouiButton.setDisable(false);
|
||||
ouiButton.fire();
|
||||
} else {
|
||||
nonButton.setDisable(false);
|
||||
nonButton.fire();
|
||||
}
|
||||
}));
|
||||
timeline.play();
|
||||
}
|
||||
|
||||
public void fireBtnIAattaquer(JoueurVirtuel jIA, List<Joueur> joueursLieu) {
|
||||
ControleurIA cIA = new ControleurIA();
|
||||
ouiButton.setDisable(true);
|
||||
nonButton.setDisable(true);
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(2000), ae -> {
|
||||
if (cIA.choixSiAttaquer(jIA, joueursLieu)) {
|
||||
ouiButton.setDisable(false);
|
||||
ouiButton.fire();
|
||||
} else {
|
||||
nonButton.setDisable(false);
|
||||
nonButton.fire();
|
||||
}
|
||||
}));
|
||||
timeline.play();
|
||||
}
|
||||
}
|
||||
|
@ -10,27 +10,18 @@ import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import main.GestionnaireJeu;
|
||||
|
||||
public class ChoisirEquipement implements Initializable{
|
||||
@FXML private GridPane grilleEquipement;
|
||||
@FXML private HBox hbox;
|
||||
|
||||
private List<CarteEquipement> equipements = new ArrayList<CarteEquipement>();
|
||||
private CarteEquipement equipementSelected;
|
||||
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
for (int i=0; i<equipements.size(); i++) {
|
||||
ImageView carte = (ImageView) grilleEquipement.getChildren().get(i);
|
||||
|
||||
/*InputStream input = getClass().getResourceAsStream("/ihm/ressources/img/" + "nomcarte" + ".png");
|
||||
Image image = new Image(input);
|
||||
carte.setImage(image);*/
|
||||
|
||||
int numEquipement = i;
|
||||
carte.setOnMouseClicked(e -> {
|
||||
equipementSelected = equipements.get(numEquipement);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public List<CarteEquipement> getEquipements() {
|
||||
@ -61,4 +52,23 @@ public class ChoisirEquipement implements Initializable{
|
||||
return equipementSelected;
|
||||
}
|
||||
|
||||
public void setListCarteEquipements(List<CarteEquipement> lce) {
|
||||
this.equipements = lce;
|
||||
}
|
||||
|
||||
public void initChoisirEquipement() {
|
||||
for (CarteEquipement ce : equipements) {
|
||||
|
||||
ImageView iv = new ImageView(PlateauController.getImageCarte(ce));
|
||||
iv.setFitHeight(100);
|
||||
iv.setFitHeight(100);
|
||||
iv.setPreserveRatio(true);
|
||||
|
||||
hbox.getChildren().add(iv);
|
||||
iv.setOnMouseClicked(e -> {
|
||||
equipementSelected = ce;
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,50 +5,67 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.util.Duration;
|
||||
import main.Contexte;
|
||||
import main.GestionnaireJeu;
|
||||
import main.Joueur;
|
||||
import main.JoueurVirtuel;
|
||||
|
||||
public class ChoisirJoueur implements Initializable{
|
||||
@FXML private HBox joueurHaut;
|
||||
@FXML private HBox joueurBas;
|
||||
@FXML private Label titre;
|
||||
@FXML private Button btn1;
|
||||
@FXML private Button btn2;
|
||||
@FXML private Button btn3;
|
||||
@FXML private Button btn4;
|
||||
@FXML private Button btn5;
|
||||
@FXML private Button btn6;
|
||||
@FXML private Button btn7;
|
||||
@FXML private Button btn8;
|
||||
public class ChoisirJoueur implements Initializable {
|
||||
@FXML
|
||||
private HBox joueurHaut;
|
||||
@FXML
|
||||
private HBox joueurBas;
|
||||
@FXML
|
||||
private Label titre;
|
||||
@FXML
|
||||
private Button btn1;
|
||||
@FXML
|
||||
private Button btn2;
|
||||
@FXML
|
||||
private Button btn3;
|
||||
@FXML
|
||||
private Button btn4;
|
||||
@FXML
|
||||
private Button btn5;
|
||||
@FXML
|
||||
private Button btn6;
|
||||
@FXML
|
||||
private Button btn7;
|
||||
@FXML
|
||||
private Button btn8;
|
||||
|
||||
private JoueurIHM joueurSelected;
|
||||
private List<JoueurIHM> listJoueursIHM;
|
||||
private List<Button> buttons;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
|
||||
|
||||
this.buttons = new ArrayList<Button>();
|
||||
|
||||
|
||||
this.buttons.add(btn1);
|
||||
this.buttons.add(btn2);
|
||||
this.buttons.add(btn3);
|
||||
this.buttons.add(btn4);
|
||||
this.buttons.add(btn5);
|
||||
this.buttons.add(btn6);
|
||||
this.buttons.add(btn7);
|
||||
this.buttons.add(btn8);
|
||||
this.buttons.add(btn6);
|
||||
this.buttons.add(btn7);
|
||||
this.buttons.add(btn8);
|
||||
}
|
||||
|
||||
|
||||
public void initButtons() {
|
||||
|
||||
|
||||
int i = 0;
|
||||
|
||||
while(i <listJoueursIHM.size()) {
|
||||
|
||||
while (i < listJoueursIHM.size()) {
|
||||
Button b = this.buttons.get(i);
|
||||
JoueurIHM jihm = listJoueursIHM.get(i);
|
||||
b.setOnAction(e -> {
|
||||
@ -58,27 +75,27 @@ public class ChoisirJoueur implements Initializable{
|
||||
b.setText(jihm.getNom());
|
||||
i++;
|
||||
}
|
||||
|
||||
for(int j = i; j < buttons.size(); j++) {
|
||||
|
||||
for (int j = i; j < buttons.size(); j++) {
|
||||
Button b = this.buttons.get(j);
|
||||
b.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
//GETTERS AND SETTERS
|
||||
|
||||
// GETTERS AND SETTERS
|
||||
|
||||
public HBox getJoueurHaut() {
|
||||
return joueurHaut;
|
||||
}
|
||||
|
||||
|
||||
public HBox getHBox(int valeur) {
|
||||
if(valeur < 4) {
|
||||
if (valeur < 4) {
|
||||
return joueurHaut;
|
||||
}else {
|
||||
} else {
|
||||
return joueurBas;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setJoueurHaut(HBox joueurHaut) {
|
||||
this.joueurHaut = joueurHaut;
|
||||
}
|
||||
@ -95,8 +112,16 @@ public class ChoisirJoueur implements Initializable{
|
||||
return titre;
|
||||
}
|
||||
|
||||
public void setTitre(Label titre) {
|
||||
this.titre = titre;
|
||||
public void setTitre(Contexte c) {
|
||||
switch (c) {
|
||||
case ATTAQUER:
|
||||
titre.setText("Choisissez le joueur à attaquer!");
|
||||
break;
|
||||
case CHOISIR_VISION:
|
||||
titre.setText("Choisissez le joueur à qui passer la carte vision!");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public JoueurIHM getJoueurSelected() {
|
||||
@ -106,4 +131,28 @@ public class ChoisirJoueur implements Initializable{
|
||||
public void setListJoueursIHM(List<JoueurIHM> joueursIHM) {
|
||||
this.listJoueursIHM = joueursIHM;
|
||||
}
|
||||
|
||||
public void fireBtnIA(JoueurVirtuel jIA, Contexte c) {
|
||||
for (Button b : buttons)
|
||||
b.setDisable(true);
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(2000), ae -> {
|
||||
List<Joueur> joueurs = new ArrayList<>();
|
||||
for (JoueurIHM jihm : listJoueursIHM) {
|
||||
joueurs.add(jihm.getJoueur());
|
||||
}
|
||||
Joueur jchoisi = jIA.choisirJoueur(joueurs, c);
|
||||
int i = 0;
|
||||
boolean found = false;
|
||||
while (!found && i < listJoueursIHM.size()) {
|
||||
if (listJoueursIHM.get(i).getJoueur().equals(jchoisi)) {
|
||||
found = true;
|
||||
buttons.get(i).setDisable(false);
|
||||
buttons.get(i).fire();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}));
|
||||
timeline.play();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package ihm.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import carte.CarteEquipement;
|
||||
import database.RessourceLoader;
|
||||
import ihm.ImageViewEquipement;
|
||||
@ -62,20 +66,27 @@ public class JoueurIHM {
|
||||
private void initRevealButton() {
|
||||
Button btn = getRevealButton();
|
||||
btn.setOnAction(x -> {
|
||||
|
||||
this.joueur.reveal();
|
||||
ImageView iv = this.getCartePersonnage();
|
||||
System.out.println(this.joueur.getCartePersonnage());
|
||||
Image im = this.pc.getImageCarte(this.joueur.getCartePersonnage());
|
||||
GridPane gp = (GridPane) iv.getParent();
|
||||
iv.setImage(im);
|
||||
iv.fitHeightProperty().bind(gp.heightProperty());
|
||||
initButtonEffect(btn);
|
||||
//btn.setDisable(true);
|
||||
btn.setText("Utiliser Effet");
|
||||
estRevele = true;
|
||||
this.joueur.setRevele(true);;
|
||||
actionReveler(btn);
|
||||
});
|
||||
}
|
||||
|
||||
public void reveler() {
|
||||
Button btn = getRevealButton();
|
||||
actionReveler(btn);
|
||||
}
|
||||
|
||||
private void actionReveler(Button btn) {
|
||||
ImageView iv = this.getCartePersonnage();
|
||||
System.out.println(this.joueur.getCartePersonnage());
|
||||
Image im = this.pc.getImageCarte(this.joueur.getCartePersonnage());
|
||||
GridPane gp = (GridPane) iv.getParent();
|
||||
iv.setImage(im);
|
||||
iv.fitHeightProperty().bind(gp.heightProperty());
|
||||
initButtonEffect(btn);
|
||||
btn.setText("Utiliser Effet");
|
||||
estRevele = true;
|
||||
}
|
||||
|
||||
public Button getRevealButton() {
|
||||
Pane p = (Pane) zoneJoueur.getChildren().get(2);
|
||||
@ -226,26 +237,36 @@ public class JoueurIHM {
|
||||
public void ajouterEquipement(CarteEquipement e) {
|
||||
HBox hb = getPaneEquipement();
|
||||
ImageViewEquipement ive = new ImageViewEquipement(e);
|
||||
hb.getChildren().add(new ImageViewEquipement(e));
|
||||
hb.getChildren().add(ive);
|
||||
ive.setPreserveRatio(true);
|
||||
ive.fitHeightProperty().bind(hb.heightProperty());
|
||||
|
||||
//ive.fitWidthProperty().bind(hb.widthProperty());
|
||||
}
|
||||
|
||||
public void retirerEquipement(CarteEquipement e) {
|
||||
|
||||
HBox hb = getPaneEquipement();
|
||||
for (Node n : hb.getChildren()) {
|
||||
if (n instanceof ImageViewEquipement) {
|
||||
ImageViewEquipement ive = (ImageViewEquipement) n;
|
||||
if (ive.contains(e)) {
|
||||
hb.getChildren().remove(ive);
|
||||
List<ImageView> liv = new ArrayList<ImageView>();
|
||||
for(Iterator<Node> iterator = hb.getChildren().iterator(); iterator.hasNext();) {
|
||||
Node n = iterator.next();
|
||||
|
||||
if (n instanceof ImageViewEquipement) {
|
||||
ImageViewEquipement ive = (ImageViewEquipement) n;
|
||||
if (ive.contains(e)) {
|
||||
liv.add(ive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hb.getChildren().removeAll(liv);
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return this.joueur.getNom();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
import main.Contexte;
|
||||
import main.GestionnaireJeu;
|
||||
import main.Joueur;
|
||||
import main.JoueurVirtuel;
|
||||
|
||||
public class LancerDes {
|
||||
private int resultat;
|
||||
@ -36,31 +38,31 @@ public class LancerDes {
|
||||
this.contexte = c;
|
||||
}
|
||||
|
||||
public VBox initLancer() {
|
||||
public VBox initLancer(Joueur joueur) {
|
||||
switch (typeDe) {
|
||||
case LANCER_DE_4:
|
||||
return initLancerD4();
|
||||
return initLancerD4(joueur);
|
||||
case LANCER_DE_6:
|
||||
return initLancerD6();
|
||||
return initLancerD6(joueur);
|
||||
case LANCER_DES:
|
||||
return initLancerBoth();
|
||||
return initLancerBoth(joueur);
|
||||
default :
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private VBox initLancerD4() {
|
||||
private VBox initLancerD4(Joueur j) {
|
||||
DieImages images = new DieImages(4);
|
||||
Die die = new Die(images.getImages());
|
||||
ImageView stackpane = die.getdieFace();
|
||||
stackpane.setFitHeight(100);
|
||||
stackpane.setFitWidth(100);
|
||||
Button btn = new Button();
|
||||
Text txt = new Text("Lancez le dés pour attaquer");
|
||||
Text txt = new Text("Lancez le dé");
|
||||
txt.setFont(Font.font(null, null, null, 12));
|
||||
txt.setFill(Color.WHITE);
|
||||
btn.setText("Lancer dés");
|
||||
btn.setText("Lancer dé");
|
||||
btn.setOnAction((ActionEvent event) -> {
|
||||
btn.setDisable(true);// Disable Button
|
||||
Random random = new Random();
|
||||
@ -91,20 +93,22 @@ public class LancerDes {
|
||||
VBox root = new VBox(txt,des, new StackPane(btn));
|
||||
root.setAlignment(Pos.CENTER);
|
||||
root.setSpacing(20);
|
||||
if(j instanceof JoueurVirtuel)
|
||||
btn.fire();
|
||||
return root;
|
||||
}
|
||||
|
||||
private VBox initLancerD6() {
|
||||
private VBox initLancerD6(Joueur j) {
|
||||
DieImages images = new DieImages(6);
|
||||
Die die = new Die(images.getImages());
|
||||
ImageView stackpane = die.getdieFace();
|
||||
stackpane.setFitHeight(100);
|
||||
stackpane.setFitWidth(100);
|
||||
Button btn = new Button();
|
||||
Text txt = new Text("Lancez le dés pour attaquer");
|
||||
Text txt = new Text("Lancez le dé");
|
||||
txt.setFont(Font.font(null, null, null, 12));
|
||||
txt.setFill(Color.WHITE);
|
||||
btn.setText("Lancer dés");
|
||||
btn.setText("Lancer dé");
|
||||
btn.setOnAction((ActionEvent event) -> {
|
||||
btn.setDisable(true);// Disable Button
|
||||
Random random = new Random();
|
||||
@ -122,8 +126,6 @@ public class LancerDes {
|
||||
Timeline timeline2 = new Timeline(new KeyFrame(
|
||||
Duration.millis(2000),
|
||||
ae -> {
|
||||
|
||||
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
}));
|
||||
timeline2.play();
|
||||
@ -135,10 +137,12 @@ public class LancerDes {
|
||||
VBox root = new VBox(txt,des, new StackPane(btn));
|
||||
root.setAlignment(Pos.CENTER);
|
||||
root.setSpacing(20);
|
||||
if(j instanceof JoueurVirtuel)
|
||||
btn.fire();
|
||||
return root;
|
||||
}
|
||||
|
||||
private VBox initLancerBoth() {
|
||||
private VBox initLancerBoth(Joueur j) {
|
||||
DieImages images = new DieImages(6);
|
||||
DieImages images2 = new DieImages(4);
|
||||
Die die = new Die(images.getImages());
|
||||
@ -150,7 +154,7 @@ public class LancerDes {
|
||||
stackpane.setFitWidth(100);
|
||||
stackpane2.setFitWidth(100);
|
||||
Button btn = new Button();
|
||||
Text txt = new Text("Lancez les dés pour vous deplacer");
|
||||
Text txt = new Text("Lancez les dés");
|
||||
txt.setFont(Font.font(null, null, null, 12));
|
||||
txt.setFill(Color.WHITE);
|
||||
btn.setText("Lancer dés");
|
||||
@ -191,6 +195,8 @@ public class LancerDes {
|
||||
VBox root = new VBox(txt,des, new StackPane(btn));
|
||||
root.setAlignment(Pos.CENTER);
|
||||
root.setSpacing(20);
|
||||
if(j instanceof JoueurVirtuel)
|
||||
btn.fire();
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -3,27 +3,41 @@ package ihm.controller;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.util.Duration;
|
||||
import main.GestionnaireJeu;
|
||||
|
||||
public class LieuZJ implements Initializable {
|
||||
@FXML private Button okButton;
|
||||
@FXML private ImageView imageView;
|
||||
@FXML
|
||||
private Button okButton;
|
||||
@FXML
|
||||
private ImageView imageView;
|
||||
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
|
||||
|
||||
okButton.setOnAction(x -> {
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setImageView(Image imageCarte) {
|
||||
this.imageView.setImage(imageCarte);
|
||||
}
|
||||
|
||||
public void fireBtnIA() {
|
||||
okButton.setDisable(true);
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(2000), ae -> {
|
||||
okButton.setDisable(false);
|
||||
okButton.fire();
|
||||
}));
|
||||
timeline.play();
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,7 @@ public class MenuController implements Initializable{
|
||||
AnchorPane pane = fxmlLoader.load();
|
||||
Scene scene = new Scene(pane);
|
||||
Stage appStage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow();
|
||||
|
||||
double width = appStage.getWidth();
|
||||
double height = appStage.getHeight();
|
||||
double X = appStage.getX();
|
||||
double Y = appStage.getY();
|
||||
|
||||
appStage.setScene(scene);
|
||||
appStage.setScene(scene);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ihm.controller;
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -18,6 +19,7 @@ import carte.CarteLieu;
|
||||
import carte.CartePiochable;
|
||||
import carte.CartePiochable.Type;
|
||||
import database.RessourceLoader;
|
||||
import effet.action.Action;
|
||||
import ihm.EffetSonore;
|
||||
import ihm.PopUp;
|
||||
import javafx.animation.KeyFrame;
|
||||
@ -27,7 +29,9 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.SplitPane;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
@ -42,6 +46,7 @@ import javafx.util.Duration;
|
||||
import main.Contexte;
|
||||
import main.GestionnaireJeu;
|
||||
import main.Joueur;
|
||||
import main.JoueurVirtuel;
|
||||
|
||||
public class PlateauController implements Initializable {
|
||||
|
||||
@ -58,13 +63,16 @@ public class PlateauController implements Initializable {
|
||||
private PiocherCarte pc;
|
||||
private LancerDes ld;
|
||||
|
||||
private Map<Carte,BufferedImage> mapRessourcesCartes;
|
||||
private Map<String,BufferedImage> mapRessourcesDosCartes;
|
||||
private static Map<Carte,BufferedImage> mapRessourcesCartes;
|
||||
private static Map<String,BufferedImage> mapRessourcesDosCartes;
|
||||
|
||||
public static int DICE_SIX = 1;
|
||||
public static int DICE_QUATRE = 0;
|
||||
public static int DICE_BOTH = 2;
|
||||
|
||||
private final double RES = 200./2250.;
|
||||
private ResourceBundle resourceBundle;
|
||||
|
||||
/**
|
||||
* initialise les données du plateau
|
||||
*/
|
||||
@ -72,6 +80,7 @@ public class PlateauController implements Initializable {
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
//System.out.println("Création du plateau ...");
|
||||
|
||||
this.resourceBundle = arg1;
|
||||
this.joueursIHM = new ArrayList<JoueurIHM>();
|
||||
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
|
||||
RessourceLoader rl = gj.getRessourceLoader();
|
||||
@ -103,88 +112,6 @@ public class PlateauController implements Initializable {
|
||||
List<ImageView> ivs = this.getLieux();
|
||||
|
||||
applyImages(cl,ivs);
|
||||
|
||||
// BUTTONS ETC
|
||||
//System.out.println(this.joueursPane);
|
||||
|
||||
/*
|
||||
this.hboxJoueur.add(joueur1);
|
||||
this.hboxJoueur.add(joueur2);
|
||||
this.hboxJoueur.add(joueur3);
|
||||
this.hboxJoueur.add(joueur4);
|
||||
|
||||
for (HBox hbox : hboxJoueur) {
|
||||
tour.add((AnchorPane) hbox.getChildren().get(0));
|
||||
VBox carte = (VBox) hbox.getChildren().get(1);
|
||||
cartePerso.add((ImageView) carte.getChildren().get(0));
|
||||
btnRevelation.add((Button) carte.getChildren().get(1));
|
||||
VBox info = (VBox) hbox.getChildren().get(2);
|
||||
nomJoueur.add((Label) info.getChildren().get(0));
|
||||
}
|
||||
|
||||
this.vboxJoueur.add(joueur5);
|
||||
this.vboxJoueur.add(joueur6);
|
||||
this.vboxJoueur.add(joueur7);
|
||||
this.vboxJoueur.add(joueur8);
|
||||
|
||||
for (VBox vbox : vboxJoueur) {
|
||||
tour.add((AnchorPane) vbox.getChildren().get(0));
|
||||
HBox joueur = (HBox) vbox.getChildren().get(1);
|
||||
VBox carte = (VBox) joueur.getChildren().get(1);
|
||||
cartePerso.add((ImageView) carte.getChildren().get(0));
|
||||
btnRevelation.add((Button) carte.getChildren().get(1));
|
||||
VBox info = (VBox) joueur.getChildren().get(0);
|
||||
nomJoueur.add((Label) info.getChildren().get(0));
|
||||
}
|
||||
|
||||
//initilaisation des boutons se reveler
|
||||
int i = 0;
|
||||
for (Button b : btnRevelation) {
|
||||
int compteur = i;
|
||||
b.setOnAction(e -> {try {seReveler(compteur);} catch (IOException e1) {e1.printStackTrace();}});
|
||||
i++;
|
||||
}
|
||||
//initialisation des bouton carte personnage
|
||||
int j = 0;
|
||||
for (ImageView b : cartePerso) {
|
||||
int compteur = j;
|
||||
b.setOnMouseClicked(e -> {try {consulterSaCarte(compteur);} catch (IOException e1) {e1.printStackTrace();}});
|
||||
j++;
|
||||
}*/
|
||||
|
||||
/*
|
||||
//initialisation des pions
|
||||
VBox pionLieux14 = (VBox) lieux.getChildren().get(0);
|
||||
VBox pionLieux58 = (VBox) lieux.getChildren().get(4);
|
||||
for (int k=0; k<4; k++) {
|
||||
pionLieux.add((Circle) pionLieux14.getChildren().get(k));
|
||||
}
|
||||
for (int k=0; k<4; k++) {
|
||||
pionLieux.add((Circle) pionLieux58.getChildren().get(k));
|
||||
}
|
||||
|
||||
VBox pionVie14 = (VBox) lieux.getChildren().get(0);
|
||||
VBox pionVie58 = (VBox) lieux.getChildren().get(4);
|
||||
for (int k=0; k<4; k++) {
|
||||
pionVie.add((Circle) pionVie14.getChildren().get(k));
|
||||
}
|
||||
for (int k=0; k<4; k++) {
|
||||
pionVie.add((Circle) pionVie58.getChildren().get(k));
|
||||
}
|
||||
|
||||
System.out.println("Tour du joueur 1");
|
||||
|
||||
try {
|
||||
final URL fxmlURL = getClass().getResource("../ressources/Jouer_tour(1)lancer_des.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.ENGLISH);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
Pane root = fxmlLoader.load();
|
||||
root.setPrefSize(255, 180);
|
||||
tour.get(2).getChildren().setAll(root);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@ -207,12 +134,16 @@ public class PlateauController implements Initializable {
|
||||
}
|
||||
|
||||
private void applyImageLieu(ImageView iv, Image im) {
|
||||
|
||||
StackPane sp = (StackPane) iv.getParent();
|
||||
iv.setImage(im);
|
||||
iv.fitHeightProperty().bind(sp.heightProperty());
|
||||
}
|
||||
|
||||
iv.setImage(im);
|
||||
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
|
||||
iv.setFitWidth(RES*screenSize.width);
|
||||
//iv.fitHeightProperty().bind(sp.heightProperty());
|
||||
//iv.fitWidthProperty().bind(sp.widthProperty());
|
||||
|
||||
iv.setPreserveRatio(true);
|
||||
//iv.fitWidthProperty().bind(sp.widthProperty());
|
||||
}
|
||||
|
||||
private Pane getPaneJoueur(int i) {
|
||||
|
||||
@ -333,7 +264,7 @@ public class PlateauController implements Initializable {
|
||||
|
||||
this.ld=new LancerDes(typeDice,rolls,c);
|
||||
JoueurIHM jihm = getJoueurIHM(joueur);
|
||||
jihm.setZoneJoueur(ld.initLancer());
|
||||
jihm.setZoneJoueur(ld.initLancer(joueur));
|
||||
}
|
||||
|
||||
public void afficherChoisir(Joueur j, Contexte contexte) throws IOException {
|
||||
@ -342,17 +273,33 @@ public class PlateauController implements Initializable {
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
Pane root = (Pane)fxmlLoader.load();
|
||||
this.cb = fxmlLoader.getController();
|
||||
cb.setTitre(contexte);
|
||||
if(j instanceof JoueurVirtuel) {
|
||||
switch(contexte) {
|
||||
case ACTIVER_EFFET_LIEU :
|
||||
cb.fireBtnIAEffetLieu();
|
||||
break;
|
||||
case ATTAQUER :
|
||||
cb.fireBtnIAattaquer((JoueurVirtuel)j, j.getJoueursRange());
|
||||
break;
|
||||
case CHOISIR_VISION :
|
||||
cb.fireBtnIAVision();;
|
||||
break;
|
||||
}
|
||||
}
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.setZoneJoueur(root);
|
||||
}
|
||||
|
||||
|
||||
public void afficherChoisirEquipementVole(Joueur j) throws IOException {
|
||||
public void afficherChoisirEquipementVole(Joueur j, List<CarteEquipement> lce) throws IOException {
|
||||
final URL fxmlURL = getClass().getResource("/ihm/ressources/Jouer_tour(2a)voler_equipement.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
Pane root = (Pane)fxmlLoader.load();
|
||||
this.ce = fxmlLoader.getController();
|
||||
this.ce.setListCarteEquipements(lce);
|
||||
this.ce.initChoisirEquipement();
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.setZoneJoueur(root);
|
||||
}
|
||||
@ -369,7 +316,7 @@ public class PlateauController implements Initializable {
|
||||
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
Pane p = (Pane) jihm.getZoneJoueur();
|
||||
Pane pane = null;
|
||||
Pane pane = new Pane();
|
||||
|
||||
if(p.getChildren() != null && p.getChildren().size() > 0) {
|
||||
|
||||
@ -397,7 +344,20 @@ public class PlateauController implements Initializable {
|
||||
Pane root = (Pane)fxmlLoader.load();
|
||||
LieuZJ lzj = fxmlLoader.getController();
|
||||
lzj.setImageView(this.getImageCarte(j.getCarteLieu()));
|
||||
if(j instanceof JoueurVirtuel) lzj.fireBtnIA();
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
if(jihm.getPosition()==4 || jihm.getPosition()==5) {
|
||||
SplitPane s=(SplitPane)root.getChildren().get(0);
|
||||
AnchorPane a=(AnchorPane)s.getItems().get(0);
|
||||
VBox v= (VBox)a.getChildren().get(0);
|
||||
AnchorPane b=(AnchorPane)s.getItems().get(1);
|
||||
ImageView i= (ImageView)b.getChildren().get(0);
|
||||
|
||||
v.setRotate(180);
|
||||
i.setRotate(180);
|
||||
s.setRotate(180);
|
||||
}
|
||||
|
||||
jihm.setZoneJoueur(root);
|
||||
}
|
||||
public void afficherChoisirJoueur(Joueur j, List<Joueur> joueurs, Contexte contexte) throws IOException {
|
||||
@ -405,13 +365,42 @@ public class PlateauController implements Initializable {
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
Pane root = (Pane)fxmlLoader.load();
|
||||
|
||||
List<JoueurIHM> joueursIHM = toJoueursIHM(joueurs);
|
||||
|
||||
this.cj = fxmlLoader.getController();
|
||||
this.cj.setListJoueursIHM(this.joueursIHM);
|
||||
cj.setTitre(contexte);
|
||||
this.cj.setListJoueursIHM(joueursIHM);
|
||||
this.cj.initButtons();
|
||||
if(j instanceof JoueurVirtuel)
|
||||
cj.fireBtnIA((JoueurVirtuel)j, contexte);
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.setZoneJoueur(root);
|
||||
}
|
||||
public void afficherPiocher(Joueur j) throws IOException {
|
||||
private List<JoueurIHM> toJoueursIHM(List<Joueur> joueurs) {
|
||||
|
||||
List<JoueurIHM> list = new ArrayList<JoueurIHM>();
|
||||
|
||||
for(Joueur j : joueurs) {
|
||||
list.add(getJoueurIHM(j));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void afficherPiocher(Joueur j) throws IOException {
|
||||
|
||||
final URL fxmlURL = getClass().getResource("/ihm/ressources/Jouer_tour(2b)piocher_carte.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
Pane root = (Pane)fxmlLoader.load();
|
||||
//CartePiochable lzj = fxmlLoader.getController();
|
||||
//lzj.setImageView(this.getImageCarte(j.getCarteLieu()));
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.setZoneJoueur(root);
|
||||
}
|
||||
public void afficherEffet(Joueur j) throws IOException {
|
||||
|
||||
final URL fxmlURL = getClass().getResource("/ihm/ressources/Jouer_tour(2b)piocher_carte.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
@ -461,6 +450,7 @@ public class PlateauController implements Initializable {
|
||||
|
||||
public void updateVieJoueur(Joueur joueur, int damage) {
|
||||
JoueurIHM jIHM = getJoueurIHM(joueur);
|
||||
jIHM.getZoneJoueur().getChildren().setAll();
|
||||
jIHM.deplacerPionVie(damage);
|
||||
}
|
||||
|
||||
@ -481,13 +471,13 @@ public class PlateauController implements Initializable {
|
||||
}
|
||||
|
||||
|
||||
public Image getImageCarte(Carte carte) {
|
||||
BufferedImage bi = this.mapRessourcesCartes.get(carte);
|
||||
public static Image getImageCarte(Carte carte) {
|
||||
BufferedImage bi = mapRessourcesCartes.get(carte);
|
||||
return RessourceLoader.toJavaFX(bi);
|
||||
}
|
||||
|
||||
public Image getImageDosCarte(String s) {
|
||||
BufferedImage bi = this.mapRessourcesDosCartes.get(s);
|
||||
public static Image getImageDosCarte(String s) {
|
||||
BufferedImage bi = mapRessourcesDosCartes.get(s);
|
||||
return RessourceLoader.toJavaFX(bi);
|
||||
}
|
||||
|
||||
@ -501,7 +491,6 @@ public class PlateauController implements Initializable {
|
||||
public void retirerEquipement(Joueur j, CarteEquipement e) {
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.retirerEquipement(e);
|
||||
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
@ -524,8 +513,14 @@ public class PlateauController implements Initializable {
|
||||
pu.getStage().hide();
|
||||
}
|
||||
});
|
||||
|
||||
if(j instanceof JoueurVirtuel) {
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(3000), ae -> {
|
||||
pu.getStage().hide();
|
||||
}));
|
||||
timeline.play();
|
||||
}
|
||||
pu.display();
|
||||
|
||||
}
|
||||
|
||||
public void afficherVision(Joueur j, CartePiochable cartePiochable) throws IOException {
|
||||
@ -538,7 +533,20 @@ public class PlateauController implements Initializable {
|
||||
Image im = getImageCarte(cartePiochable);
|
||||
lzj.setImageView(im);
|
||||
lzj.setText("Cachez la carte vision");
|
||||
if(j instanceof JoueurVirtuel) lzj.fireBtnIA();
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
if(jihm.getPosition()==4 || jihm.getPosition()==5) {
|
||||
SplitPane s=(SplitPane)root.getChildren().get(0);
|
||||
AnchorPane a=(AnchorPane)s.getItems().get(0);
|
||||
VBox v= (VBox)a.getChildren().get(0);
|
||||
AnchorPane b=(AnchorPane)s.getItems().get(1);
|
||||
ImageView i= (ImageView)b.getChildren().get(0);
|
||||
|
||||
v.setRotate(180);
|
||||
i.setRotate(180);
|
||||
s.setRotate(180);
|
||||
}
|
||||
jihm.getZoneJoueur();
|
||||
jihm.setZoneJoueur(root);
|
||||
|
||||
}
|
||||
@ -552,4 +560,49 @@ public class PlateauController implements Initializable {
|
||||
public void setMapRessourcesDosCartes(Map<String,BufferedImage> mapRessourcesDosCartes) {
|
||||
this.mapRessourcesDosCartes = mapRessourcesDosCartes;
|
||||
}
|
||||
|
||||
|
||||
private Action choixAction;
|
||||
|
||||
public void afficherChoisirAction(Joueur joueur, List<Action> list) {
|
||||
|
||||
final URL fxmlURL = getClass().getResource("/ihm/ressources/ChoisirAction.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
|
||||
List<Button> buttons = new ArrayList<Button>();
|
||||
|
||||
for(Action a : list) {
|
||||
Button button = interpret(a);
|
||||
buttons.add(button);
|
||||
button.setOnAction(x -> {
|
||||
this.choixAction = a;
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
});
|
||||
}
|
||||
|
||||
VBox v = new VBox();
|
||||
v.getChildren().addAll(buttons);
|
||||
|
||||
JoueurIHM jihm = getJoueurIHM(joueur);
|
||||
jihm.setZoneJoueur(v);
|
||||
}
|
||||
|
||||
public Action getChoixAction(Joueur joueur) {
|
||||
return this.choixAction;
|
||||
}
|
||||
|
||||
|
||||
private Button interpret(Action a) {
|
||||
String s = a.toString();
|
||||
Button b = new Button(s);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
public void revealJoueur(Joueur joueur) {
|
||||
JoueurIHM jihm = getJoueurIHM(joueur);
|
||||
jihm.reveler();
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,9 @@ import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
@ -43,18 +45,48 @@ public class PlayersController implements Initializable{
|
||||
@FXML private HBox hb7;
|
||||
@FXML private HBox hb8;
|
||||
|
||||
|
||||
//pour les radios boutons
|
||||
@FXML private HBox hbr1;
|
||||
@FXML private HBox hbr2;
|
||||
@FXML private HBox hbr3;
|
||||
@FXML private HBox hbr4;
|
||||
@FXML private HBox hbr5;
|
||||
@FXML private HBox hbr6;
|
||||
@FXML private HBox hbr7;
|
||||
@FXML private HBox hbr8;
|
||||
|
||||
|
||||
@FXML private ToggleGroup tg1;
|
||||
@FXML private ToggleGroup tg2;
|
||||
@FXML private ToggleGroup tg3;
|
||||
@FXML private ToggleGroup tg4;
|
||||
@FXML private ToggleGroup tg5;
|
||||
@FXML private ToggleGroup tg6;
|
||||
@FXML private ToggleGroup tg7;
|
||||
@FXML private ToggleGroup tg8;
|
||||
|
||||
|
||||
private List<HBox> ligne = new ArrayList<HBox>();
|
||||
private List<Button> plus = new ArrayList<Button>();
|
||||
private List<TextField> txt = new ArrayList<TextField>();
|
||||
private List<CheckBox> ia = new ArrayList<CheckBox>();
|
||||
|
||||
private List<HBox> listeHbIA = new ArrayList<HBox>();
|
||||
private List<RadioButton> listeIaLv1 = new ArrayList<RadioButton>();
|
||||
private List<RadioButton> listeIaLv2 = new ArrayList<RadioButton>();
|
||||
private List<RadioButton> listeIaLv3 = new ArrayList<RadioButton>();
|
||||
|
||||
private List<ToggleGroup> listeToggleRbIa = new ArrayList<ToggleGroup>();
|
||||
|
||||
|
||||
private HashMap<Integer, Couple> joueurs = new HashMap<Integer, Couple>();
|
||||
|
||||
private int nbJoueursH = 0;
|
||||
private int nbJoueursV = 0;
|
||||
|
||||
/**
|
||||
* recup<EFBFBD>re chaque bouton textField et Checkebox a partir des hbox
|
||||
* recupère chaque bouton textField et Checkebox à partir des hbox
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
@ -66,12 +98,44 @@ public class PlayersController implements Initializable{
|
||||
ligne.add(hb6);
|
||||
ligne.add(hb7);
|
||||
ligne.add(hb8);
|
||||
|
||||
listeHbIA.add(hbr1);
|
||||
listeHbIA.add(hbr2);
|
||||
listeHbIA.add(hbr3);
|
||||
listeHbIA.add(hbr4);
|
||||
listeHbIA.add(hbr5);
|
||||
listeHbIA.add(hbr6);
|
||||
listeHbIA.add(hbr7);
|
||||
listeHbIA.add(hbr8);
|
||||
|
||||
|
||||
listeToggleRbIa.add(tg1);
|
||||
listeToggleRbIa.add(tg2);
|
||||
listeToggleRbIa.add(tg3);
|
||||
listeToggleRbIa.add(tg4);
|
||||
listeToggleRbIa.add(tg5);
|
||||
listeToggleRbIa.add(tg6);
|
||||
listeToggleRbIa.add(tg7);
|
||||
listeToggleRbIa.add(tg8);
|
||||
|
||||
|
||||
|
||||
for (HBox hb : ligne) {
|
||||
txt.add((TextField) hb.getChildren().get(0));
|
||||
plus.add((Button) hb.getChildren().get(1));
|
||||
ia.add((CheckBox) hb.getChildren().get(2));
|
||||
}
|
||||
|
||||
for (HBox hbr : listeHbIA) {
|
||||
listeIaLv1.add((RadioButton) hbr.getChildren().get(0));
|
||||
listeIaLv2.add((RadioButton) hbr.getChildren().get(1));
|
||||
listeIaLv3.add((RadioButton) hbr.getChildren().get(2));
|
||||
|
||||
hbr.getChildren().get(0).setVisible(false);
|
||||
hbr.getChildren().get(1).setVisible(false);
|
||||
hbr.getChildren().get(2).setVisible(false);
|
||||
}
|
||||
|
||||
int i=0;
|
||||
for (Button btn : plus) {
|
||||
int compteur = i;
|
||||
@ -106,10 +170,10 @@ public class PlayersController implements Initializable{
|
||||
CheckBox cb = (CheckBox) hb.getChildren().get(2);
|
||||
if (tf.isEditable()) {
|
||||
if(cb.isSelected()) {
|
||||
joueurs.put(i, new Couple(tf.getText(), true));
|
||||
joueurs.put(i, new Couple(tf.getText(), choixDifficulte(listeToggleRbIa.get(i))));
|
||||
}
|
||||
else {
|
||||
joueurs.put(i, new Couple(tf.getText(), false));
|
||||
joueurs.put(i, new Couple(tf.getText()));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
@ -170,6 +234,12 @@ public class PlayersController implements Initializable{
|
||||
plus.get(indice).setOnAction(e -> {enleverJoueur(indice);});
|
||||
|
||||
if (ia.get(indice).isSelected()) {
|
||||
|
||||
listeIaLv1.get(indice).setVisible(true);
|
||||
listeIaLv2.get(indice).setVisible(true);
|
||||
listeIaLv3.get(indice).setVisible(true);
|
||||
|
||||
|
||||
nbJoueursV++;
|
||||
}else {
|
||||
nbJoueursH++;
|
||||
@ -197,16 +267,47 @@ public class PlayersController implements Initializable{
|
||||
txt.get(indice).setStyle("-fx-background-color: silver;");
|
||||
plus.get(indice).setOnAction(e -> {ajoutJoueur(indice);});
|
||||
|
||||
if (ia.get(indice).isSelected())
|
||||
if (ia.get(indice).isSelected()) {
|
||||
nbJoueursV--;
|
||||
else
|
||||
}
|
||||
|
||||
else {
|
||||
nbJoueursH--;
|
||||
}
|
||||
|
||||
|
||||
listeIaLv1.get(indice).setVisible(false);
|
||||
listeIaLv2.get(indice).setVisible(false);
|
||||
listeIaLv3.get(indice).setVisible(false);
|
||||
|
||||
|
||||
if (nbJoueursH + nbJoueursV < 4) {
|
||||
btnCommencer.setStyle("-fx-background-color: gray; -fx-text-fill: black;");
|
||||
}
|
||||
}
|
||||
|
||||
public int choixDifficulte(ToggleGroup tog) {
|
||||
if(tog.getSelectedToggle() == tog.getToggles().get(0)) {
|
||||
System.out.println("ia facile");
|
||||
return 1;
|
||||
}
|
||||
|
||||
else if (tog.getSelectedToggle() == tog.getToggles().get(1)) {
|
||||
System.out.println("ia moyenne");
|
||||
return 2;
|
||||
}
|
||||
|
||||
else if (tog.getSelectedToggle() == tog.getToggles().get(2)) {
|
||||
System.out.println("ia difficile");
|
||||
return 3;
|
||||
}
|
||||
|
||||
else {
|
||||
System.out.println("erreur choix difficulté de l'ia");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void mettreNomDefaut(int indice) {
|
||||
if (ia.get(indice).isSelected()) {
|
||||
ajoutJoueur(indice);
|
||||
|
@ -1,9 +1,10 @@
|
||||
package ihm.controller;
|
||||
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
@ -16,32 +17,44 @@ import javafx.scene.layout.BackgroundImage;
|
||||
import javafx.scene.layout.BackgroundPosition;
|
||||
import javafx.scene.layout.BackgroundRepeat;
|
||||
import javafx.scene.layout.BackgroundSize;
|
||||
import javafx.util.Duration;
|
||||
import main.GestionnaireJeu;
|
||||
|
||||
public class RecevoirCarte implements Initializable {
|
||||
@FXML private Button okButton;
|
||||
@FXML private Label label;
|
||||
@FXML private ImageView imageView;
|
||||
@FXML
|
||||
private Button okButton;
|
||||
@FXML
|
||||
private Label label;
|
||||
@FXML
|
||||
private ImageView imageView;
|
||||
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
|
||||
|
||||
okButton.setOnAction(x -> {
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setText(String name) {
|
||||
this.label.setText(name);
|
||||
}
|
||||
|
||||
|
||||
public void setImageView(Image imageCarte) {
|
||||
AnchorPane ap = (AnchorPane) imageView.getParent();
|
||||
|
||||
BackgroundImage myBI= new BackgroundImage(imageCarte,
|
||||
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,
|
||||
new BackgroundSize(BackgroundSize.AUTO,1.0,true,true,false,false));
|
||||
|
||||
BackgroundImage myBI = new BackgroundImage(imageCarte, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundPosition.DEFAULT, new BackgroundSize(BackgroundSize.AUTO, 1.0, true, true, false, false));
|
||||
ap.setBackground(new Background(myBI));
|
||||
}
|
||||
|
||||
public void fireBtnIA() {
|
||||
okButton.setDisable(true);
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(2000), ae -> {
|
||||
okButton.setDisable(false);
|
||||
okButton.fire();
|
||||
}));
|
||||
timeline.play();
|
||||
}
|
||||
}
|
||||
|
11
src/ihm/ressources/ChoisirAction.fxml
Normal file
11
src/ihm/ressources/ChoisirAction.fxml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" styleClass="background" stylesheets="@style/plateau.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.ressources.ChoisirAction">
|
||||
<children>
|
||||
<VBox alignment="CENTER" layoutX="-126.0" layoutY="92.0" prefHeight="200.0" prefWidth="226.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
@ -1,27 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="210.0" prefWidth="260.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ChoisirEquipement">
|
||||
<AnchorPane stylesheets="@style/plateau.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ChoisirEquipement">
|
||||
<children>
|
||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" stylesheets="@style/popUp.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<VBox alignment="CENTER" spacing="10.0" styleClass="background" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Label layoutX="58.0" layoutY="14.0" text="%voler.equipement.joueur" />
|
||||
<ScrollPane layoutX="28.0" layoutY="38.0">
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" styleClass="text" text="%voler.equipement.joueur" />
|
||||
<ScrollPane fx:id="scrollpane" fitToHeight="true" fitToWidth="true" prefHeight="144.0" prefWidth="144.0" vbarPolicy="NEVER" VBox.vgrow="SOMETIMES">
|
||||
<content>
|
||||
<HBox>
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="hbox" styleClass="background" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
</Pane>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</VBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
@ -252,7 +252,7 @@
|
||||
<Insets bottom="25.0" />
|
||||
</padding>
|
||||
</GridPane>
|
||||
<HBox alignment="CENTER" prefHeight="366.0" prefWidth="1125.0" spacing="50.0">
|
||||
<HBox alignment="CENTER" maxWidth="1280.0" spacing="50.0">
|
||||
<children>
|
||||
<VBox alignment="TOP_CENTER">
|
||||
<children>
|
||||
@ -290,14 +290,14 @@
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" spacing="50.0">
|
||||
<children>
|
||||
<GridPane alignment="CENTER" hgap="20.0">
|
||||
<GridPane alignment="CENTER" hgap="20.0" maxHeight="-Infinity" prefHeight="250.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="ALWAYS" />
|
||||
<ColumnConstraints />
|
||||
<ColumnConstraints hgrow="ALWAYS" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints />
|
||||
<RowConstraints vgrow="ALWAYS" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<GridPane>
|
||||
@ -324,21 +324,21 @@
|
||||
<ColumnConstraints />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints />
|
||||
<RowConstraints vgrow="ALWAYS" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<HBox alignment="TOP_CENTER" maxHeight="-Infinity" maxWidth="-Infinity" spacing="5.0" styleClass="lieux" stylesheets="@style/plateau.css">
|
||||
<HBox alignment="CENTER" spacing="5.0" styleClass="lieux" stylesheets="@style/plateau.css">
|
||||
<children>
|
||||
<StackPane HBox.hgrow="NEVER">
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="77.0" pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane prefHeight="150.0" prefWidth="63.0" styleClass="lieu" />
|
||||
<ImageView pickOnBounds="true" preserveRatio="true" StackPane.alignment="CENTER" />
|
||||
<FlowPane styleClass="lieu" />
|
||||
</children>
|
||||
</StackPane>
|
||||
<StackPane layoutX="39.0" layoutY="12.0" HBox.hgrow="NEVER">
|
||||
<StackPane layoutX="39.0" layoutY="12.0" maxHeight="360.0" HBox.hgrow="NEVER">
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="40.0" pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane prefHeight="150.0" prefWidth="13.0" />
|
||||
<ImageView pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane />
|
||||
</children>
|
||||
</StackPane>
|
||||
</children>
|
||||
@ -353,14 +353,14 @@
|
||||
<children>
|
||||
<StackPane HBox.hgrow="NEVER">
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="98.0" pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane prefHeight="150.0" prefWidth="64.0" />
|
||||
<ImageView pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane />
|
||||
</children>
|
||||
</StackPane>
|
||||
<StackPane HBox.hgrow="NEVER">
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="93.0" pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane prefHeight="150.0" prefWidth="69.0" />
|
||||
<ImageView pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane />
|
||||
</children>
|
||||
</StackPane>
|
||||
</children>
|
||||
@ -370,16 +370,16 @@
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" spacing="5.0" styleClass="lieux" stylesheets="@style/plateau.css" GridPane.columnIndex="2">
|
||||
<children>
|
||||
<StackPane HBox.hgrow="NEVER">
|
||||
<StackPane maxHeight="360.0" HBox.hgrow="NEVER">
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="111.0" pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane prefHeight="150.0" prefWidth="81.0" />
|
||||
<ImageView pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane />
|
||||
</children>
|
||||
</StackPane>
|
||||
<StackPane HBox.hgrow="NEVER">
|
||||
<StackPane maxHeight="360.0" HBox.hgrow="NEVER">
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="125.0" pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane prefHeight="150.0" prefWidth="113.0" />
|
||||
<ImageView pickOnBounds="true" preserveRatio="true" />
|
||||
<FlowPane />
|
||||
</children>
|
||||
</StackPane>
|
||||
</children>
|
||||
|
Reference in New Issue
Block a user