Merge branch 'development' of https://github.com/PTE-SH/ShadowHunterGame into development
This commit is contained in:
21
src/database/QueryGenerator.java
Normal file
21
src/database/QueryGenerator.java
Normal file
@ -0,0 +1,21 @@
|
||||
package database;
|
||||
|
||||
public class QueryGenerator {
|
||||
|
||||
public static String AllFrom(String table) {
|
||||
return "SELECT * FROM " + getTable(table);
|
||||
}
|
||||
|
||||
public static String WithId(String table, int d) {
|
||||
return "SELECT * FROM " + getTable(table) + "WHERE id =" + d;
|
||||
}
|
||||
|
||||
public static String WithName(String s, String name) {
|
||||
return "SELECT * FROM " + getTable(s) + "WHERE nom ='" + name + "'";
|
||||
}
|
||||
|
||||
public static String getTable(String s) {
|
||||
return "public.\"" + s + "\"";
|
||||
}
|
||||
|
||||
}
|
40
src/database/Record.java
Normal file
40
src/database/Record.java
Normal file
@ -0,0 +1,40 @@
|
||||
package database;
|
||||
|
||||
public class Record {
|
||||
|
||||
private int id;
|
||||
private String nom;
|
||||
private byte[] img;
|
||||
|
||||
public Record() {
|
||||
this(0, null, null);
|
||||
}
|
||||
|
||||
public Record(String n, byte[] b) {
|
||||
this(0, n, b);
|
||||
}
|
||||
|
||||
public Record(String number, String n, byte[] b) {
|
||||
this(Integer.parseInt(number), n, b);
|
||||
}
|
||||
|
||||
public Record(int i, String n, byte[] b) {
|
||||
this.id = i;
|
||||
this.nom = n;
|
||||
this.img = b;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public byte[] getImg() {
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
}
|
56
src/database/Table.java
Normal file
56
src/database/Table.java
Normal file
@ -0,0 +1,56 @@
|
||||
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 Table {
|
||||
|
||||
private String name;
|
||||
private List<Record> list = new ArrayList<Record>();
|
||||
|
||||
public Table(String JavaTableName) {
|
||||
this.name = JavaTableName;
|
||||
}
|
||||
|
||||
public void remplirTable(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()) {
|
||||
Record r = new Record(retour.getString("id"), retour.getString("nom"), retour.getBytes("image"));
|
||||
list.add(r);
|
||||
//System.out.printf("%-20.30s %-30.30s %-20.30s%n", retour.getString("id"), retour.getString("nom"), retour.getBytes("image"));
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.out.println("Connection failure.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Record> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -27,8 +27,6 @@ public class PlateauController implements Initializable {
|
||||
private List<VBox> vboxJoueur = new ArrayList<VBox>();
|
||||
private List<Button> btnRevelation = new ArrayList<Button>();
|
||||
private List<Button> btnCartePerso = new ArrayList<Button>();
|
||||
private List<Label> nomPerso = new ArrayList<Label>();
|
||||
private List<Label> factionPerso = new ArrayList<Label>();
|
||||
private List<Label> nomJoueur = new ArrayList<Label>();
|
||||
|
||||
@FXML private VBox joueur1;
|
||||
@ -41,7 +39,7 @@ public class PlateauController implements Initializable {
|
||||
@FXML private VBox joueur8;
|
||||
|
||||
/**
|
||||
* initialise les donn<6E>es du plateau
|
||||
* initialise les donn<6E>es du plateau
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
@ -56,10 +54,8 @@ public class PlateauController implements Initializable {
|
||||
this.vboxJoueur.add(joueur7);
|
||||
this.vboxJoueur.add(joueur8);
|
||||
for (VBox vbox : vboxJoueur) {
|
||||
nomPerso.add((Label) vbox.getChildren().get(1));
|
||||
factionPerso.add((Label) vbox.getChildren().get(0));
|
||||
nomJoueur.add((Label) vbox.getChildren().get(2));
|
||||
HBox enfant = (HBox) vbox.getChildren().get(3);
|
||||
nomJoueur.add((Label) vbox.getChildren().get(0));
|
||||
HBox enfant = (HBox) vbox.getChildren().get(1);
|
||||
btnCartePerso.add((Button) enfant.getChildren().get(0));
|
||||
btnRevelation.add((Button) enfant.getChildren().get(1));
|
||||
}
|
||||
@ -78,14 +74,7 @@ public class PlateauController implements Initializable {
|
||||
j++;
|
||||
}
|
||||
|
||||
//initialisation nom personnage
|
||||
for (Label l : nomPerso) {
|
||||
l.setText("???");
|
||||
}
|
||||
//initialisation nom personnage
|
||||
for (Label l : factionPerso) {
|
||||
l.setText("???");
|
||||
}
|
||||
|
||||
|
||||
listJoueur = View.getJoueurs();
|
||||
}
|
||||
@ -93,7 +82,7 @@ public class PlateauController implements Initializable {
|
||||
/**
|
||||
* Affiche aux yeux de tous la carte personnage du joueur
|
||||
*
|
||||
* @param j : Le joueur sur lequel on a cliqu<71>
|
||||
* @param j : Le joueur sur lequel on a cliqu<71>
|
||||
*/
|
||||
public void seReveler(int numJoueur) throws IOException {
|
||||
System.out.println(listJoueur.get(numJoueur).getNom() + " se revele");
|
||||
@ -121,7 +110,7 @@ public class PlateauController implements Initializable {
|
||||
/**
|
||||
* Permet de consulter sa carte perssonage en cas d'oublie
|
||||
*
|
||||
* @param j : Le joueur sur lequel on a cliqu<71>
|
||||
* @param j : Le joueur sur lequel on a cliqu<71>
|
||||
*/
|
||||
public void consulterSaCarte(int numJoueur) throws IOException {
|
||||
System.out.println(listJoueur.get(numJoueur).getNom() + " consulte sa carte");
|
||||
|
@ -144,7 +144,7 @@ public class PlayersController implements Initializable{
|
||||
*/
|
||||
public void ajoutJoueur(int indice){
|
||||
System.out.println("Ajout du joueur " + (indice+1));
|
||||
plus.get(indice).setText("- ");
|
||||
plus.get(indice).setText("-");
|
||||
txt.get(indice).setEditable(true);
|
||||
txt.get(indice).setStyle("-fx-background-color: white;");
|
||||
plus.get(indice).setOnAction(e -> {enleverJoueur(indice);});
|
||||
|
@ -17,14 +17,14 @@
|
||||
<left>
|
||||
<VBox alignment="CENTER" prefHeight="688.0" prefWidth="240.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<HBox fx:id="hb5" alignment="CENTER" prefHeight="67.0" prefWidth="340.0" rotate="90.0">
|
||||
<HBox fx:id="hb5" alignment="CENTER_RIGHT" prefHeight="67.0" prefWidth="340.0" rotate="90.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<TextField prefHeight="51.0" prefWidth="149.0">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button mnemonicParsing="false" prefHeight="55.0" prefWidth="100.0" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<Button mnemonicParsing="false" prefHeight="55.0" prefWidth="45.0" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
@ -45,14 +45,14 @@
|
||||
<Insets bottom="150.0" left="-100.0" />
|
||||
</VBox.margin>
|
||||
</HBox>
|
||||
<HBox fx:id="hb7" alignment="CENTER" rotate="90.0">
|
||||
<HBox fx:id="hb7" alignment="CENTER_LEFT" rotate="90.0">
|
||||
<children>
|
||||
<TextField prefHeight="51.0" prefWidth="298.0">
|
||||
<TextField prefHeight="51.0" prefWidth="149.0">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button mnemonicParsing="false" prefHeight="55.0" prefWidth="100.0" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<Button mnemonicParsing="false" prefHeight="55.0" prefWidth="45.0" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
@ -79,14 +79,14 @@
|
||||
<right>
|
||||
<VBox alignment="CENTER" prefHeight="688.0" prefWidth="248.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<HBox fx:id="hb6" alignment="CENTER" prefHeight="100.0" prefWidth="200.0" rotate="270.0">
|
||||
<HBox fx:id="hb6" alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" rotate="270.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<TextField prefHeight="51.0" prefWidth="149.0">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button mnemonicParsing="false" prefHeight="55.0" prefWidth="100.0" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<Button mnemonicParsing="false" prefHeight="55.0" prefWidth="45.0" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
@ -107,23 +107,23 @@
|
||||
<Insets bottom="150.0" right="-100.0" />
|
||||
</VBox.margin>
|
||||
</HBox>
|
||||
<HBox fx:id="hb8" alignment="CENTER" prefHeight="100.0" prefWidth="200.0" rotate="270.0">
|
||||
<HBox fx:id="hb8" alignment="CENTER_RIGHT" prefHeight="100.0" prefWidth="200.0" rotate="270.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<TextField prefHeight="51.0" prefWidth="149.0">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button mnemonicParsing="false" prefHeight="55.0" prefWidth="100.0" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<Button mnemonicParsing="false" prefHeight="55.0" prefWidth="45.0" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" right="10.0" />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets right="5.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" right="10.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
<CheckBox mnemonicParsing="false">
|
||||
<font>
|
||||
|
@ -19,8 +19,6 @@
|
||||
<children>
|
||||
<VBox fx:id="joueur1" alignment="CENTER" prefHeight="164.0" prefWidth="212.0" rotate="180.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Faction" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Perssonage" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom joueur" />
|
||||
<HBox alignment="CENTER" prefHeight="46.0" prefWidth="212.0">
|
||||
<children>
|
||||
@ -54,8 +52,6 @@
|
||||
</VBox>
|
||||
<VBox fx:id="joueur2" alignment="CENTER" prefHeight="164.0" prefWidth="212.0" rotate="180.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Faction" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Perssonage" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom joueur" />
|
||||
<HBox alignment="CENTER" prefHeight="46.0" prefWidth="212.0">
|
||||
<children>
|
||||
@ -95,8 +91,6 @@
|
||||
<children>
|
||||
<VBox fx:id="joueur3" alignment="CENTER" prefHeight="164.0" prefWidth="212.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Faction" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Personnage" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom joueur" />
|
||||
<HBox alignment="CENTER" prefHeight="44.0" prefWidth="274.0">
|
||||
<children>
|
||||
@ -129,8 +123,6 @@
|
||||
</VBox>
|
||||
<VBox fx:id="joueur4" alignment="CENTER" prefHeight="164.0" prefWidth="212.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Faction" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Personnage" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom joueur" />
|
||||
<HBox alignment="CENTER" prefHeight="44.0" prefWidth="274.0">
|
||||
<children>
|
||||
@ -169,8 +161,6 @@
|
||||
<children>
|
||||
<VBox fx:id="joueur5" alignment="CENTER" prefHeight="181.0" prefWidth="333.0" rotate="90.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Faction" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom personnage" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom joueur" />
|
||||
<HBox alignment="CENTER" prefHeight="53.0" prefWidth="198.0">
|
||||
<children>
|
||||
@ -203,8 +193,6 @@
|
||||
</VBox>
|
||||
<VBox fx:id="joueur7" alignment="CENTER" prefHeight="179.0" prefWidth="329.0" rotate="90.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Faction" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom personnage" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom joueur" />
|
||||
<HBox alignment="CENTER" prefHeight="53.0" prefWidth="198.0">
|
||||
<children>
|
||||
@ -243,8 +231,6 @@
|
||||
<children>
|
||||
<VBox fx:id="joueur6" alignment="CENTER" prefHeight="163.0" prefWidth="329.0" rotate="270.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Faction" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom perssonage" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom joueur" />
|
||||
<HBox alignment="CENTER" prefHeight="39.0" prefWidth="214.0">
|
||||
<children>
|
||||
@ -277,8 +263,6 @@
|
||||
</VBox>
|
||||
<VBox fx:id="joueur8" alignment="CENTER" prefHeight="163.0" prefWidth="329.0" rotate="270.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom Faction" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom perssonage" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Nom joueur" />
|
||||
<HBox alignment="CENTER" prefHeight="39.0" prefWidth="214.0">
|
||||
<children>
|
||||
@ -411,7 +395,6 @@
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" prefHeight="60.0" prefWidth="50.0">
|
||||
<children>
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Inconnu" />
|
||||
<Label styleClass="text" stylesheets="@style/plateau.css" text="Charles" />
|
||||
</children>
|
||||
</VBox>
|
||||
|
Reference in New Issue
Block a user