diff --git a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin index 2e9233a..11b4101 100644 Binary files a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin and b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin differ diff --git a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock index 21e93f2..3c6b230 100644 Binary files a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock and b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock differ diff --git a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin index 6f4f8bc..23c31ec 100644 Binary files a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin and b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin differ diff --git a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock index 425a8a7..9d886b2 100644 Binary files a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock and b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock differ diff --git a/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 00524af..81575cc 100644 Binary files a/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class b/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class index 157a23c..b221faf 100644 Binary files a/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class and b/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class differ diff --git a/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar b/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar index 42b4104..78d94bd 100644 Binary files a/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar and b/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar differ diff --git a/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin b/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin index f3896ea..2528f19 100644 Binary files a/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin and b/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java b/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java index fd45418..4eca923 100644 --- a/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java +++ b/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java @@ -14,6 +14,8 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; public class HappyBirdMain extends Application { + /* Testen des Endscreens */ + private final Button endscreenTest = new Button("Endscreentest"); /*Datenbank einlesen*/ MariaDB datenbank = new MariaDB(); @@ -43,6 +45,7 @@ public class HappyBirdMain extends Application { /*Buttons erstellen und zuweisen*/ private final Button startButton = new Button("START"); private final Button highscoresButton = new Button("HIGHSCORES"); + private final Button personalHighscoresButton = new Button ("YOUR HIGHSCORES"); private final Button settingsButton = new Button("EINSTELLUNGEN"); private final Button startGameButton = new Button("SPIEL STARTEN"); private final Button menuButton = new Button("ZURÜCK"); @@ -55,7 +58,7 @@ public class HappyBirdMain extends Application { private final Button background2 = new Button(); /*Buttons in Arrays speichern*/ - private final Button[] buttons = {startButton, highscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton, settingsButtonPause, menuButtonPause, backButtonPause}; + private final Button[] buttons = {startButton, highscoresButton, personalHighscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton, settingsButtonPause, menuButtonPause, backButtonPause}; private final Button[] pauseButtons = {continueButton, settingsButtonPause, menuButtonPause, backButtonPause}; private final Button[] backgroundButtons = {background1, background2}; @@ -776,8 +779,7 @@ public class HappyBirdMain extends Application { /*** * Erste Datenabfrage als Test - wird später gelöscht */ - public void dataQuery() - { + public void dataQuery() { String dataquery = "SELECT * FROM happybirddb;"; try (ResultSet rs = datenbank.st.executeQuery(dataquery)) { while (rs.next()) @@ -797,8 +799,7 @@ public class HappyBirdMain extends Application { * * @return den Highscore des aktuellen Spielers */ - public int getPlayerHighscore() - { + public int getPlayerHighscore() { int highscore = 0; String playeracronym = acronym.getText(); String sql = "SELECT MAX(punkte) FROM happybirddb WHERE kuerzel = '" + playeracronym + "';"; @@ -817,10 +818,11 @@ public class HappyBirdMain extends Application { } /*** - * writeHighscores() gibt die Highscores aus ( die 5 höchsten Werte, die bis jetzt gespielt wurden ) + * calculateHighscores() gibt die Highscores aus ( die 5 höchsten Werte, die bis jetzt gespielt wurden ) + * + * @return die 5 höchsten erreichten Scores */ - public String calculateHighscores() - { + public String calculateHighscores() { String bestFiveHighscores = "PLAYER\t\tSCORE\n\n"; int i = 0; String sql = "SELECT * FROM happybirddb ORDER BY punkte DESC LIMIT 5;"; @@ -837,12 +839,34 @@ public class HappyBirdMain extends Application { return bestFiveHighscores; } + /*** + * calculatePersonalHighscores() berechnet die 5 höchsten erreichten Scores des aktuellen Spielers + * + * @return die 5 höchsten erreichten Scores des aktuellen Spielers + */ + public String calculatePersonalHighscores() { + String bestFiveHighscores = "PLAYER\t\tSCORE\n\n"; + String currentPlayer = acronymLabel.getText(); + int i = 0; + String sql = "SELECT * FROM happybirddb WHERE kuerzel = '" + currentPlayer + "' ORDER BY punkte DESC LIMIT 5;"; + try (ResultSet rs = datenbank.st.executeQuery(sql)) { + while (rs.next()) + { + bestFiveHighscores+= rs.getString(4) + "\t" + rs.getString(3)+"\n"; + } + } + catch (Exception e) + { + System.out.println("Falsche Abfrage"); + } + return bestFiveHighscores; + } + /*** * Fügt die erreichte Punktzahl des Spielers für den Spieler mit seinem Namen und Kürzel in die Datenbank ein * @param points die erreichten Punkte */ - public void writeIntoDatabase(int points) - { + public void writeIntoDatabase(int points) { String playername = name.getText(); String playeracronym = acronym.getText(); /*String sql = "INSERT INTO happybirddb(name, kuerzel, punkte) VALUES ('" + playername + "', '" + points + @@ -866,8 +890,7 @@ public class HappyBirdMain extends Application { * * @return true, wenn ja, sonst false */ - public boolean correctName() - { + public boolean correctName() { String nametext = name.getText(); if (!nametext.matches("[a-zA-ZÄÖÜäöüß ]*")) { @@ -895,8 +918,7 @@ public class HappyBirdMain extends Application { * ( >= 3 Zeichen, <= 12 Zeichen, Groß- und Kleinbuchstaben, Zahlen 0-9 -- keine Sonderzeichen) * @return true, wenn ja, sonst false */ - public boolean correctAcronym() - { + public boolean correctAcronym() { String acronymtext = acronym.getText(); System.out.println(acronymtext.length()); System.out.println(acronymtext); @@ -912,4 +934,22 @@ public class HappyBirdMain extends Application { } return true; } + + public void generateEndScreen() { + /*Name und Highscores ausblenden, Pause-Button ausblenden*/ + nameLabel.setVisible(false); + highscoreLabel.setVisible(false); + pauseButton.setVisible(false); + + /*Überschrift einblenden - Text auf Game Over setzen */ + headline.setVisible(true); + headline.setText("GAME OVER"); + /*startGameButton anzeigen, Text zu "neu Starten" ändern und positionieren*/ + startGameButton.setVisible(true); + startGameButton.setText("NEU STARTEN"); + /*Button fürs Hauptmenü einblenden und positionieren*/ + menuButton.setVisible(true); + /*Button für persönliche Highscores einblenden und positionieren*/ + personalHighscoresButton.setVisible(true); + } } \ No newline at end of file