diff --git a/README.md b/README.md index beb148f..c74bdb0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,13 @@ Pour gagner, les Hunters et Shadow doivent éliminer tous les personnages du cam ## Comment l'utiliser -Vous trouverez la documentation pour utliser notre application [ici]. +Dans un premier temps, vous pouvez télécharger la dernière version de notre application en utilisant la commande : + +```git clone https://github.com/PTE-SH/ShadowHunterGame.git``` + +Puis, il faut executez le ``ShadowHunterGame.exe`` pour pouvoir y jouer. + +Ce projet repose sur le [Java JDK 11](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) pour pouvoir fonctionner. ## Auteurs diff --git a/src/database/DatabaseManager.java b/src/database/DatabaseManager.java new file mode 100644 index 0000000..e3f2a72 --- /dev/null +++ b/src/database/DatabaseManager.java @@ -0,0 +1,39 @@ +package database; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +public class DatabaseManager { + + private final static String url = "jdbc:postgresql://localhost:5432/ShadowHunterDatabase"; + private final static String user = "shManager"; + private final static String password = "shadowhunter1234"; + + public static Connection connect() throws SQLException { + return DriverManager.getConnection(url, user, password); + } + + public static List remplirTable(String query) { + List list = new ArrayList(); + try (Connection connection = connect()) { + + //System.out.println("Connected to PostgreSQL database!"); + Statement statement = connection.createStatement(); + //System.out.println("Reading records..."); + ResultSet retour = statement.executeQuery(query); + while (retour.next()) { + list.add(new Record(retour.getString("id"), retour.getString("nom"), retour.getBytes("image"), retour.getBytes("objet"))); + } + } catch (SQLException e) { + System.err.println("Connection failure."); + e.printStackTrace(); + } + return list; + } + +} diff --git a/src/database/DatabaseTesting.java b/src/database/DatabaseTesting.java index 2861320..18684ed 100644 --- a/src/database/DatabaseTesting.java +++ b/src/database/DatabaseTesting.java @@ -1,44 +1,14 @@ package database; -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.File; import java.io.IOException; -import javax.imageio.ImageIO; - -/* -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -*/ - public class DatabaseTesting { public static void main(String[] args) throws IOException { Table a = new Table("a"); - a.remplirTableAllFrom("CartesAll"); + + a.fillList(QueryGenerator.AllFrom("CartesAll")); System.out.println(a.toString()); - //a.getList().get(1).getImg() - - - BufferedImage image = ImageIO.read( new ByteArrayInputStream( a.getList().get(1).getImg() ) ); - ImageIO.write(image, "JPG", new File("filename.jpg")); - - /* - * PreparedStatement ps = conn.prepareStatement("SELECT img FROM images WHERE imgname = ?"); -ps.setString(1, "myimage.gif"); -ResultSet rs = ps.executeQuery(); -while (rs.next()) { - byte[] imgBytes = rs.getBytes(1); OR byte []out = (byte[])(rs.getObject(1)); - // use the data in some way here -} -rs.close(); -ps.close();*/ - - } diff --git a/src/database/Record.java b/src/database/Record.java index f24f7a5..da4cbec 100644 --- a/src/database/Record.java +++ b/src/database/Record.java @@ -9,6 +9,7 @@ public class Record { public Record() { this("0", "", null); + } public Record(String n, byte[] b) { @@ -22,6 +23,7 @@ public class Record { this.img = b; } + public Record(String i, String n, byte[] b, byte[] obj) { this.id = i; this.nom = n; @@ -40,9 +42,10 @@ public class Record { public byte[] getImg() { return img; } - + + @Override public String toString() { - return String.format("%-20.30s %-30.30s %-20.30s%n", this.getId(), this.getNom(), this.getImg()); + return String.format("%-20.30s %-30.30s %-20.30s %-20.30s%n", this.getId(), this.getNom(), this.getImg(), this.getObjet()); } public byte[] getObjet() { diff --git a/src/database/Table.java b/src/database/Table.java index 4ee0cc6..ce53f44 100644 --- a/src/database/Table.java +++ b/src/database/Table.java @@ -21,55 +21,8 @@ public class Table { this.name = JavaTableName; } - public void remplirTableAllFrom(String DatabaseTableName) { - try (Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/ShadowHunterDatabase", "shManager", "shadowhunter1234")) { //notre utilisateur que l'on utilisera (: - - System.out.println("Connected to PostgreSQL database!"); - Statement statement = connection.createStatement(); - System.out.println("Reading records..."); - ResultSet retour = statement.executeQuery(QueryGenerator.AllFrom(DatabaseTableName)); - while (retour.next()) { - list.add(new Record(retour.getString("id"), retour.getString("nom"), retour.getBytes("image"))); - } - - } catch (SQLException e) { - System.out.println("Connection failure."); - e.printStackTrace(); - } - } - - public void remplirTableWithId(String DatabaseTableName, int id) { - try (Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/ShadowHunterDatabase", "shManager", "shadowhunter1234")) { //notre utilisateur que l'on utilisera (: - - System.out.println("Connected to PostgreSQL database!"); - Statement statement = connection.createStatement(); - System.out.println("Reading records..."); - ResultSet retour = statement.executeQuery(QueryGenerator.WithId(DatabaseTableName, id)); - while (retour.next()) { - list.add(new Record(retour.getString("id"), retour.getString("nom"), retour.getBytes("image"))); - } - - } catch (SQLException e) { - System.out.println("Connection failure."); - e.printStackTrace(); - } - } - - public void remplirTableWithName(String DatabaseTableName, String s) { - try (Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/ShadowHunterDatabase", "shManager", "shadowhunter1234")) { //notre utilisateur que l'on utilisera (: - - System.out.println("Connected to PostgreSQL database!"); - Statement statement = connection.createStatement(); - System.out.println("Reading records..."); - ResultSet retour = statement.executeQuery(QueryGenerator.WithName(DatabaseTableName, s)); - while (retour.next()) { - list.add(new Record(retour.getString("id"), retour.getString("nom"), retour.getBytes("image"))); - } - - } catch (SQLException e) { - System.out.println("Connection failure."); - e.printStackTrace(); - } + public void fillList(String query) { + this.list = DatabaseManager.remplirTable(query); } public void remplirTableQuery(String query) { @@ -89,23 +42,23 @@ public class Table { } } - public String getName() { + protected String getName() { return name; } - public void setName(String name) { + protected void setName(String name) { this.name = name; } - public List getList() { + protected List getList() { return list; } public String toString() { - return " " + this.getList(); + return this.getList().toString(); } - public boolean isEmpty() { + protected boolean isEmpty() { if(list.isEmpty()) { return true; } else { diff --git a/src/ihm/Main.java b/src/ihm/Main.java index 047d8f3..6f9f30e 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -16,8 +16,7 @@ import main.GestionnaireJeu; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception { - - final URL fxmlURL = getClass().getResource("ressources/Menu.fxml"); + final URL fxmlURL = getClass().getResource("ressources/Menu.fxml"); final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE); final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); Pane root = fxmlLoader.load(); @@ -30,7 +29,7 @@ public class Main extends Application { public void handle(WindowEvent arg0) { System.exit(0); } - }); + }); primaryStage.setMaximized(true); primaryStage.show(); } diff --git a/src/ihm/controller/ChoisirEquipement.java b/src/ihm/controller/ChoisirEquipement.java index 7b164ca..f27f1df 100644 --- a/src/ihm/controller/ChoisirEquipement.java +++ b/src/ihm/controller/ChoisirEquipement.java @@ -1,24 +1,62 @@ package ihm.controller; +import java.io.InputStream; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.ResourceBundle; -import carte.CarteEquipement; import javafx.fxml.FXML; import javafx.fxml.Initializable; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import javafx.scene.layout.GridPane; -import main.Joueur; +import carte.CarteEquipement; public class ChoisirEquipement implements Initializable{ - @FXML private GridPane equipement; + @FXML private GridPane grilleEquipement; - private Joueur joueurVole; - private CarteEquipement equipementVole; + private List equipements = new ArrayList(); + private CarteEquipement equipementSelected; @Override public void initialize(URL arg0, ResourceBundle arg1) { - // TODO Auto-generated method stub - + for (int i=0; i { + equipementSelected = equipements.get(numEquipement); + }); + } + } + + public List getEquipements() { + return equipements; + } + + public void setEquipements(List equipements) { + this.equipements = equipements; + } + + public CarteEquipement getEquipementSelected() { + return equipementSelected; + } + + public void setEquipementSelected(CarteEquipement equipementSelected) { + this.equipementSelected = equipementSelected; + } + + public GridPane getGrilleEquipement() { + return grilleEquipement; + } + + public void setGrilleEquipement(GridPane grilleEquipement) { + this.grilleEquipement = grilleEquipement; } } diff --git a/src/ihm/controller/ChoisirJoueur.java b/src/ihm/controller/ChoisirJoueur.java index 4d2e971..2991b00 100644 --- a/src/ihm/controller/ChoisirJoueur.java +++ b/src/ihm/controller/ChoisirJoueur.java @@ -20,13 +20,15 @@ public class ChoisirJoueur implements Initializable{ for (int i=0; i { + System.out.println("Vous avez choisi le joueur " + (numJoueur+1)); this.joueurSelected = numJoueur; }); } for (int i=0; i { + int numJoueur = i+4; + joueurBas.getChildren().get(i).setOnMouseClicked(e -> { + System.out.println("Vous avez choisi le joueur " + (numJoueur+1)); this.joueurSelected = numJoueur; }); } diff --git a/src/ihm/controller/JouerSonTour2Controller.java b/src/ihm/controller/JouerSonTour2Controller.java deleted file mode 100644 index 6d47e56..0000000 --- a/src/ihm/controller/JouerSonTour2Controller.java +++ /dev/null @@ -1,9 +0,0 @@ -package ihm.controller; - -public class JouerSonTour2Controller extends ChoisirBoolean{ - public void initButtons () { - super.getOuiButton().setText("utiliser.capaciter.lieux"); - super.getNonButton().setText("sauter.etape"); - super.getTitre().setText("description.capacite.carte.lieux"); - } -} \ No newline at end of file diff --git a/src/ihm/controller/JouerSonTour2c1Controller.java b/src/ihm/controller/JouerSonTour2c1Controller.java deleted file mode 100644 index fb28624..0000000 --- a/src/ihm/controller/JouerSonTour2c1Controller.java +++ /dev/null @@ -1,9 +0,0 @@ -package ihm.controller; - -public class JouerSonTour2c1Controller extends ChoisirBoolean{ - public void initButtons () { - super.getOuiButton().setText("Attaquer !"); - super.getNonButton().setText("se.soigner"); - super.getTitre().setText("attaquer.ou.soigner"); - } -} diff --git a/src/ihm/controller/JouerSonTour3Controller.java b/src/ihm/controller/JouerSonTour3Controller.java deleted file mode 100644 index 9654a02..0000000 --- a/src/ihm/controller/JouerSonTour3Controller.java +++ /dev/null @@ -1,9 +0,0 @@ -package ihm.controller; - -public class JouerSonTour3Controller extends ChoisirBoolean{ - public void initButtons () { - super.getOuiButton().setText("Attaquer !"); - super.getNonButton().setText("Ne pas attaquer"); - super.getTitre().setText("Voulez-vous attaquer un joueur ?"); - } -} diff --git a/src/ihm/controller/JouerSonTour4Controller.java b/src/ihm/controller/JouerSonTour4Controller.java index 7018ffa..a9d8064 100644 --- a/src/ihm/controller/JouerSonTour4Controller.java +++ b/src/ihm/controller/JouerSonTour4Controller.java @@ -15,6 +15,6 @@ public class JouerSonTour4Controller extends LancerDes{ @Override public void initialize(URL arg0, ResourceBundle arg1) { super.initialize(arg0, arg1); - defenseur.setText(j.getNom()); + //defenseur.setText(j.getNom()); } } diff --git a/src/ihm/controller/LancerDes.java b/src/ihm/controller/LancerDes.java index 79c0c3c..5a99d58 100644 --- a/src/ihm/controller/LancerDes.java +++ b/src/ihm/controller/LancerDes.java @@ -14,8 +14,13 @@ public class LancerDes implements Initializable{ @FXML private Button btnStop; @FXML private Button btnLancer; + private int[] valeurD6 = {1, 2, 3, 4, 5, 6}; + private int[] valeurD4 = {1, 2, 3, 4}; + private int resultatD6; private int resultatD4; + + private boolean lancement = true; @Override public void initialize(URL arg0, ResourceBundle arg1) { @@ -23,27 +28,30 @@ public class LancerDes implements Initializable{ btnStop.setVisible(false); btnLancer.setOnAction(e -> { - lancement(); - btnLancer.setVisible(false); - btnStop.setVisible(true); + try { + btnLancer.setVisible(false); + btnStop.setVisible(true); + lancement(); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } }); btnStop.setOnAction(e -> { //à remplir avec les valeurs donné par le gestionnaire de jeux + lancement = false; d6.setText(Integer.toString(resultatD6)); d4.setText(Integer.toString(resultatD4)); }); } - public void lancement() { - /*for (int i=1; i<7; i++) { - Thread.sleep(500); - d6.setText(Integer.toString(i)); - } - - for (int i=1; i<5; i++) { - Thread.sleep(500); - d4.setText(Integer.toString(i)); + public void lancement() throws InterruptedException { + /*int i=0; + while (lancement) { + d6.setText(Integer.toString(valeurD6[i%6])); + d4.setText(Integer.toString(valeurD4[i%4])); + i++; + //Thread.sleep(500); }*/ } } diff --git a/src/ihm/controller/PiocherCarte.java b/src/ihm/controller/PiocherCarte.java new file mode 100644 index 0000000..e67c1ff --- /dev/null +++ b/src/ihm/controller/PiocherCarte.java @@ -0,0 +1,40 @@ +package ihm.controller; + +import java.net.URL; +import java.util.ResourceBundle; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; + +import main.Type; +import main.TypeLumiere; +import main.TypeTenebre; +import main.TypeVision; + +public class PiocherCarte implements Initializable{ + @FXML private Button lumiere; + @FXML private Button vision; + @FXML private Button tenebre; + + private Type carte; + + @Override + public void initialize(URL arg0, ResourceBundle arg1) { + lumiere.setOnAction(e ->{ + carte = new TypeLumiere(); + }); + + vision.setOnAction(e -> { + carte = new TypeVision(); + }); + + tenebre.setOnAction(e -> { + carte = new TypeTenebre(); + }); + } + + public Type getCarte() { + return carte; + } +} diff --git a/src/ihm/controller/VisualiserCarte.java b/src/ihm/controller/VisualiserCarte.java new file mode 100644 index 0000000..aa0862c --- /dev/null +++ b/src/ihm/controller/VisualiserCarte.java @@ -0,0 +1,69 @@ +package ihm.controller; + +import java.net.URL; +import java.util.ResourceBundle; + +import carte.Carte; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Label; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; + +public class VisualiserCarte implements Initializable{ + @FXML private Label typeCarte; + @FXML private Label effetCarte; + @FXML private ImageView imageCarte; + + private Carte carte; + + @Override + public void initialize(URL arg0, ResourceBundle arg1) { + /*typeCarte.setText(carte.getNom()); + effetCarte.setText(carte.getDescription());*/ + } + + /** + * signe la fin du tour + * @param mouseEvent click n'importe ou sur la fenetre + */ + @FXML + private void fin (MouseEvent mouseEvent) { + + } + + public Label getTypeCarte() { + return typeCarte; + } + + public void setTypeCarte(Label typeCarte) { + this.typeCarte = typeCarte; + } + + public Label getEffetCarte() { + return effetCarte; + } + + public void setEffetCarte(Label effetCarte) { + this.effetCarte = effetCarte; + } + + public ImageView getImageCarte() { + return imageCarte; + } + + public void setImageCarte(ImageView imageCarte) { + this.imageCarte = imageCarte; + } + + public Carte getCarte() { + return carte; + } + + public void setCarte(Carte carte) { + this.carte = carte; + } + + + +} diff --git a/src/ihm/controller/VisualiserCarteVision.java b/src/ihm/controller/VisualiserCarteVision.java new file mode 100644 index 0000000..a422ed8 --- /dev/null +++ b/src/ihm/controller/VisualiserCarteVision.java @@ -0,0 +1,12 @@ +package ihm.controller; + +import javafx.fxml.FXML; +import javafx.scene.input.MouseEvent; + +public class VisualiserCarteVision extends VisualiserCarte{ + @FXML + public void voirCarte(MouseEvent mouseEvent) { + //super.getImageCarte().setImage(arg0); + System.out.println("\tCarte vision"); + } +} diff --git a/src/ihm/ressources/Dés.fxml b/src/ihm/ressources/Dés.fxml deleted file mode 100644 index 3c2699a..0000000 --- a/src/ihm/ressources/Dés.fxml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/ihm/ressources/Jouer_tour(2)carte_lieux.fxml b/src/ihm/ressources/Jouer_tour(2)carte_lieux.fxml index 847be7e..3afb9e7 100644 --- a/src/ihm/ressources/Jouer_tour(2)carte_lieux.fxml +++ b/src/ihm/ressources/Jouer_tour(2)carte_lieux.fxml @@ -8,7 +8,7 @@ - + diff --git a/src/ihm/ressources/Jouer_tour(2a)voler_equipement.fxml b/src/ihm/ressources/Jouer_tour(2a)voler_equipement.fxml index b710284..3b4d2b6 100644 --- a/src/ihm/ressources/Jouer_tour(2a)voler_equipement.fxml +++ b/src/ihm/ressources/Jouer_tour(2a)voler_equipement.fxml @@ -14,9 +14,9 @@ diff --git a/src/ihm/ressources/Jouer_tour(2b)piocher_carte.fxml b/src/ihm/ressources/Jouer_tour(2b)piocher_carte.fxml index f626870..0db53ce 100644 --- a/src/ihm/ressources/Jouer_tour(2b)piocher_carte.fxml +++ b/src/ihm/ressources/Jouer_tour(2b)piocher_carte.fxml @@ -1,15 +1,44 @@ + + + - - + - diff --git a/src/ihm/ressources/Jouer_tour(2ba)piocher_lumiere_tenebre.fxml b/src/ihm/ressources/Jouer_tour(2ba)piocher_lumiere_tenebre.fxml index fe808d0..4b53126 100644 --- a/src/ihm/ressources/Jouer_tour(2ba)piocher_lumiere_tenebre.fxml +++ b/src/ihm/ressources/Jouer_tour(2ba)piocher_lumiere_tenebre.fxml @@ -7,24 +7,23 @@ - - + - + - + diff --git a/src/ihm/ressources/Jouer_tour(2bb1)piocher_vision.fxml b/src/ihm/ressources/Jouer_tour(2bb1)piocher_vision.fxml index dc7f7db..62a765e 100644 --- a/src/ihm/ressources/Jouer_tour(2bb1)piocher_vision.fxml +++ b/src/ihm/ressources/Jouer_tour(2bb1)piocher_vision.fxml @@ -8,15 +8,14 @@ - - + - - + + + + + + + + + + diff --git a/src/ihm/ressources/Jouer_tour(2c1)attaquer_soigner.fxml b/src/ihm/ressources/Jouer_tour(2c1)attaquer_soigner.fxml index 12573b8..52b1728 100644 --- a/src/ihm/ressources/Jouer_tour(2c1)attaquer_soigner.fxml +++ b/src/ihm/ressources/Jouer_tour(2c1)attaquer_soigner.fxml @@ -5,7 +5,7 @@ - + diff --git a/src/ihm/ressources/Jouer_tour(2c2)choisir_joueur.fxml b/src/ihm/ressources/Jouer_tour(2c2)choisir_joueur.fxml index e69de29..05f086a 100644 --- a/src/ihm/ressources/Jouer_tour(2c2)choisir_joueur.fxml +++ b/src/ihm/ressources/Jouer_tour(2c2)choisir_joueur.fxml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ihm/ressources/Jouer_tour(3a)attaquer.fxml b/src/ihm/ressources/Jouer_tour(3a)attaquer.fxml index f1ee422..8ec1254 100644 --- a/src/ihm/ressources/Jouer_tour(3a)attaquer.fxml +++ b/src/ihm/ressources/Jouer_tour(3a)attaquer.fxml @@ -4,7 +4,7 @@ - +