Merge branch 'development' of https://github.com/PTE-SH/ShadowHunterGame into development
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package ihm.controller;
|
||||
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -28,6 +29,7 @@ import javafx.fxml.Initializable;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Parent;
|
||||
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;
|
||||
@@ -66,6 +68,8 @@ public class PlateauController implements Initializable {
|
||||
public static int DICE_QUATRE = 0;
|
||||
public static int DICE_BOTH = 2;
|
||||
|
||||
private final double RES = 200./2250.;
|
||||
|
||||
/**
|
||||
* initialise les données du plateau
|
||||
*/
|
||||
@@ -104,88 +108,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();
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@@ -211,9 +133,14 @@ public class PlateauController implements Initializable {
|
||||
|
||||
StackPane sp = (StackPane) iv.getParent();
|
||||
iv.setImage(im);
|
||||
iv.fitHeightProperty().bind(sp.heightProperty());
|
||||
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) {
|
||||
|
||||
@@ -415,6 +342,18 @@ public class PlateauController implements Initializable {
|
||||
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 {
|
||||
@@ -457,6 +396,17 @@ public class PlateauController implements Initializable {
|
||||
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);
|
||||
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 CarteEquipement getChoixEquipementVole(Joueur joueur) {
|
||||
JoueurIHM jihm = getJoueurIHM(joueur);
|
||||
@@ -574,6 +524,18 @@ public class PlateauController implements Initializable {
|
||||
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);
|
||||
|
||||
}
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user