Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhovev committed Jan 16, 2023
1 parent 0d4f4cb commit dc8d321
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 85 deletions.
8 changes: 4 additions & 4 deletions src/main/java/start/structure/Metier/entite/Score.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class Score {
private IntegerProperty score;
private Timestamp horodatage;
private String login;
private static String gameCode = "DK"; //CodeJeu: Motron: 'TRON' | Tetris : 'TETRIS' | DonkeyKong : 'DK' | Brick breaker : 'CB'
private static String gameCodeTRON = "TRON";
private static String gameCodeTETRIS = "TETRIS";
private static String gameCodeCB = "CB";
private static final String gameCode = "DK"; //CodeJeu: Motron: 'TRON' | Tetris : 'TETRIS' | DonkeyKong : 'DK' | Brick breaker : 'CB'
private static final String gameCodeTRON = "TRON";
private static final String gameCodeTETRIS = "TETRIS";
private static final String gameCodeCB = "CB";


private Score() {
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/start/structure/Metier/manager/ScoreManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public List<Score> getScores() {
public List<Score> getScoresTRON() {
return stockage.getAllTRON();
}

public List<Score> getScoresCB() {
return stockage.getAllCB();
}
Expand All @@ -69,24 +70,27 @@ public List<Score> getScoresTETRIS() {
}


public Map<Integer,Double> getScoresTemps(){ return stockage.getAllTemps(); }
public Map<Integer, Double> getScoresTemps() {
return stockage.getAllTemps();
}

public String getLoginTemps(int id) {
return stockage.getLoginTemps(id);
}

public int getDernierCode() {
return stockage.getDernierCode();
}

public void addTemps(double temps,String login) {
stockage.addTemps(temps,login);
public void addTemps(double temps, String login) {
stockage.addTemps(temps, login);
}

public List<Double> getTempsByLogin(String login) {
return stockage.getTempsByLogin(login);
}

public Map<Integer,Double> getAllTempsByDepartement(String departement) {
public Map<Integer, Double> getAllTempsByDepartement(String departement) {
return stockage.getAllTempsByDepartement(departement);
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/start/structure/Sound/Son.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class Son {

public static void playMusic() {
try {
gameMusic = new Media(Objects.requireNonNull(String.valueOf(RessourcesAccess.class.getResource("son/fond.wav"))));
mediaPlayer = new MediaPlayer(gameMusic);
gameMusic = new Media(Objects.requireNonNull(String.valueOf(RessourcesAccess.class.getResource("son/fond.wav"))));
mediaPlayer = new MediaPlayer(gameMusic);
if (gameMusic != null) {
mediaPlayer.setAutoPlay(true);
mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
Expand All @@ -29,8 +29,8 @@ public static void playMusic() {

public static void jump() {
try {
jumpMusic = new Media(Objects.requireNonNull(String.valueOf(RessourcesAccess.class.getResource("son/jump.wav"))));
mediaPlayer = new MediaPlayer(jumpMusic);
jumpMusic = new Media(Objects.requireNonNull(String.valueOf(RessourcesAccess.class.getResource("son/jump.wav"))));
mediaPlayer = new MediaPlayer(jumpMusic);
if (jumpMusic != null) {
mediaPlayer.setAutoPlay(true);
mediaPlayer.setCycleCount(1);
Expand All @@ -44,8 +44,8 @@ public static void jump() {

public static void point() {
try {
pointMusic = new Media(Objects.requireNonNull(String.valueOf(RessourcesAccess.class.getResource("son/point.wav"))));
mediaPlayer = new MediaPlayer(pointMusic);
pointMusic = new Media(Objects.requireNonNull(String.valueOf(RessourcesAccess.class.getResource("son/point.wav"))));
mediaPlayer = new MediaPlayer(pointMusic);
if (pointMusic != null) {
mediaPlayer.setAutoPlay(true);
mediaPlayer.setCycleCount(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,52 +236,52 @@ public List<Score> getAll() {
return scoreList;
}

public Map<Integer,Double> getAllTemps() {
Map<Integer,Double> scoreList = new LinkedHashMap<>();
public Map<Integer, Double> getAllTemps() {
Map<Integer, Double> scoreList = new LinkedHashMap<>();
SQLUtils utils = SQLUtils.getInstance();
Connection connection = utils.getConnection();
String req = "SELECT * FROM scoreTemps ORDER BY temps ASC";
try (PreparedStatement st = connection.prepareStatement(req)){
try(ResultSet result = st.executeQuery()){
while (result.next()){
try (PreparedStatement st = connection.prepareStatement(req)) {
try (ResultSet result = st.executeQuery()) {
while (result.next()) {
int id = result.getInt("codeScore");
double temps = result.getDouble("temps");
String login = result.getString("login");
scoreList.put(id,temps);
scoreList.put(id, temps);
}
}
}catch (SQLException e){
} catch (SQLException e) {
e.printStackTrace();
}
return scoreList;
}

public String getLoginTemps(int id){
public String getLoginTemps(int id) {
String res = "";
SQLUtils utils = SQLUtils.getInstance();
Connection connection = utils.getConnection();
String req = "SELECT * FROM scoreTemps WHERE codeScore = ?";
try (PreparedStatement st = connection.prepareStatement(req)){
st.setInt(1,id);
try(ResultSet result = st.executeQuery()){
if (result.next()){
try (PreparedStatement st = connection.prepareStatement(req)) {
st.setInt(1, id);
try (ResultSet result = st.executeQuery()) {
if (result.next()) {
res = result.getString("login");
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
throw new RuntimeException(e);
}
return res;
}

public int getDernierCode(){
public int getDernierCode() {
int res = 0;
SQLUtils utils = SQLUtils.getInstance();
Connection connection = utils.getConnection();
String req = "SELECT * FROM scoreTemps ORDER BY codeScore DESC";
try (PreparedStatement st = connection.prepareStatement(req)){
try(ResultSet result = st.executeQuery()){
if (result.next()){
try (PreparedStatement st = connection.prepareStatement(req)) {
try (ResultSet result = st.executeQuery()) {
if (result.next()) {
res = result.getInt("codeScore");
}
}
Expand All @@ -291,41 +291,33 @@ public int getDernierCode(){
return res;
}

public void addTemps(double temps, String login){
public void addTemps(double temps, String login) {
SQLUtils utils = SQLUtils.getInstance();
Connection connection = utils.getConnection();
String req = "INSERT INTO scoreTemps (codeScore,temps,login) VALUES (?,?,?)";
try (PreparedStatement st = connection.prepareStatement(req)){
st.setInt(1,getDernierCode()+1);
st.setDouble(2,temps);
st.setString(3,login);
try (PreparedStatement st = connection.prepareStatement(req)) {
st.setInt(1, getDernierCode() + 1);
st.setDouble(2, temps);
st.setString(3, login);
st.executeUpdate();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

/**
*
*
*
*
* TRON
*
*
*
*
*/
public List<Score> getAllTRON() {
List<Score> scoreList = new ArrayList<>();
SQLUtils utils = SQLUtils.getInstance();
Connection connection = utils.getConnection();
String req = "SELECT * FROM SCORES WHERE codeJeu = ? ORDER BY score DESC";
try (
PreparedStatement st = connection.prepareStatement(req);
PreparedStatement st = connection.prepareStatement(req)
) {
st.setString(1, Score.getGameCodeTRON());
try (ResultSet result = st.executeQuery();) {
try (ResultSet result = st.executeQuery()) {
while (result.next()) {
int id = result.getInt("codeScore");
int scoreValue = result.getInt("score");
Expand All @@ -344,26 +336,18 @@ public List<Score> getAllTRON() {
}

/**
*
*
*
*
* CB
*
*
*
*
*/
public List<Score> getAllCB() {
List<Score> scoreList = new ArrayList<>();
SQLUtils utils = SQLUtils.getInstance();
Connection connection = utils.getConnection();
String req = "SELECT * FROM SCORES WHERE codeJeu = ? ORDER BY score DESC";
try (
PreparedStatement st = connection.prepareStatement(req);
PreparedStatement st = connection.prepareStatement(req)
) {
st.setString(1, Score.getGameCodeCB());
try (ResultSet result = st.executeQuery();) {
try (ResultSet result = st.executeQuery()) {
while (result.next()) {
int id = result.getInt("codeScore");
int scoreValue = result.getInt("score");
Expand All @@ -382,15 +366,7 @@ public List<Score> getAllCB() {
}

/**
*
*
*
*
* TETRIS
*
*
*
*
*/

public List<Score> getAllTETRIS() {
Expand All @@ -399,10 +375,10 @@ public List<Score> getAllTETRIS() {
Connection connection = utils.getConnection();
String req = "SELECT * FROM SCORES WHERE codeJeu = ? ORDER BY score DESC";
try (
PreparedStatement st = connection.prepareStatement(req);
PreparedStatement st = connection.prepareStatement(req)
) {
st.setString(1, Score.getGameCodeTETRIS());
try (ResultSet result = st.executeQuery();) {
try (ResultSet result = st.executeQuery()) {
while (result.next()) {
int id = result.getInt("codeScore");
int scoreValue = result.getInt("score");
Expand All @@ -421,17 +397,17 @@ public List<Score> getAllTETRIS() {
}


public List<Score> getAllByDepartement(String numDepartement){
public List<Score> getAllByDepartement(String numDepartement) {
ArrayList<Score> scores = new ArrayList<>();
SQLUtils utils = SQLUtils.getInstance();
Connection connection = utils.getConnection();
String req = "SELECT * FROM scores WHERE codeJeu = ? AND login IN (SELECT login FROM Joueurs WHERE numDepartement = ?) ORDER BY score DESC";
try (
PreparedStatement st = connection.prepareStatement(req);
PreparedStatement st = connection.prepareStatement(req)
) {
st.setString(1, Score.getGameCode());
st.setString(2, numDepartement);
try (ResultSet result = st.executeQuery();) {
try (ResultSet result = st.executeQuery()) {
while (result.next()) {
int id = result.getInt("codeScore");
int scoreValue = result.getInt("score");
Expand All @@ -449,25 +425,25 @@ public List<Score> getAllByDepartement(String numDepartement){
return scores;
}

public Map<Integer,Double> getAllTempsByDepartement(String numDepartement){
Map<Integer,Double> temps = new LinkedHashMap<>();
public Map<Integer, Double> getAllTempsByDepartement(String numDepartement) {
Map<Integer, Double> temps = new LinkedHashMap<>();
SQLUtils utils = SQLUtils.getInstance();
Connection connection = utils.getConnection();
String req = "SELECT * FROM scoreTemps WHERE login IN (SELECT login FROM Joueurs WHERE numDepartement = ?) ORDER BY temps ASC";
try (
PreparedStatement st = connection.prepareStatement(req);
PreparedStatement st = connection.prepareStatement(req)
) {
st.setString(1, numDepartement);
try (ResultSet result = st.executeQuery();) {
try (ResultSet result = st.executeQuery()) {
while (result.next()) {
int id = result.getInt("codeScore");
double tempsValue = result.getDouble("temps");
temps.put(id,tempsValue);
temps.put(id, tempsValue);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return temps;
}
}
10 changes: 5 additions & 5 deletions src/main/java/start/structure/View/VueConnexion.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void affichageVueConnexion(Stage stage) throws IOException {
ComboBox<String> comboBoxDepartement = new ComboBox<>();
comboBoxDepartement.setLayoutX(790);
comboBoxDepartement.setLayoutY(425);
comboBoxDepartement.getItems().addAll("01 - Ain", "02 - Aisne", "03 - Allier", "04 - Alpes-de-Haute-Provence", "05 - Hautes-Alpes", "06 - Alpes-Maritimes", "07 - Ardèche", "08 - Ardennes", "09 - Ariège", "10 - Aube", "11 - Aude", "12 - Aveyron", "13 - Bouches-du-Rhône", "14 - Calvados", "15 - Cantal", "16 - Charente", "17 - Charente-Maritime", "18 - Cher", "19 - Corrèze", "2A - Corse-du-Sud", "2B - Haute-Corse", "21 - Côte-d'Or", "22 - Côtes-d'Armor", "23 - Creuse", "24 - Dordogne", "25 - Doubs", "26 - Drôme", "27 - Eure", "28 - Eure-et-Loir", "29 - Finistère", "30 - Gard", "31 - Haute-Garonne", "32 - Gers", "33 - Gironde", "34 - Hérault", "35 - Ille-et-Vilaine", "36 - Indre", "37 - Indre-et-Loire", "38 - Isère", "39 - Jura", "40 - Landes", "41 - Loir-et-Cher", "42 - Loire", "43 - Haute-Loire", "44 - Loire-Atlantique", "45 - Loiret", "46 - Lot", "47 - Lot-et-Garonne", "48 - Lozère", "49 - Maine-et-Loire", "50 - Manche", "51 - Marne", "52 - Haute-Marne", "53 - Mayenne", "54 - Meurthe-et-Moselle", "55 - Meuse", "56 - Morbihan", "57 - Moselle", "58 - Nièvre", "59 - Nord", "60 - Oise", "61 - Orne", "62 - Pas-de-Calais", "63 - Puy-de-Dôme", "64 - Pyrénées-Atlantiques", "65 - Hautes-Pyrénées", "66 - Pyrénées-Orientales", "67 - Bas-Rhin", "68 - Haut-Rhin", "69 - Rhône", "70 - Haute-Saône", "71 - Saône-et-Loire", "72 - Sarthe", "73 - Savoie", "74 - Haute-Savoie", "75 - Paris", "76 - Seine-Maritime", "77 - Seine-et-Marne", "78 - Yvelines", "79 - Deux-Sèvres", "80 - Somme", "81 - Tarn", "82 - Tarn-et-Garonne", "83 - Var", "84 - Vaucluse", "85 - Vendée", "86 - Vienne", "87 - Haute-Vienne", "88 - Vosges", "89 - Yonne", "90 - Territoire de Belfort", "91 - Essonne","92 - Hauts-de-Seine", "93 - Seine-Saint-Denis", "94 - Val-de-Marne", "95 - Val-d'Oise", "971 - Guadeloupe", "972 - Martinique", "973 - Guyane", "974 - La Réunion", "976 - Mayotte");
comboBoxDepartement.getItems().addAll("01 - Ain", "02 - Aisne", "03 - Allier", "04 - Alpes-de-Haute-Provence", "05 - Hautes-Alpes", "06 - Alpes-Maritimes", "07 - Ardèche", "08 - Ardennes", "09 - Ariège", "10 - Aube", "11 - Aude", "12 - Aveyron", "13 - Bouches-du-Rhône", "14 - Calvados", "15 - Cantal", "16 - Charente", "17 - Charente-Maritime", "18 - Cher", "19 - Corrèze", "2A - Corse-du-Sud", "2B - Haute-Corse", "21 - Côte-d'Or", "22 - Côtes-d'Armor", "23 - Creuse", "24 - Dordogne", "25 - Doubs", "26 - Drôme", "27 - Eure", "28 - Eure-et-Loir", "29 - Finistère", "30 - Gard", "31 - Haute-Garonne", "32 - Gers", "33 - Gironde", "34 - Hérault", "35 - Ille-et-Vilaine", "36 - Indre", "37 - Indre-et-Loire", "38 - Isère", "39 - Jura", "40 - Landes", "41 - Loir-et-Cher", "42 - Loire", "43 - Haute-Loire", "44 - Loire-Atlantique", "45 - Loiret", "46 - Lot", "47 - Lot-et-Garonne", "48 - Lozère", "49 - Maine-et-Loire", "50 - Manche", "51 - Marne", "52 - Haute-Marne", "53 - Mayenne", "54 - Meurthe-et-Moselle", "55 - Meuse", "56 - Morbihan", "57 - Moselle", "58 - Nièvre", "59 - Nord", "60 - Oise", "61 - Orne", "62 - Pas-de-Calais", "63 - Puy-de-Dôme", "64 - Pyrénées-Atlantiques", "65 - Hautes-Pyrénées", "66 - Pyrénées-Orientales", "67 - Bas-Rhin", "68 - Haut-Rhin", "69 - Rhône", "70 - Haute-Saône", "71 - Saône-et-Loire", "72 - Sarthe", "73 - Savoie", "74 - Haute-Savoie", "75 - Paris", "76 - Seine-Maritime", "77 - Seine-et-Marne", "78 - Yvelines", "79 - Deux-Sèvres", "80 - Somme", "81 - Tarn", "82 - Tarn-et-Garonne", "83 - Var", "84 - Vaucluse", "85 - Vendée", "86 - Vienne", "87 - Haute-Vienne", "88 - Vosges", "89 - Yonne", "90 - Territoire de Belfort", "91 - Essonne", "92 - Hauts-de-Seine", "93 - Seine-Saint-Denis", "94 - Val-de-Marne", "95 - Val-d'Oise", "971 - Guadeloupe", "972 - Martinique", "973 - Guyane", "974 - La Réunion", "976 - Mayotte");
comboBoxDepartement.setValue("01 - Ain");
comboBoxDepartement.getStyleClass().add("buttonEcran");
comboBoxDepartement.setStyle("-fx-font-size: 12px; -fx-pref-width: 130px; -fx-pref-height: 20px;");
Expand Down Expand Up @@ -149,10 +149,10 @@ public void affichageVueConnexion(Stage stage) throws IOException {
try {
String departement;
ArrayList<String> listeDrom = new ArrayList<>(Arrays.asList("971 - Guadeloupe", "972 - Martinique", "973 - Guyane", "974 - La Réunion", "976 - Mayotte"));
if (listeDrom.contains(comboBoxDepartement.getValue())){
departement = comboBoxDepartement.getValue().substring(0,3);
}else {
departement = comboBoxDepartement.getValue().substring(0,2);
if (listeDrom.contains(comboBoxDepartement.getValue())) {
departement = comboBoxDepartement.getValue().substring(0, 3);
} else {
departement = comboBoxDepartement.getValue().substring(0, 2);
}
PlayerManager.getInstance().createPlayer(textFieldPseudoInscription.getText(), passwordFieldInscription.getText(), departement);
Session.getInstance().connect(textFieldPseudoInscription.getText());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/start/structure/View/VueJeu.java
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ private void move(PersonnePrincipale personnePrincipale, ArrayList<Echelle> eche
button_Droite.setGraphic(image_Droite);
button_Espace.setGraphic(image_Espace_Click);
if (!personnePrincipale.isEstEnSaut()) {
Son.jump();
Son.jump();
PauseTransition pause = new PauseTransition(Duration.seconds(0.8));
personnePrincipale.jump();
personnePrincipale.setaEuSonScore(false);
Expand Down
Loading

0 comments on commit dc8d321

Please sign in to comment.