diff --git a/README.md b/README.md index d351a7e1c76dec53336acb562d9f67b5c8075daf..36649891de9120708f42d1e77509733f2abd6a23 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ ## Hier könnte ihre Werbung stehn -### Known issues - - Videos sometimes don't load in windows 11 especially on weaker systems +### Known issues: + - Videos sometimes don't load in Windows 11 especially on weaker systems + - SQL server is very slow (thanks Oracle) diff --git a/pom.xml b/pom.xml index a5d670d9583de6fb53164a13ef1f6a1a8abb2495..00cecae4b603bb2ef7a769e8effa5db5010b47d5 100644 --- a/pom.xml +++ b/pom.xml @@ -76,6 +76,7 @@ <artifactId>spring-core</artifactId> <version>4.3.24.RELEASE</version> </dependency>--> + <dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ojdbc11</artifactId> @@ -93,6 +94,7 @@ <artifactId>gson</artifactId> <version>2.10.1</version> </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateAccountController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateAccountController.java new file mode 100644 index 0000000000000000000000000000000000000000..826cb76c7ba083c1cd0608fe5d6d83e28ef68733 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateAccountController.java @@ -0,0 +1,86 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Label; +import javafx.scene.control.RadioButton; +import javafx.scene.control.TextField; +import javafx.scene.control.ToggleGroup; +import javafx.scene.layout.VBox; + +import java.net.URL; +import java.util.ResourceBundle; + +public class CreateAccountController implements Initializable { + @FXML + private VBox parent; + @FXML + private RadioButton local; + @FXML + private ToggleGroup statistics; + @FXML + private TextField playerName, password; + @FXML + private Label errorMessage, passwordLabel; + + String selectedButton; + SceneLoader sceneLoader = new SceneLoader(); + Persistence persistence = Persistence.getInstance(); + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + getSelected(); + } + + private void getSelected() { + statistics.selectedToggleProperty().addListener((observableValue, toggle, t1) -> { + if (statistics.getSelectedToggle() != null) { + RadioButton selectedToggle = (RadioButton) statistics.getSelectedToggle(); + selectedButton = selectedToggle.getText(); + System.out.println(selectedButton); + } + if (local.isSelected()) { + password.setEditable(false); + password.setText(""); + passwordLabel.setStyle("-fx-text-fill: rgba(0, 0, 0, 0.3)"); + password.setStyle("-fx-border-color: rgba(0, 0, 0, 0.3)"); + } else { + passwordLabel.setStyle("-fx-text-fill: black"); + password.setEditable(true); + password.setStyle("-fx-border-color: black"); + } + }); + } + + private void switchScene(String name) { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene(name)); + } + + @FXML + private void create() { + AccountType accountType; + if (selectedButton.equals("Local")) { + accountType = AccountType.LOCAL; + } else { + accountType = AccountType.ONLINE; + } + try { + persistence.createAccount(playerName.getText(), password.getText(), accountType); + persistence.resetPlayerStatistics(); + persistence.loadPlayerStatistics(); + switchScene("MainMenu"); + } catch (DatabaseException e) { + errorMessage.setText(e.getMessage()); + } + } + + @FXML + private void back() { + switchScene("PlayerCreateScene"); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java index 1b09b4b3a4fdc1bba073bae2f79fcd78c4ece9e1..6f1c4e05dc1ea8b636fd60d08bb4797671a6977b 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java @@ -1,5 +1,7 @@ package de.hdm_stuttgart.battlearena.Controller; +import de.hdm_stuttgart.battlearena.Controller.Utilities.ScreenClasses; +import de.hdm_stuttgart.battlearena.Controller.Utilities.ScreenDimensionCalculator; import de.hdm_stuttgart.battlearena.Controller.Enum.GameMode; import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Controller.Enum.PlayerMode; @@ -7,23 +9,38 @@ import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; import de.hdm_stuttgart.battlearena.Model.Entity.EntityFactory; import de.hdm_stuttgart.battlearena.Model.Entity.EntityType; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectStatus; import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; +import de.hdm_stuttgart.battlearena.Model.Map.Biom; import de.hdm_stuttgart.battlearena.Model.Map.TileManager; import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; import javafx.animation.AnimationTimer; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; import javafx.fxml.FXML; import javafx.fxml.Initializable; +import javafx.geometry.Insets; +import javafx.geometry.Rectangle2D; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; +import javafx.scene.control.Label; +import javafx.scene.control.Slider; +import javafx.scene.layout.*; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import javafx.stage.Screen; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import java.io.IOException; import java.net.URL; +import java.util.List; import java.util.ResourceBundle; +import java.util.stream.Collectors; public class GameSceneController implements Initializable { @@ -31,6 +48,20 @@ public class GameSceneController implements Initializable { @FXML private Canvas canvas2D; + @FXML + private Slider slider, slider2; + @FXML + private Rectangle playerHealth, enemyHealth; + @FXML + private Pane playerPane, enemyPane; + @FXML + private Label playerHp, enemyHp, time, round; + @FXML + private StackPane stackPane; + Screen screen = Screen.getPrimary(); + Rectangle2D visualBounds = screen.getVisualBounds(); + final private double healthBarWidth = screen.getBounds().getWidth() / 5; + ScreenDimensionCalculator screenCalculator = new ScreenDimensionCalculator(); private GraphicsContext graphicsContext2D; @@ -51,32 +82,99 @@ public class GameSceneController implements Initializable { TileManager tileManager; //map data - String mapString = "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " + - "4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + - "4 2 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 3 " + - "4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 2 3 " + - "4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 1 2 3 " + - "4 1 1 1 2 2 4 1 3 3 3 1 1 1 3 2 2 3 " + - "4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 2 1 3 " + - "4 1 5 1 2 2 4 3 3 1 4 3 3 3 3 2 1 3 " + - "4 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + - "4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 1 3 " + - "4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 1 1 3 " + - "4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 2 2 3 " + - "4 1 1 1 1 1 4 3 3 1 3 3 3 3 3 1 2 3 " + - "4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + - "4 1 1 2 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + - "4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 " + - "4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 " + - "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3"; + + /*String mapString = "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " + + "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " + + "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " + + "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " + + "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " + + "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " + + "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " + + "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " + + "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " + + "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " + + "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " + + "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " + + "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " + + "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " + + "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " + + "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " + + "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " + + "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 "; + */ + + String mapString = "11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 " + + "11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 " + + "11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 " + + "11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 " + + "11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 " + + "11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 " + + "11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 " + + "11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 " + + "11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 " + + "11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 " + + "11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 " + + "11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 " + + "11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 " + + "11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 " + + "11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 " + + "11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 " + + "11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 " + + "11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12"; + int horizontalTileCount = 18; int verticalTileCount = 18; - int diffTileCount = 6; + int diffTileCount = 30; int scaledTileSize = 48; - + private final Biom biom = runtimeInfo.getMapBiom(); @Override public void initialize(URL url, ResourceBundle resourceBundle) { + double diagonalInches = screenCalculator.calculateDiagonalInches(visualBounds.getWidth(), + visualBounds.getHeight(), screen.getDpi()); +// for some reason scene builder overwrites css fonts bruh + playerHp.setFont(Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 55)); + enemyHp.setFont(Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 55)); + playerHp.setText("100%"); + playerHp.setMinWidth(120); + playerHp.setMaxWidth(120); + enemyHp.setText("100%"); + enemyHp.setMinWidth(120); + +// stopping the VBox from shrinking when health bar gets smaller + playerPane.setMinWidth(healthBarWidth); + playerPane.setMaxWidth(healthBarWidth); + enemyPane.setMinWidth(healthBarWidth); + enemyPane.setMaxWidth(healthBarWidth); + + playerHealth.setWidth(healthBarWidth); + enemyHealth.setWidth(healthBarWidth); + +// make it responsive + stackPane.heightProperty().addListener((observableValue, oldValue, newValue) -> { + canvas2D.setScaleY(newValue.doubleValue() / 870); + canvas2D.setScaleX(newValue.doubleValue() / 870); + }); + + System.out.println(stackPane.heightProperty()); + System.out.println("dpi: " + screen.getDpi()); + +// testing hp bar + slider.valueProperty().addListener((observableValue, oldValue, newValue) -> { + System.out.println(stackPane.widthProperty().doubleValue()); + System.out.println(stackPane.heightProperty().doubleValue()); + double newWidth = healthBarWidth * (newValue.doubleValue() / 100); + playerHealth.setWidth(newWidth); + playerHp.setText(newValue.intValue() + "%"); + }); + slider2.valueProperty().addListener((observableValue, oldValue, newValue) -> { + double newWidth = healthBarWidth * (newValue.doubleValue() / 100); + enemyHealth.setWidth(newWidth); + enemyHp.setText(newValue.intValue() + "%"); + }); + + System.out.println("inches: " + diagonalInches); + graphicsContext2D = canvas2D.getGraphicsContext2D(); graphicsContext2D.setImageSmoothing(false); @@ -90,7 +188,8 @@ public class GameSceneController implements Initializable { playerTwoClass, this, PlayerMode.PLAYER_TWO); } - tileManager = new TileManager(graphicsContext2D, diffTileCount, horizontalTileCount, verticalTileCount, mapString); + tileManager = new TileManager(graphicsContext2D, diffTileCount, horizontalTileCount, + verticalTileCount, runtimeInfo.getMapDataGame(), biom); SoundEffects soundEffects = new SoundEffects(); @@ -108,9 +207,11 @@ public class GameSceneController implements Initializable { AnimationTimer gameLoop = new AnimationTimer() { @Override public void handle(long l) { - graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight()); - renderContent(graphicsContext2D); - updateContent(); + if (!inputHandler.isPause()) { + graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight()); + renderContent(graphicsContext2D); + updateContent(); + } } }; gameLoop.start(); @@ -122,14 +223,33 @@ public class GameSceneController implements Initializable { enemy.updateEntityMovement(this); player.attack(enemy, graphicsContext2D); enemy.attack(player, graphicsContext2D); + updateGameplayObjects(); + player.checkGameplayObjectInteraction(player, graphicsContext2D); + enemy.checkGameplayObjectInteraction(enemy, graphicsContext2D); + player.placeBomb(player, enemy, graphicsContext2D); + enemy.placeBomb(enemy, player, graphicsContext2D); } private void renderContent(GraphicsContext graphicsContext) { tileManager.renderMap(); player.renderEntity(graphicsContext); enemy.renderEntity(graphicsContext); - player.checkHealTile(player, graphicsContext2D); - enemy.checkHealTile(enemy, graphicsContext2D); + renderGameplayObjects(graphicsContext); + } + + private void renderGameplayObjects(GraphicsContext graphicsContext) { + List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); + for (IEntity gameplayObject : gameplayObjects) { + gameplayObject.renderEntity(graphicsContext); + } + } + + private void updateGameplayObjects() { + List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); + List<IEntity> updateList = gameplayObjects.stream().filter(obj -> obj.getOBJECT_STATUS() != ObjectStatus.USED) + .collect(Collectors.toList()); + runtimeInfo.setGameplayObjects(updateList); + log.debug("Gameplay objects updated"); } public IEntity getEnemy() { @@ -147,4 +267,4 @@ public class GameSceneController implements Initializable { public int getScaledTileSize() { return scaledTileSize; } -} +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java index 0ee284ce321557aafe682c4accff45c12625da6c..6a99c538617e193578e4a80332c60baa7c0bcf5e 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java @@ -1,9 +1,7 @@ package de.hdm_stuttgart.battlearena.Controller; import de.hdm_stuttgart.battlearena.Controller.Utilities.CreateMediaPlayer; -import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; -import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.StartupThread; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; @@ -40,7 +38,6 @@ public class IntroController implements Initializable { introParent.setStyle("-fx-background-color: black;"); introParent.setCursor(Cursor.NONE); createMediaPlayer(); - new StartupThread().run(); } private void createMediaPlayer() { @@ -50,11 +47,7 @@ public class IntroController implements Initializable { mediaPlayer.setOnEndOfMedia(() -> { if (counter == videos.length - 1) { - try { - videoEnd(); - } catch (IOException e) { - throw new RuntimeException(e); - } + videoEnd(); } else { nextVideo(); } @@ -63,42 +56,20 @@ public class IntroController implements Initializable { // TODO: make any button pressed work introParent.setOnMouseClicked((mouseEvent) -> { if (counter == videos.length - 1) { - try { - videoEnd(); - } catch (IOException e) { - throw new RuntimeException(e); - } + videoEnd(); } else { nextVideo(); } }); } - private void videoEnd() throws IOException { - boolean isStartUp = true, noAccount = false, statsLoaded = false; - while (isStartUp) { - try { - persistence.loadPlayerAccount(); - persistence.verifyPlayerAccount(); - mediaPlayer.dispose(); - isStartUp = false; - } catch (DatabaseException e) { - noAccount = true; -// TODO: reset player account if account fails to load in loadPlayerAccount() - } - if (noAccount) { - introParent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/PlayerCreateScene.fxml")))); - } - } - while (!statsLoaded) { // while loop because Martin said so - try { - persistence.loadPlayerStatistics(); - statsLoaded = true; - } catch (DatabaseException e) { - log.error(e); - } + private void videoEnd() { + try { + mediaPlayer.dispose(); + introParent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/LoadingScreen.fxml")))); + } catch (IOException e) { + throw new RuntimeException(); } - introParent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); } private void nextVideo() { diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoadingScreenController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoadingScreenController.java new file mode 100644 index 0000000000000000000000000000000000000000..a7aa8a685f37286da95ba3edda224fc8c78f30d4 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoadingScreenController.java @@ -0,0 +1,143 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ThreadStartup1; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ThreadStartup2; +import javafx.application.Platform; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.geometry.Rectangle2D; +import javafx.scene.control.Label; +import javafx.scene.image.ImageView; +import javafx.scene.layout.BorderPane; +import javafx.stage.Screen; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.net.URL; +import java.util.*; + +public class LoadingScreenController implements Initializable { + @FXML + private Label tips; + @FXML + private BorderPane parent; + @FXML + private ImageView logo, throbber; + + boolean isReady = false; + private int counter = 0; + private boolean statsLoaded = false; + private final String[] loadingTips = { + "Did you know, that since 2009, Martin isn't on the FBI list?", + "BattleArena is actually derived from the combination of the words 'Battle' and 'Arena'.", + "Yannik ist over 1,80m tall.", + "Electricity is a vital part to play this game.", + "There is a typo in one of the tips.", + "Over 1000 people play games every day.", + "A lot of people believe Nikola Tesla was the first to invent electricity but some clouds beat him to it.", + "Monkeys usually don't have keys.", + "While you're reading this, you've wasted 2 seconds.", + "If you die, you're dead.", + "If you take damage, you loose hp.", + "Did you know that Java is also an Island?", + "This loading screen might never end.", + "Get the BattleArena Ultimate-Edition for only 420,69€.", + "To move left, press one of the keys on your keyboard.", + "To use the gravity-gun, close the game and start Half Life 2.", + "Buying this game was a good decision! (no refunds)." + }; + + private final List<String> shuffledTips = Arrays.asList(loadingTips); + private static final Logger log = LogManager.getLogger(Persistence.class); + Rectangle2D screen = Screen.getPrimary().getVisualBounds(); + ThreadStartup1 thread1 = new ThreadStartup1(); + ThreadStartup2 thread2 = new ThreadStartup2(); + Persistence persistence = Persistence.getInstance(); + + Thread tipsThread = new Thread(() -> { + try { + setLoadingTips(); + } catch (InterruptedException e) { + log.info("Data finished loading"); + } + }); + + Thread loadingDataThread = new Thread(() -> { + try { + Thread.sleep(4000); + loadData(); + } catch (IOException e) { + throw new RuntimeException(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + }); + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + Collections.shuffle(shuffledTips); + setImages(); + + tipsThread.start(); + thread1.start(); + + boolean threadOneIsRunning = true, threadTwoIsRunning = false; + while (!isReady) { + if (!thread1.isAlive() && threadOneIsRunning) { + thread2.start(); + threadTwoIsRunning = true; + threadOneIsRunning = false; + } + if (!thread2.isAlive() && threadTwoIsRunning) { + isReady = true; + } + } + loadingDataThread.start(); + } + + private void setImages() { + logo.setTranslateY(screen.getHeight() * 0.08); + System.out.println(screen.getHeight()); + logo.setFitWidth(screen.getWidth() * 0.3); + throbber.setFitWidth(screen.getWidth() * 0.07); + logo.setPreserveRatio(true); + throbber.setPreserveRatio(true); + } + + private void setLoadingTips() throws InterruptedException { + while (!statsLoaded && counter < loadingTips.length) { + String nextTip = shuffledTips.get(counter); + Platform.runLater(() -> tips.setText(nextTip)); // JavaFX method to queue a task that needs to be executed on the JavaFX application thread (update ui components) + counter++; + +// check if statsLoaded is still false before sleeping + if (!statsLoaded) { + if (nextTip.length() > 60) { + Thread.sleep(6000); + } else { + Thread.sleep(3500); + } + setLoadingTips(); + } + } + } + + private void loadData() throws IOException { + if (persistence.getAccount().getAccountType() != AccountType.NONE) { + try { + persistence.loadPlayerStatistics(); + statsLoaded = true; + } catch (DatabaseException e) { + log.error(e); + } + } + + Platform.runLater(tipsThread::interrupt); + parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoginController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoginController.java new file mode 100644 index 0000000000000000000000000000000000000000..6e3fd79dd026c1b1db894041b1782058cd819ab8 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoginController.java @@ -0,0 +1,55 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.ParserException; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Utilities.Parser; +import javafx.application.Platform; +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; + +import java.security.NoSuchAlgorithmException; + +public class LoginController { + @FXML + private VBox parent; + @FXML + private TextField playerName, password; + @FXML + private Label errorMessage; + + SceneLoader sceneLoader = new SceneLoader(); + Persistence persistence = Persistence.getInstance(); + + private void switchScene(String name) { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene(name)); + } + + @FXML + private void login() { + errorMessage.setText("Loading an eternity because of slow SQL server..."); + thread.start(); + } + + Thread thread = new Thread(() -> { + try { + persistence.login(playerName.getText(), password.getText()); + persistence.loadPlayerStatistics(); + Platform.runLater(() -> switchScene("MainMenu")); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } catch (DatabaseException e) { + Platform.runLater(() -> errorMessage.setText(e.getMessage())); + } + }); + + @FXML + private void back() { + thread.interrupt(); + switchScene("PlayerCreateScene"); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java index 392326c31e7e700ca491b955e92531d125bf9e5f..75315ab525f8037751af3070d1402fe0c9ed7f71 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java @@ -3,6 +3,7 @@ package de.hdm_stuttgart.battlearena.Controller; import de.hdm_stuttgart.battlearena.Controller.Utilities.CreateMediaPlayer; import de.hdm_stuttgart.battlearena.Controller.Utilities.MusicPlayerSingleton; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; import javafx.fxml.FXML; import javafx.fxml.Initializable; @@ -34,7 +35,7 @@ public class MenuBorderPaneController implements Initializable { private MediaPlayer musicPlayer, mediaPlayer; private MediaView mediaView; private final String[] videoFiles = {"depression", "allMyFellas", "wooOOoo", "myMind", "dogCheese", "gta", "cat", "bobama", "roomba", "firework", "cheezburger", - "kangaroo", "lifeCouldBeMonke", "seal", "imNotYou", "parkingTickets", "russianKid", "rejectHumanity", "horse", "catSitting", "pablo", "holyCrap", + "kangaroo", "lifeCouldBeMonke", "seal", "rolling", "imNotYou", "parkingTickets", "russianKid", "rejectHumanity", "horse", "catSitting", "pablo", "holyCrap", "lessGoo", "sadCat", "basketball", "yoinkySploinky", "msPuff", "=D", "banana", "chaCha", "async", "sadHorse", "minecraftCat", "muecke", "top10Cats", "dog", "pot", "mineCraftCat2", "catEating", "catJump", "bear", "pancake", "frog", "gtfo", "carl", "dog2", "slippery", "wolf", "legCat", "sad", "waaahhh"}; @@ -44,7 +45,11 @@ public class MenuBorderPaneController implements Initializable { @Override public void initialize(URL url, ResourceBundle resourceBundle) { - center.getChildren().add(sceneLoader.loadScene("MainMenu")); + if (Persistence.getInstance().getAccount().getAccountType() == AccountType.NONE) { + center.getChildren().add(sceneLoader.loadScene("PlayerCreateScene")); + } else { + center.getChildren().add(sceneLoader.loadScene("MainMenu")); + } // set size for rusty gear image depending on screen resolution final double imageWidth = screen.getWidth() / 6; imgRight.setFitWidth(imageWidth); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlaceholderController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlaceholderController.java new file mode 100644 index 0000000000000000000000000000000000000000..a018d9e82ae12e61b22762484397f479597ff0c1 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlaceholderController.java @@ -0,0 +1,51 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import de.hdm_stuttgart.battlearena.Controller.Utilities.CreateMediaPlayer; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.layout.BorderPane; +import javafx.scene.media.Media; +import javafx.scene.media.MediaPlayer; +import javafx.scene.media.MediaView; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.Objects; +import java.util.ResourceBundle; + +public class PlaceholderController implements Initializable { + @FXML + private BorderPane parent; + @FXML + private MediaView mediaView; + @FXML + private Button button; + private MediaPlayer mediaPlayer, musicPlayer; + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + File file = new File("src/main/resources/videos/construction.mp4"); + mediaPlayer = new CreateMediaPlayer().getMediaPlayer(mediaView, file, true, parent); + mediaView.setMediaPlayer(mediaPlayer); + mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE); + parent.setStyle("-fx-font-size: 50; -fx-text-fill: white; -fx-font-family: 'Arial Black'"); + + Media musicMedia = new Media(new File("src/main/resources/sound/music/constructionJazz.mp3").toURI().toString()); + musicPlayer = new MediaPlayer(musicMedia); + musicPlayer.setCycleCount(MediaPlayer.INDEFINITE); + musicPlayer.setAutoPlay(true); + + button.setOnMouseClicked(mouseEvent -> { + try { + mediaPlayer.dispose(); + musicPlayer.dispose(); + parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); + } catch (IOException e) { + throw new RuntimeException(); + } + }); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java index 68dfd4029aad7452c5d19d82fdfcaec3f0e8435e..56f73045145a2c36b567f177e7423cd86f0bcd07 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java @@ -1,51 +1,34 @@ package de.hdm_stuttgart.battlearena.Controller; -import de.hdm_stuttgart.battlearena.Controller.Utilities.CreateMediaPlayer; +import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.fxml.Initializable; -import javafx.scene.control.Button; -import javafx.scene.layout.BorderPane; -import javafx.scene.media.Media; -import javafx.scene.media.MediaPlayer; -import javafx.scene.media.MediaView; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.Objects; -import java.util.ResourceBundle; - -public class PlayerCreateController implements Initializable { - @FXML - private BorderPane parent; - @FXML - private MediaView mediaView; +public class PlayerCreateController { @FXML - private Button button; - private MediaPlayer mediaPlayer, musicPlayer; + private VBox parent; - @Override - public void initialize(URL url, ResourceBundle resourceBundle) { - File file = new File("src/main/resources/videos/construction.mp4"); - mediaPlayer = new CreateMediaPlayer().getMediaPlayer(mediaView, file, true, parent); - mediaView.setMediaPlayer(mediaPlayer); - mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE); - parent.setStyle("-fx-font-size: 50; -fx-text-fill: white; -fx-font-family: 'Arial Black'"); + SceneLoader sceneLoader = new SceneLoader(); - Media musicMedia = new Media(new File("src/main/resources/sound/music/constructionJazz.mp3").toURI().toString()); - musicPlayer = new MediaPlayer(musicMedia); - musicPlayer.setCycleCount(MediaPlayer.INDEFINITE); - musicPlayer.setAutoPlay(true); + private void switchScene(String name) { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene(name)); + } - button.setOnMouseClicked(mouseEvent -> { - try { - mediaPlayer.dispose(); - musicPlayer.dispose(); - parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); - } catch (IOException e) { - throw new RuntimeException(); - } - }); + @FXML + private void createScene() { + switchScene("CreateAccount"); + } + + @FXML + private void loginScene() { + switchScene("Login"); + } + + @FXML + private void exit() { + Stage stage = (Stage) parent.getScene().getWindow(); + stage.close(); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SettingsController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SettingsController.java index a04eb1c6d84b615f3eff95b33d86485cb0ef5b51..836c9cf9df4f8f17b7633fac1c0867d9b00bac02 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SettingsController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SettingsController.java @@ -38,8 +38,17 @@ public class SettingsController implements Initializable { @FXML private void backButton() { + switchScene("MainMenu"); + } + + @FXML + private void account() { + switchScene("PlayerCreateScene"); + } + + private void switchScene(String name) { parent.getChildren().clear(); - parent.getChildren().add(sceneLoader.loadScene("MainMenu")); + parent.getChildren().add(sceneLoader.loadScene(name)); } private void setMusicVolume() { diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java index 9e27cab1e0a87b52e01a1ea63b84ba6cf6b46006..5276d92651d747ed1ad42b757b0d3c3fde9c241a 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java @@ -54,8 +54,6 @@ public class SkinSelectionController implements Initializable { @FXML private void gameScene() { - - parent.getChildren().clear(); parent.getChildren().add(new SceneLoader().loadScene("MapSelection")); } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ButtonTransition.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ButtonTransition.java index b129d469320cdd8549e234a3a5d6fae8901187ea..8e59516428834ab48bf7a9b2cfebb1760ad63308 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ButtonTransition.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ButtonTransition.java @@ -1,6 +1,7 @@ package de.hdm_stuttgart.battlearena.Controller.Utilities; import javafx.animation.ScaleTransition; +import javafx.application.Platform; import javafx.scene.control.Button; import javafx.scene.control.skin.ButtonSkin; import javafx.util.Duration; @@ -13,14 +14,20 @@ public class ButtonTransition extends ButtonSkin { fadeIn.setNode(button); fadeIn.setToX(1.1); fadeIn.setToY(1.1); - button.setOnMouseEntered(e -> fadeIn.playFromStart()); + +// this ensures that any JavaFX related code is run on the JavaFX application thread + button.setOnMouseEntered(e -> { + Platform.runLater(fadeIn::playFromStart); + }); // set transition for mouse exiting buttonButtonTransitionScale final ScaleTransition fadeOut = new ScaleTransition(Duration.millis(150)); fadeOut.setNode(button); fadeOut.setToX(1.0); fadeOut.setToY(1.0); - button.setOnMouseExited(e -> fadeOut.playFromStart()); + button.setOnMouseExited(e -> { + Platform.runLater(fadeOut::playFromStart); + }); button.setScaleX(1.0); button.setScaleY(1.0); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Main/Driver.java b/src/main/java/de/hdm_stuttgart/battlearena/Main/Driver.java new file mode 100644 index 0000000000000000000000000000000000000000..3c296f75fcc5cbe62f220a50248ce70474712ac5 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Main/Driver.java @@ -0,0 +1,75 @@ +package de.hdm_stuttgart.battlearena.Main; + + +import de.hdm_stuttgart.battlearena.Model.Sound.SoundManager; +import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.geometry.Rectangle2D; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.scene.text.Font; +import javafx.stage.Screen; +import javafx.stage.Stage; + +import javafx.stage.StageStyle; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Objects; + +public class Driver extends Application { + + private static final Logger log = LogManager.getLogger(Driver.class); + Rectangle2D screen = Screen.getPrimary().getVisualBounds(); + + InputHandler inputHandler = InputHandler.getInstance(); + + SoundManager soundManager = new SoundManager(); + + @Override + public void start(Stage stage) throws Exception { + +// loading font in start() because CSS can't handle whitespace in folder names + Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 50); + Font.loadFont(getClass().getResourceAsStream("/fonts/AmaticSC-Bold.ttf"), 50); + Font.loadFont(getClass().getResourceAsStream("/fonts/Arthemis-mLA22.ttf"), 50); + Font.loadFont(getClass().getResourceAsStream("/fonts/ShadowsIntoLight-Regular.ttf"), 50); + + Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/Intro.fxml"))); + + Scene scene = new Scene(root); + + scene.setOnKeyPressed(inputHandler::handleKeyPress); + scene.setOnKeyReleased(inputHandler::handleKeyRelease); + + stage.setTitle("BattleArena"); + stage.getIcons().add(new Image("file:src/main/resources/textures/images/icon.png")); + stage.setScene(scene); + stage.minHeightProperty().setValue(400); + stage.minWidthProperty().setValue(600); + stage.setMaximized(true); + stage.setWidth(screen.getWidth()); + stage.setHeight(screen.getHeight()); + stage.initStyle(StageStyle.UNDECORATED); + scene.getStylesheets().add(Objects.requireNonNull(this.getClass().getResource("/styles/style.css")).toExternalForm()); + stage.setScene(scene); + + stage.setOnCloseRequest(event -> { + if (soundManager != null) { + soundManager.stopMusic(); + } + }); + + stage.show(); + log.debug("Project started successfully!"); + +// Exiting program if an exception occurs +// Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { +// log.error(throwable.getMessage()); +// System.exit(1); +// }); + } +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java b/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java index 96aa7223b99ca350cbcd9eaa56c215036d088386..77261800125e391620b0facc16c47a6ee3217f79 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java @@ -1,73 +1,9 @@ package de.hdm_stuttgart.battlearena.Main; - -import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; - import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.geometry.Rectangle2D; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.image.Image; -import javafx.scene.text.Font; -import javafx.stage.Screen; -import javafx.stage.Stage; - -import javafx.stage.StageStyle; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.Objects; - -public class Main extends Application { - - private static final Logger log = LogManager.getLogger(Main.class); - Rectangle2D screen = Screen.getPrimary().getVisualBounds(); - - InputHandler inputHandler = InputHandler.getInstance(); +public class Main { public static void main(String[] args) { - launch(args); - } - - @Override - public void start(Stage stage) throws Exception { - -// loading font in start() because CSS can't handle whitespace in folder names - Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 50); - -// TODO: revert back to intro scene - Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/Intro.fxml"))); - - Scene scene = new Scene(root); - - scene.setOnKeyPressed(inputHandler::handleKeyPress); - scene.setOnKeyReleased(inputHandler::handleKeyRelease); - - stage.setTitle("BattleArena"); - stage.getIcons().add(new Image("file:src/main/resources/textures/images/icon.png")); - stage.setScene(scene); - stage.minHeightProperty().setValue(400); - stage.minWidthProperty().setValue(600); - stage.setMaximized(true); - stage.setWidth(screen.getWidth()); - stage.setHeight(screen.getHeight()); - stage.initStyle(StageStyle.UNDECORATED); - scene.getStylesheets().add(Objects.requireNonNull(this.getClass().getResource("/styles/style.css")).toExternalForm()); - stage.setScene(scene); - - - // SoundManager soundManager = new SoundManager(); - - /*stage.setOnCloseRequest(event -> { - if (soundManager != null) { - soundManager.stopMusic(); - } - }); - - soundManager.playMusic(MusicType.GAME);*/ - - stage.show(); - log.debug("Project started successfully!"); + Application.launch(Driver.class, args); } -} \ No newline at end of file +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/AccountType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/AccountType.java deleted file mode 100644 index 145d7a4f6f54bad787231fc80b276a2abaae261b..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/AccountType.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; - -public enum AccountType { - - NONE, - LOCAL, - ONLINE - -} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/AccountType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/AccountType.java new file mode 100644 index 0000000000000000000000000000000000000000..4ddb26cd2de6356b40b45af16dad0b9dfeb7f4d8 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/AccountType.java @@ -0,0 +1,9 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs; + +public enum AccountType { + + NONE, + LOCAL, + ONLINE + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/MapType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/MapType.java new file mode 100644 index 0000000000000000000000000000000000000000..8403ea2c46b21e5b8349917316f7414eb1a74710 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/MapType.java @@ -0,0 +1,8 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs; + +public enum MapType { + + COREMAP, + COMMUNITYMAP + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/ThreadStatus.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/ThreadStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..48ef20b9c36ce3e1758460adb489b643a7175c8e --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ENUMs/ThreadStatus.java @@ -0,0 +1,10 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs; + +public enum ThreadStatus { + + RUNNING, + FAILED, + FINISHED, + NONE + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/GsonHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/GsonHandler.java index 308b553a68422590c8a0619baa336e91ee513bb2..0b6bb2a2974338947bbbd2a7f299ef52077dfd59 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/GsonHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/GsonHandler.java @@ -3,6 +3,7 @@ package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.MapType; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.GSONException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -145,5 +146,4 @@ public class GsonHandler { } } - } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/MapType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/MapType.java deleted file mode 100644 index d7738b3c5205d4f217e2a27f0e88578cc34f6fa1..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/MapType.java +++ /dev/null @@ -1,8 +0,0 @@ -package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; - -public enum MapType { - - COREMAP, - COMMUNITYMAP - -} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java index 638529da884c6bd83ae1f34bf67c653b6c73b89e..b5577ef44a09e762123913b3be6e7af0b4eaa126 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java @@ -1,5 +1,7 @@ package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.MapType; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.GSONException; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.ParserException; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.SQLException; @@ -9,6 +11,7 @@ import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Utilities.Parser; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; public class Persistence { @@ -22,7 +25,7 @@ public class Persistence { private PlayerStatistics statistics; private PlayerAccount account; private AppSettings settings; - protected ArrayList<MapInfo> communityMapsListRemote; //for community map browser + private ArrayList<MapInfo> communityMapsListRemote; //for community map browser @@ -56,7 +59,7 @@ public class Persistence { return communityMapsListRemote; } - public void loadPlayerAccount() throws DatabaseException { + public synchronized void loadPlayerAccount() throws DatabaseException { try { account = gsonHandler.loadAccount(); log.info("Player account successfully loaded!"); @@ -67,12 +70,14 @@ public class Persistence { } } - public void loadPlayerStatistics() throws DatabaseException { + public synchronized void loadPlayerStatistics() throws DatabaseException { try { if (account.getAccountType() == AccountType.LOCAL) { statistics = gsonHandler.loadStats(); + Parser.playerStatsValid(statistics); } else { statistics = db.getStatistics(account.getPlayerName()); + Parser.playerStatsValid(statistics); } log.info("Player statistics successfully loaded!"); } @@ -89,9 +94,12 @@ public class Persistence { log.error(e); throw new DatabaseException(e.getMessage()); } + catch (ParserException e) { + throw new RuntimeException("Player statistics data corrupted!"); + } } - public void loadCoreMaps() throws DatabaseException { + public synchronized void loadCoreMaps() throws DatabaseException { try { coreMaps = gsonHandler.loadMaps(MapType.COREMAP); log.info("Core-Maps successfully loaded from file!"); @@ -103,7 +111,7 @@ public class Persistence { } } - public void loadCommunityMaps() throws DatabaseException { + public synchronized void loadCommunityMaps() throws DatabaseException { try { communityMaps = gsonHandler.loadMaps(MapType.COMMUNITYMAP); log.info("Community-Maps successfully loaded from file!"); @@ -115,7 +123,7 @@ public class Persistence { } } - public void loadSettings() throws DatabaseException { + public synchronized void loadSettings() throws DatabaseException { try { settings = gsonHandler.loadSettings(); log.info("Application settings successfully loaded from file!"); @@ -126,7 +134,7 @@ public class Persistence { } } - public void updateCoreMaps() throws DatabaseException { + public synchronized void updateCoreMaps() throws DatabaseException { try { coreMaps = db.getCoreMaps(); gsonHandler.saveMaps(coreMaps, MapType.COREMAP); @@ -144,7 +152,7 @@ public class Persistence { } } - public void getCommunityMap(String mapID) throws DatabaseException { + public synchronized void getCommunityMap(String mapID) throws DatabaseException { for(int i = 0; communityMaps.size() > i; i++){ if(communityMaps.get(i).getMapID().equals(mapID)){ throw new DatabaseException("Identical map already saved locally. See map name: " + communityMaps.get(i).getMapID()); @@ -170,25 +178,7 @@ public class Persistence { } } -/* public MapData getGameMap(String mapSelected, boolean choseCoremaps) throws DatabaseException{ - String mapID = mapSelected.substring(mapSelected.indexOf("(") + 1, mapSelected.length() - 1); - if (choseCoremaps) { - for (int index = 0; index < coreMaps.size(); index++) { - if (coreMaps.get(index).getMapID().equals(mapID)) { - return coreMaps.get(index); - } - } - } else { - for (int index = 0; index < communityMaps.size(); index++) { - if (communityMaps.get(index).getMapID().equals(mapID)) { - return coreMaps.get(index); - } - } - } - throw new DatabaseException("Database error - Map not found!"); - }*/ - - public void saveSettings(){ + public synchronized void saveSettings(){ try{ gsonHandler.saveSettings(settings); } @@ -197,8 +187,9 @@ public class Persistence { } } - public void savePlayerStatistics() throws DatabaseException{ //on shutdown of game + public synchronized void savePlayerStatistics() throws DatabaseException{ //on shutdown of game try { + Parser.playerStatsValid(statistics); if (account.getAccountType() == AccountType.LOCAL) { gsonHandler.saveStats(statistics); } else if (account.getAccountType() == AccountType.ONLINE) { @@ -211,7 +202,8 @@ public class Persistence { } } - public void saveCreatedMapLocally(MapData map) throws DatabaseException { + public synchronized void saveCreatedMap(MapData map, boolean doUpload) throws DatabaseException { + String part1 = ""; try { for(int i = 0; communityMaps.size() > i; i++){ if(communityMaps.get(i).getMapID().equals(map.getMapID())){ @@ -220,54 +212,54 @@ public class Persistence { } communityMaps.add(map); gsonHandler.saveMaps(communityMaps, MapType.COMMUNITYMAP); - //createLocalCommunityMapsList(); log.info("Newly created map stored successfully in JSON!"); } catch(Exception e){ log.error(e); - if(e.getMessage().contains("Identical map already saved") | e.getMessage().contains("ORA-01017")){ - throw new DatabaseException(e.getMessage()); - } - else{ - throw new DatabaseException("Unknown Database Error. Saving newly created Community-Map locally failed!"); + if(e.getMessage().contains("Identical map already saved")){ + part1 = e.getMessage(); + } + } + if(doUpload) { + try { + db.uploadCommunityMap(map); + log.info("Newly created Community-Map successfully published!"); + } + catch (Exception e) { + log.error(e); + if (e.getMessage().contains("ORA-17868") | e.getMessage().contains("ORA-01017")) { + throw new DatabaseException(part1 + "\nNo connection to SQL server! Saving to SQL communityMap server failed!"); + } else if (e.getMessage().contains("ORA-00001")) { + throw new DatabaseException(part1 + "\nMap already existing on communityMaps server!\n Look for mapID: " + map.getMapID()); + } else { + throw new DatabaseException(part1 + "\nUnknown Database Error. Saving to SQL communityMap server failed!"); + } } } } - public void uploadCreatedMap(MapData map) throws DatabaseException { + public synchronized void updatePlayerStatistics(int kills, int deaths, int gameTime, int blocksDestroyed, boolean gameWon) throws DatabaseException{ //after game round; only update stats in RAM, not in persistence (run savePlayerStatistics() method at end of program to save stats to persistence) try { - db.uploadCommunityMap(map); - log.info("Newly created Community-Map successfully published!"); - } - catch(Exception e){ - log.error(e); - if(e.getMessage().contains("ORA-17868") | e.getMessage().contains("ORA-01017")){ - throw new DatabaseException("No connection to SQL server!"); - } - else if(e.getMessage().contains("ORA-00001")){ - throw new DatabaseException("Map already existing on communityMaps server!\n Look for mapID: " + map.getMapID()); + Parser.playerStatsValid(new PlayerStatistics(0, 0, kills, deaths, blocksDestroyed, gameTime)); //temp instance of PLayerStatistics to validate new values + statistics.addKills(kills); + statistics.addDeaths(deaths); + statistics.addGameTime(gameTime); + statistics.addBlocksDestroyed(blocksDestroyed); + if(gameWon){ + statistics.addGamesWon(); } else{ - throw new DatabaseException("Unknown Database Error. Saving to SQL communityMap server failed!"); + statistics.addGamesLost(); } + RuntimeInfo.getInstance().resetGameStats(); + log.info("Statistics successfully updated!"); } - } - - public void updatePlayerStatistics(int kills, int deaths, int gameTime, int blocksDestroyed, boolean gameWon) throws DatabaseException{ //after game round - statistics.addKills(kills); - statistics.addDeaths(deaths); - statistics.addGameTime(gameTime); - statistics.addBlocksDestroyed(blocksDestroyed); - if(gameWon){ - statistics.addGamesWon(); - } - else{ - statistics.addGamesLost(); + catch(Exception e){ + log.error(e); } - log.info("Statistics successfully updated!"); } - public void createAccount(String playerName, String password, AccountType type) throws DatabaseException { + public synchronized void createAccount(String playerName, String password, AccountType type) throws DatabaseException { //for local account submit empty string try { Parser.usernameValid(playerName); if(type == AccountType.LOCAL) { @@ -307,7 +299,7 @@ public class Persistence { } } - public void createRemoteCommunityMapsList(){ //for Map-Browser + public synchronized void createRemoteCommunityMapsList(){ //for Map-Browser try { communityMapsListRemote = db.getCommunityMapsList(); log.info("MapList successfully retrieved from server!"); @@ -318,7 +310,7 @@ public class Persistence { } } - public void verifyPlayerAccount() throws DatabaseException { + public synchronized void verifyPlayerAccount() throws DatabaseException { try { if (account.getAccountType() == AccountType.NONE) { throw new DatabaseException("Must create playerAccount first!"); @@ -331,7 +323,7 @@ public class Persistence { throw new DatabaseException("Locally stored password does not match online password. Please reenter credentials!"); } } - else{ //überflüssig, da GSON schon beim laden der Daten meckern würde, wenn er den Accounttype nicht finden kann + else{ //eigentlich überflüssig, da GSON schon beim Laden der Daten meckern würde, wenn er den Accounttype nicht finden kann throw new DatabaseException("AccountType invalid - accountData corrupted! Please create new Account or login with existing!"); } log.info("Player account successfully verified!"); @@ -358,7 +350,7 @@ public class Persistence { } } - public void verifyCoreMaps() throws DatabaseException{ + public synchronized void verifyCoreMaps() throws DatabaseException{ try { for (int i = 0; coreMaps.size() > i; i++) { Parser.mapDataValid(coreMaps.get(i).getMapData()); @@ -376,7 +368,7 @@ public class Persistence { } } - public void verifyCommunityMaps() throws DatabaseException{ + public synchronized void verifyCommunityMaps() throws DatabaseException{ try { for (int i = 0; communityMaps.size() > i; i++) { Parser.mapDataValid(communityMaps.get(i).getMapData()); @@ -394,7 +386,7 @@ public class Persistence { } } - public void verifyAppSettings() throws DatabaseException{ + public synchronized void verifyAppSettings() throws DatabaseException{ try { Parser.volumeValid(settings.getSfxVolume()); Parser.volumeValid(settings.getMusicVolume()); @@ -406,7 +398,7 @@ public class Persistence { } } - public void resetPlayerAccount() throws DatabaseException{ + public synchronized void resetPlayerAccount() throws DatabaseException{ try{ account = new PlayerAccount("", "", AccountType.NONE); gsonHandler.saveAccount(account); @@ -417,7 +409,7 @@ public class Persistence { } } - public void resetPlayerStatistics() throws DatabaseException{ + public synchronized void resetPlayerStatistics() throws DatabaseException{ try { if (account.getAccountType() == AccountType.LOCAL) { statistics = new PlayerStatistics(0, 0, 0, 0, 0, 0); @@ -434,7 +426,7 @@ public class Persistence { } } - public void resetSettings(){ + public synchronized void resetSettings(){ try { settings = new AppSettings(50, 50); gsonHandler.saveSettings(settings); @@ -444,11 +436,11 @@ public class Persistence { } } - public void resetCoreMaps(){ + public synchronized void resetCoreMaps(){ try { coreMaps = new ArrayList<MapData>(); - coreMaps.add(new MapData("09a02b54d05b5b7ebc29a4383ca12d3dda846b72", "Arena1", 18, 18, "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12")); - coreMaps.add(new MapData("0ab15557ab6dc4be60dfe6a9b0288bac3036bd97", "Arena2", 18, 18, "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12")); + coreMaps.add(new MapData("b8f5da1a3619a3585978a6d9c8c683c3210193e6", "Arena1", 18, 18, "11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12")); + coreMaps.add(new MapData("6b9ff964a4afc821672645d5c2bb8fb2b0dcb2e8", "Outpost", 18, 18, "16 16 16 16 16 16 16 16 16 16 10 12 13 11 12 14 11 12 16 0 16 0 0 1 0 0 0 0 1 0 0 1 0 2 0 12 16 0 0 0 0 0 16 16 0 0 15 3 0 0 0 2 1 12 16 0 0 2 16 0 0 1 16 0 15 15 3 3 0 2 0 12 11 10 12 2 11 10 12 0 16 0 0 15 15 3 1 2 0 12 11 0 0 2 0 0 12 0 0 16 0 0 15 3 0 2 0 12 11 0 10 2 10 0 12 0 0 16 0 0 15 15 12 2 11 12 11 0 10 2 10 0 12 0 0 0 0 0 0 0 0 2 0 16 11 0 1 2 10 0 12 16 0 0 11 10 0 10 12 2 0 16 11 0 10 2 10 0 1 0 0 16 11 3 0 0 12 0 1 16 11 0 10 2 10 0 12 0 16 0 11 0 0 1 12 2 0 16 11 0 10 2 10 0 12 0 0 0 11 0 0 0 12 2 0 16 11 0 0 1 0 0 12 16 0 0 11 0 0 0 12 0 0 16 11 10 12 2 11 10 12 0 16 0 11 0 10 10 12 2 0 16 16 0 0 2 16 0 0 0 0 0 11 0 0 3 12 0 11 12 16 0 16 16 16 0 0 16 0 0 1 0 0 0 0 2 0 12 16 0 0 0 0 0 0 0 0 0 11 0 0 1 0 2 0 12 16 16 16 16 16 16 16 16 16 16 11 12 13 11 12 14 11 12")); gsonHandler.saveMaps(coreMaps, MapType.COREMAP); log.info("Core maps successfully reset on local storage!"); } @@ -457,7 +449,7 @@ public class Persistence { } } - public void resetCommunityMaps(){ + public synchronized void resetCommunityMaps(){ try { communityMaps = new ArrayList<MapData>(); communityMaps.add(new MapData("fbf44184867512faecc195ae75ca55d5ab7bad2d", "Arena3", 18, 18, "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12")); @@ -470,4 +462,20 @@ public class Persistence { } } + public synchronized void login(String userName, String password) throws NoSuchAlgorithmException, RuntimeException, DatabaseException { + try { + String hash = HashGenerator.hashAndHex(password); + if (hash.equals(db.checkCredentials(userName))) { + account = new PlayerAccount(userName, hash, AccountType.ONLINE); + gsonHandler.saveAccount(account); + log.info("Login successful!"); + } else { + throw new DatabaseException("Wrong password!"); + } + } + catch (GSONException | SQLException e) { + throw new RuntimeException(e); + } + } + } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PlayerAccount.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PlayerAccount.java index a028edd30e66fc1116615efb7764503e3746469a..ae1e60649de3d31e4a1b99e70de92a9bfbfe0c53 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PlayerAccount.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PlayerAccount.java @@ -1,5 +1,7 @@ package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; + public class PlayerAccount { private String playerName; diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java index 700868280f57d86a35458287c37af2e5bb432f1e..c33a1f4469770dabd9541bec1d6ddba587fc7e0d 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java @@ -6,9 +6,15 @@ import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.ParserE import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Utilities.HashGenerator; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Utilities.Parser; import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; +import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; +import de.hdm_stuttgart.battlearena.Model.Map.Biom; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.ArrayList; +import java.util.List; + public class RuntimeInfo { private static final Logger log = LogManager.getLogger(RuntimeInfo.class); @@ -25,15 +31,24 @@ public class RuntimeInfo { private EntityClass playerOneClass = EntityClass.HUMAN; private EntityClass playerTwoClass = EntityClass.HUMAN; + private Biom mapBiom = Biom.GRASS; //Default value: GRASS - private RuntimeInfo(){}; + private List<IEntity> gameplayObjects = new ArrayList<>(); - public static RuntimeInfo getInstance(){ - return runtimeInfoSingleton; - } + //Stats Tracking during Gameplay + private int kills = 0; + private int deaths = 0; + private int blocksDestroyed = 0; + private int gameTime = 0; + private boolean gameWon = true; - public String getMapDataGame() { - return mapDataGame; + + + + private RuntimeInfo() {} + + public static RuntimeInfo getInstance() { + return runtimeInfoSingleton; } public MapData generateMap(String mapName, String mapData) throws ParserException { @@ -41,23 +56,29 @@ public class RuntimeInfo { Parser.mapDataValid(mapData); Parser.mapNameValid(mapName); return new MapData(HashGenerator.hashAndHex(mapData), mapName, 18, 18, mapData); - } - catch(Exception e){ + } catch (Exception e) { log.error(e); throw new ParserException(e.getMessage()); } } - public void setGameMap(MapData mapSelected){ //Create Game Scene Dropdown list directly gives reference to selected map + public void setGameMap(MapData mapSelected) { //Create Game Scene Dropdown list directly gives reference to selected map try { mapGame = mapSelected; mapDataGame = mapSelected.getMapData(); - } - catch(Exception e){ + } catch (Exception e) { log.error(e); } } + public void resetGameStats(){ + kills = 0; + deaths = 0; + blocksDestroyed = 0; + gameTime = 0; + gameWon = true; + } + public GameState getGameState() { return gameState; } @@ -106,4 +127,80 @@ public class RuntimeInfo { this.playerTwoClass = playerTwoClass; } + public Biom getMapBiom() { + return mapBiom; + } + + public void setMapBiom(Biom mapBiom) { + this.mapBiom = mapBiom; + } + + public List<IEntity> getGameplayObjects() { + return gameplayObjects; + } + + public void setGameplayObjects(List<IEntity> gameplayObjects) { + this.gameplayObjects = gameplayObjects; + } + + public String getMapDataGame() { + return mapDataGame; + } + + public int getKills() { + return kills; + } + + public void setKills(int kills) { + this.kills = kills; + } + + public void addKill() { + kills = kills + 1; + } + + public int getDeaths() { + return deaths; + } + + public void setDeaths(int deaths) { + this.deaths = deaths; + } + + public void addDeath() { + deaths = deaths + 1; + } + + public int getBlocksDestroyed() { + return blocksDestroyed; + } + + public void setBlocksDestroyed(int blocksDestroyed) { + this.blocksDestroyed = blocksDestroyed; + } + + public void addBlockDestroyed() { + blocksDestroyed = blocksDestroyed + 1; + } + + public int getGameTime() { + return gameTime; + } + + public void setGameTime(int gameTime) { + this.gameTime = gameTime; + } + + public void addGameTime() { + gameTime = gameTime + 1; + } + + public boolean isGameWon() { + return gameWon; + } + + public void setGameWon(boolean gameWon) { + this.gameWon = gameWon; + } + } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadCreateAcc.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadCreateAcc.java new file mode 100644 index 0000000000000000000000000000000000000000..e7f37c6deec9db193b2f3ac8410cf28cbf44b202 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadCreateAcc.java @@ -0,0 +1,42 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadCreateAcc extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadCreateAcc.class); + private String playerName; + private String password; + private AccountType type; + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadCreateAccMsg(""); + threadsInstance.setThreadCreateAcc(ThreadStatus.RUNNING); + persistenceInst.createAccount(playerName, password, type); + log.info("Create account thread finished successfully!"); + threadsInstance.setThreadCreateAcc(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadCreateAccMsg(e.getMessage()); + log.info("Create account thread failed!"); + threadsInstance.setThreadCreateAcc(ThreadStatus.FAILED); + } + } + + public void startThread(String playerName, String password, AccountType type){ + this.playerName = playerName; + this.password = password; + this.type = type; + start(); + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadDLCommMap.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadDLCommMap.java new file mode 100644 index 0000000000000000000000000000000000000000..76bf3c0ebcc16150b3e34d907faaf0b5c33794e7 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadDLCommMap.java @@ -0,0 +1,37 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadDLCommMap extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadDLCommMap.class); + private String mapID; + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadDLCommMapMsg(""); + threadsInstance.setThreadDLCommMap(ThreadStatus.RUNNING); + persistenceInst.getCommunityMap(mapID); + log.info("Download Community-Map thread finished successfully!"); + threadsInstance.setThreadDLCommMap(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadDLCommMapMsg(e.getMessage()); + log.info("Download Community-Map thread failed!"); + threadsInstance.setThreadDLCommMap(ThreadStatus.FAILED); + } + } + + public void startThread(String mapID){ + this.mapID = mapID; + start(); + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadGetMapList.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadGetMapList.java new file mode 100644 index 0000000000000000000000000000000000000000..0062eaf71c227ed5aa6614307e6024357f691560 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadGetMapList.java @@ -0,0 +1,31 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadGetMapList extends Thread { + + private static final Logger log = LogManager.getLogger(ThreadGetMapList.class); + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadCommMapListMsg(""); + threadsInstance.setThreadCommMapList(ThreadStatus.RUNNING); + persistenceInst.createRemoteCommunityMapsList(); + log.info("Retrieving Community-Map-List thread finished successfully!"); + threadsInstance.setThreadCommMapList(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadCommMapListMsg(e.getMessage()); + log.info("Retrieving Community-Map-List thread failed!"); + threadsInstance.setThreadCommMapList(ThreadStatus.FAILED); + } + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadLogin.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadLogin.java new file mode 100644 index 0000000000000000000000000000000000000000..b6bb5e6c7c647dfe372702933672eead65c56b02 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadLogin.java @@ -0,0 +1,39 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadLogin extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadLogin.class); + private String userName; + private String password; + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadLoginMsg(""); + threadsInstance.setThreadLogin(ThreadStatus.RUNNING); + persistenceInst.login(userName, password); + log.info("Login thread finished successfully!"); + threadsInstance.setThreadLogin(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadLoginMsg(e.getMessage()); + log.info("Login thread failed!"); + threadsInstance.setThreadLogin(ThreadStatus.FAILED); + } + } + + public void startThread(String userName, String password){ + this.userName = userName; + this.password = password; + start(); + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadRstStats.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadRstStats.java new file mode 100644 index 0000000000000000000000000000000000000000..c815c70fc73043c305ddad9e575ac662207a50ac --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadRstStats.java @@ -0,0 +1,31 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadRstStats extends Thread { + + private static final Logger log = LogManager.getLogger(ThreadRstStats.class); + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadRstStatsMsg(""); + threadsInstance.setThreadRstStats(ThreadStatus.RUNNING); + persistenceInst.resetPlayerStatistics(); + log.info("Reset Player-Statistics thread finished successfully!"); + threadsInstance.setThreadRstStats(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadRstStatsMsg(e.getMessage()); + log.info("Reset Player-Statistics thread failed!"); + threadsInstance.setThreadRstStats(ThreadStatus.FAILED); + } + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadSaveCommMap.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadSaveCommMap.java new file mode 100644 index 0000000000000000000000000000000000000000..47877f48acc768333279887fd1a899bdb046ac65 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadSaveCommMap.java @@ -0,0 +1,39 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadSaveCommMap extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadSaveCommMap.class); + private MapData map; + private boolean doUpload; + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadSaveCommMapMsg(""); + threadsInstance.setThreadSaveCommMap(ThreadStatus.RUNNING); + persistenceInst.saveCreatedMap(map, doUpload); + log.info("Uploading Community-Map thread finished successfully!"); + threadsInstance.setThreadSaveCommMap(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadSaveCommMapMsg(e.getMessage()); + log.info("Uploading Community-Map thread failed!"); + threadsInstance.setThreadSaveCommMap(ThreadStatus.FAILED); + } + } + + public void startThread(MapData map, boolean doUpload){ //user can check box to optionally publish map on SQL server + this.map = map; + this.doUpload = doUpload; + start(); + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadSaveStats.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadSaveStats.java new file mode 100644 index 0000000000000000000000000000000000000000..3b6c425300db7c7790908c47e36e2282e788b33e --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadSaveStats.java @@ -0,0 +1,31 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadSaveStats extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadSaveStats.class); + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadSaveStatsMsg(""); + threadsInstance.setThreadSaveStats(ThreadStatus.RUNNING); + persistenceInst.savePlayerStatistics(); + log.info("Save Player-Statistics thread finished successfully!"); + threadsInstance.setThreadSaveStats(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadSaveStatsMsg(e.getMessage()); + log.info("Save Player-Statistics thread failed!"); + threadsInstance.setThreadSaveStats(ThreadStatus.FAILED); + } + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/StartupThread.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup1.java similarity index 51% rename from src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/StartupThread.java rename to src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup1.java index a7ad2fddfea2cc499a0de9994f1bfe2b193f87aa..3b8016b8ed5629b16ef2d949f6fc9a0376f51ad1 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/StartupThread.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup1.java @@ -1,18 +1,22 @@ package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class StartupThread extends Thread{ +public class ThreadStartup1 extends Thread{ - private static final Logger log = LogManager.getLogger(StartupThread.class); + private static final Logger log = LogManager.getLogger(ThreadStartup1.class); @Override public void run() { Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); try { + threadsInstance.setThreadStartup1Msg(""); + threadsInstance.setThreadStartup1(ThreadStatus.RUNNING); persistenceInst.loadSettings(); persistenceInst.loadCoreMaps(); persistenceInst.loadCommunityMaps(); @@ -20,8 +24,12 @@ public class StartupThread extends Thread{ persistenceInst.verifyCoreMaps(); persistenceInst.verifyCommunityMaps(); log.info("Startup routine part1 complete!"); + threadsInstance.setThreadStartup1(ThreadStatus.FINISHED); } catch (Exception e) { log.error(e); + threadsInstance.setThreadStartup1Msg(e.getMessage()); + log.info("Startup routine part1 failed!"); + threadsInstance.setThreadStartup1(ThreadStatus.FAILED); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup2.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup2.java new file mode 100644 index 0000000000000000000000000000000000000000..50ba60bf4edc9c10f56ed27e7833a65ae3e808d6 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup2.java @@ -0,0 +1,35 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadStartup2 extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadStartup2.class); + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadStartup2Msg(""); + threadsInstance.setThreadStartup2(ThreadStatus.RUNNING); + persistenceInst.loadPlayerAccount(); + if(persistenceInst.getAccount().getAccountType() != AccountType.NONE){ + persistenceInst.verifyPlayerAccount(); + } + log.info("Startup routine part2 complete!"); + threadsInstance.setThreadStartup2(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadStartup2Msg(e.getMessage()); + log.info("Startup routine part2 failed!"); + threadsInstance.setThreadStartup2(ThreadStatus.FAILED); + } + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup3.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup3.java new file mode 100644 index 0000000000000000000000000000000000000000..738c4add7276cc2706a23204b0b7daef94e51975 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadStartup3.java @@ -0,0 +1,35 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadStartup3 extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadStartup3.class); + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadStartup3Msg(""); + threadsInstance.setThreadStartup3(ThreadStatus.RUNNING); + persistenceInst.loadPlayerStatistics(); + if(persistenceInst.getAccount().getAccountType() != AccountType.NONE){ + persistenceInst.verifyPlayerAccount(); + } + log.info("Startup routine part3 complete!"); + threadsInstance.setThreadStartup3(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadStartup3Msg(e.getMessage()); + log.info("Startup routine part3 failed!"); + threadsInstance.setThreadStartup3(ThreadStatus.FAILED); + } + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateMaps.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateMaps.java new file mode 100644 index 0000000000000000000000000000000000000000..f0bc303975da0e08d54330a3331e9dca7bee1577 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateMaps.java @@ -0,0 +1,31 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadUpdateMaps extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadUpdateMaps.class); + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadUpdateMapsMsg(""); + threadsInstance.setThreadUpdateMaps(ThreadStatus.RUNNING); + persistenceInst.updateCoreMaps(); + log.info("Update Core-Maps thread finished successfully!"); + threadsInstance.setThreadUpdateMaps(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadUpdateMapsMsg(e.getMessage()); + log.info("Update Core-Maps thread failed!"); + threadsInstance.setThreadUpdateMaps(ThreadStatus.FAILED); + } + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateStats.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateStats.java new file mode 100644 index 0000000000000000000000000000000000000000..44ae6fe13e20f599800784e95dc6b0bd9a8ca9b7 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateStats.java @@ -0,0 +1,37 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ThreadUpdateStats extends Thread{ + + private static final Logger log = LogManager.getLogger(ThreadUpdateStats.class); + + @Override + public void run() { + + Persistence persistenceInst = Persistence.getInstance(); + RuntimeInfo runtimeInfoInst = RuntimeInfo.getInstance(); + Threads threadsInstance = Threads.getInstance(); + + try { + threadsInstance.setThreadUpdateStatsMsg(""); + threadsInstance.setThreadUpdateStats(ThreadStatus.RUNNING); + persistenceInst.updatePlayerStatistics(runtimeInfoInst.getKills(), runtimeInfoInst.getDeaths(), runtimeInfoInst.getGameTime(), runtimeInfoInst.getBlocksDestroyed(), runtimeInfoInst.isGameWon()); + runtimeInfoInst.setKills(0); + runtimeInfoInst.setDeaths(0); + runtimeInfoInst.setGameTime(0); + runtimeInfoInst.setBlocksDestroyed(0); + runtimeInfoInst.setGameWon(false); + log.info("Update statistics thread finished successfully!"); + threadsInstance.setThreadUpdateStats(ThreadStatus.FINISHED); + } catch (Exception e) { + log.error(e); + threadsInstance.setThreadUpdateStatsMsg(e.getMessage()); + log.info("Update statistics thread failed!"); + threadsInstance.setThreadUpdateStats(ThreadStatus.FAILED); + } + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Threads.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Threads.java new file mode 100644 index 0000000000000000000000000000000000000000..ebf4876b70d047545985366e5983fdd7438a97ec --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Threads.java @@ -0,0 +1,237 @@ +package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; + +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.ThreadStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class Threads { + + private static final Logger log = LogManager.getLogger(Threads.class); + private static final Threads threadsSingleton = new Threads(); + + //Thread Status-Updates + private ThreadStatus threadStartup1; + private String threadStartup1Msg; + private ThreadStatus threadStartup2; + private String threadStartup2Msg; + private ThreadStatus threadStartup3; + private String threadStartup3Msg; + private ThreadStatus threadUpdateMaps; + private String threadUpdateMapsMsg; + private ThreadStatus threadUpdateStats; + private String threadUpdateStatsMsg; + private ThreadStatus threadDLCommMap; + private String threadDLCommMapMsg; + private ThreadStatus threadSaveCommMap; + private String threadSaveCommMapMsg; + private ThreadStatus threadCommMapList; + private String threadCommMapListMsg; + private ThreadStatus threadRstStats; + private String threadRstStatsMsg; + private ThreadStatus threadSaveStats; + private String threadSaveStatsMsg; + private ThreadStatus threadCreateAcc; + private String threadCreateAccMsg; + private ThreadStatus threadLogin; + private String threadLoginMsg; + + + + private Threads(){}; + public static Threads getInstance(){ + return threadsSingleton; + } + + public ThreadStatus getThreadStartup1() { + return threadStartup1; + } + + public void setThreadStartup1(ThreadStatus threadStartup1) { + this.threadStartup1 = threadStartup1; + } + + public String getThreadStartup1Msg() { + return threadStartup1Msg; + } + + public void setThreadStartup1Msg(String threadStartup1Msg) { + this.threadStartup1Msg = threadStartup1Msg; + } + + public ThreadStatus getThreadStartup2() { + return threadStartup2; + } + + public void setThreadStartup2(ThreadStatus threadStartup2) { + this.threadStartup2 = threadStartup2; + } + + public String getThreadStartup2Msg() { + return threadStartup2Msg; + } + + public void setThreadStartup2Msg(String threadStartup2Msg) { + this.threadStartup2Msg = threadStartup2Msg; + } + + public ThreadStatus getThreadUpdateMaps() { + return threadUpdateMaps; + } + + public ThreadStatus getThreadStartup3() { + return threadStartup3; + } + + public void setThreadStartup3(ThreadStatus threadStartup3) { + this.threadStartup3 = threadStartup3; + } + + public String getThreadStartup3Msg() { + return threadStartup3Msg; + } + + public void setThreadStartup3Msg(String threadStartup3Msg) { + this.threadStartup3Msg = threadStartup3Msg; + } + + public void setThreadUpdateMaps(ThreadStatus threadUpdateMaps) { + this.threadUpdateMaps = threadUpdateMaps; + } + + public String getThreadUpdateMapsMsg() { + return threadUpdateMapsMsg; + } + + public void setThreadUpdateMapsMsg(String threadUpdateMapsMsg) { + this.threadUpdateMapsMsg = threadUpdateMapsMsg; + } + + public ThreadStatus getThreadUpdateStats() { + return threadUpdateStats; + } + + public void setThreadUpdateStats(ThreadStatus threadUpdateStats) { + this.threadUpdateStats = threadUpdateStats; + } + + public String getThreadUpdateStatsMsg() { + return threadUpdateStatsMsg; + } + + public void setThreadUpdateStatsMsg(String threadUpdateStatsMsg) { + this.threadUpdateStatsMsg = threadUpdateStatsMsg; + } + + public ThreadStatus getThreadDLCommMap() { + return threadDLCommMap; + } + + public void setThreadDLCommMap(ThreadStatus threadDLCommMap) { + this.threadDLCommMap = threadDLCommMap; + } + + public String getThreadDLCommMapMsg() { + return threadDLCommMapMsg; + } + + public void setThreadDLCommMapMsg(String threadDLCommMapMsg) { + this.threadDLCommMapMsg = threadDLCommMapMsg; + } + + public ThreadStatus getThreadSaveCommMap() { + return threadSaveCommMap; + } + + public void setThreadSaveCommMap(ThreadStatus threadSaveCommMap) { + this.threadSaveCommMap = threadSaveCommMap; + } + + public String getThreadSaveCommMapMsg() { + return threadSaveCommMapMsg; + } + + public void setThreadSaveCommMapMsg(String threadSaveCommMapMsg) { + this.threadSaveCommMapMsg = threadSaveCommMapMsg; + } + + public ThreadStatus getThreadCommMapList() { + return threadCommMapList; + } + + public void setThreadCommMapList(ThreadStatus threadCommMapList) { + this.threadCommMapList = threadCommMapList; + } + + public String getThreadCommMapListMsg() { + return threadCommMapListMsg; + } + + public void setThreadCommMapListMsg(String threadCommMapListMsg) { + this.threadCommMapListMsg = threadCommMapListMsg; + } + + public ThreadStatus getThreadRstStats() { + return threadRstStats; + } + + public void setThreadRstStats(ThreadStatus threadRstStats) { + this.threadRstStats = threadRstStats; + } + + public String getThreadRstStatsMsg() { + return threadRstStatsMsg; + } + + public void setThreadRstStatsMsg(String threadRstStatsMsg) { + this.threadRstStatsMsg = threadRstStatsMsg; + } + + public ThreadStatus getThreadSaveStats() { + return threadSaveStats; + } + + public void setThreadSaveStats(ThreadStatus threadSaveStats) { + this.threadSaveStats = threadSaveStats; + } + + public String getThreadSaveStatsMsg() { + return threadSaveStatsMsg; + } + + public void setThreadSaveStatsMsg(String threadSaveStatsMsg) { + this.threadSaveStatsMsg = threadSaveStatsMsg; + } + + public ThreadStatus getThreadCreateAcc() { + return threadCreateAcc; + } + + public void setThreadCreateAcc(ThreadStatus threadCreateAcc) { + this.threadCreateAcc = threadCreateAcc; + } + + public String getThreadCreateAccMsg() { + return threadCreateAccMsg; + } + + public void setThreadCreateAccMsg(String threadCreateAccMsg) { + this.threadCreateAccMsg = threadCreateAccMsg; + } + + public ThreadStatus getThreadLogin() { + return threadLogin; + } + + public void setThreadLogin(ThreadStatus threadLogin) { + this.threadLogin = threadLogin; + } + + public String getThreadLoginMsg() { + return threadLoginMsg; + } + + public void setThreadLoginMsg(String threadLoginMsg) { + this.threadLoginMsg = threadLoginMsg; + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_AzureDB.sql b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_AzureDB.sql index bd3b7cc0344912f98142b0a01760952356a327b7..d98f718bfa310c5060e88919eff6069fe10412be 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_AzureDB.sql +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_AzureDB.sql @@ -33,18 +33,18 @@ CREATE TABLE players( INSERT INTO coremaps (map_id, map_name, map_width, map_height, map_data) -VALUES ('09a02b54d05b5b7ebc29a4383ca12d3dda846b72', +VALUES ('b8f5da1a3619a3585978a6d9c8c683c3210193e6', 'Arena1', 18, 18, - '12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12'); + '11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12'); INSERT INTO coremaps (map_id, map_name, map_width, map_height, map_data) -VALUES ('0ab15557ab6dc4be60dfe6a9b0288bac3036bd97', - 'Arena2', +VALUES ('6b9ff964a4afc821672645d5c2bb8fb2b0dcb2e8', + 'Outpost', 18, 18, - '12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12'); + '16 16 16 16 16 16 16 16 16 16 10 12 13 11 12 14 11 12 16 0 16 0 0 1 0 0 0 0 1 0 0 1 0 2 0 12 16 0 0 0 0 0 16 16 0 0 15 3 0 0 0 2 1 12 16 0 0 2 16 0 0 1 16 0 15 15 3 3 0 2 0 12 11 10 12 2 11 10 12 0 16 0 0 15 15 3 1 2 0 12 11 0 0 2 0 0 12 0 0 16 0 0 15 3 0 2 0 12 11 0 10 2 10 0 12 0 0 16 0 0 15 15 12 2 11 12 11 0 10 2 10 0 12 0 0 0 0 0 0 0 0 2 0 16 11 0 1 2 10 0 12 16 0 0 11 10 0 10 12 2 0 16 11 0 10 2 10 0 1 0 0 16 11 3 0 0 12 0 1 16 11 0 10 2 10 0 12 0 16 0 11 0 0 1 12 2 0 16 11 0 10 2 10 0 12 0 0 0 11 0 0 0 12 2 0 16 11 0 0 1 0 0 12 16 0 0 11 0 0 0 12 0 0 16 11 10 12 2 11 10 12 0 16 0 11 0 10 10 12 2 0 16 16 0 0 2 16 0 0 0 0 0 11 0 0 3 12 0 11 12 16 0 16 16 16 0 0 16 0 0 1 0 0 0 0 2 0 12 16 0 0 0 0 0 0 0 0 0 11 0 0 1 0 2 0 12 16 16 16 16 16 16 16 16 16 16 11 12 13 11 12 14 11 12'); INSERT INTO communitymaps (map_id, map_name, map_width, map_height, map_data, map_downloads) VALUES ('fbf44184867512faecc195ae75ca55d5ab7bad2d', diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_Oracle.sql b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_Oracle.sql index 22de38024bc74b449f2ca80e2afa3cc063aea840..63b515d5f848f494f59dd9d541356972153a4338 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_Oracle.sql +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_Oracle.sql @@ -42,18 +42,18 @@ ALTER USER battlearenadata QUOTA 500M ON communitymaps; ALTER USER battlearenadata QUOTA 500M ON players; INSERT INTO battlearenadata.coremaps (map_id, map_name, map_width, map_height, map_data) -VALUES ('09a02b54d05b5b7ebc29a4383ca12d3dda846b72', +VALUES ('b8f5da1a3619a3585978a6d9c8c683c3210193e6', 'Arena1', 18, 18, - '12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12'); + '11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12'); INSERT INTO battlearenadata.coremaps (map_id, map_name, map_width, map_height, map_data) -VALUES ('0ab15557ab6dc4be60dfe6a9b0288bac3036bd97', - 'Arena2', +VALUES ('6b9ff964a4afc821672645d5c2bb8fb2b0dcb2e8', + 'Outpost', 18, 18, - '12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12'); + '16 16 16 16 16 16 16 16 16 16 10 12 13 11 12 14 11 12 16 0 16 0 0 1 0 0 0 0 1 0 0 1 0 2 0 12 16 0 0 0 0 0 16 16 0 0 15 3 0 0 0 2 1 12 16 0 0 2 16 0 0 1 16 0 15 15 3 3 0 2 0 12 11 10 12 2 11 10 12 0 16 0 0 15 15 3 1 2 0 12 11 0 0 2 0 0 12 0 0 16 0 0 15 3 0 2 0 12 11 0 10 2 10 0 12 0 0 16 0 0 15 15 12 2 11 12 11 0 10 2 10 0 12 0 0 0 0 0 0 0 0 2 0 16 11 0 1 2 10 0 12 16 0 0 11 10 0 10 12 2 0 16 11 0 10 2 10 0 1 0 0 16 11 3 0 0 12 0 1 16 11 0 10 2 10 0 12 0 16 0 11 0 0 1 12 2 0 16 11 0 10 2 10 0 12 0 0 0 11 0 0 0 12 2 0 16 11 0 0 1 0 0 12 16 0 0 11 0 0 0 12 0 0 16 11 10 12 2 11 10 12 0 16 0 11 0 10 10 12 2 0 16 16 0 0 2 16 0 0 0 0 0 11 0 0 3 12 0 11 12 16 0 16 16 16 0 0 16 0 0 1 0 0 0 0 2 0 12 16 0 0 0 0 0 0 0 0 0 11 0 0 1 0 2 0 12 16 16 16 16 16 16 16 16 16 16 11 12 13 11 12 14 11 12'); INSERT INTO battlearenadata.communitymaps (map_id, map_name, map_width, map_height, map_data, map_downloads) VALUES ('fbf44184867512faecc195ae75ca55d5ab7bad2d', diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java index 9d860c1af101e6002e51c846e70d219cee7772e1..675946aeef36f7e8453278393e233e854c76b04c 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java @@ -48,19 +48,19 @@ public class CollisionHandler { case UP: tileOne = tileMap[nextPlayerTop][leftColumn]; tileTwo = tileMap[nextPlayerTop][rightColumn]; - return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + return tileSet[tileOne].getCollision() && tileSet[tileTwo].getCollision(); case DOWN: tileOne = tileMap[nextPlayerBottom][leftColumn]; tileTwo = tileMap[nextPlayerBottom][rightColumn]; - return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + return tileSet[tileOne].getCollision() && tileSet[tileTwo].getCollision(); case LEFT: tileOne = tileMap[topRow][nextPlayerLeft]; tileTwo = tileMap[bottomRow][nextPlayerLeft]; - return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + return tileSet[tileOne].getCollision() && tileSet[tileTwo].getCollision(); case RIGHT: tileOne = tileMap[topRow][nextPlayerRight]; tileTwo = tileMap[bottomRow][nextPlayerRight]; - return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + return tileSet[tileOne].getCollision() && tileSet[tileTwo].getCollision(); default: return true; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java index 2e49bcaca57667a7fbea0431ff0fe8c91b356ac5..22ac1a31fc968a838a68df00b1ddad28261b177b 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java @@ -2,6 +2,9 @@ package de.hdm_stuttgart.battlearena.Model.Entity; import de.hdm_stuttgart.battlearena.Controller.Enum.PlayerMode; import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.Bomb; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.Heart; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectType; import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; import javafx.scene.canvas.GraphicsContext; @@ -26,4 +29,17 @@ public class EntityFactory { throw new IllegalArgumentException ("Entity type not supported " + entityType); } + public static IEntity createGameplayObject(ObjectType objectType, int cordX, int cordY, GraphicsContext graphicsContext) { + if (objectType == ObjectType.HEART) { + return new Heart(cordX, cordY, graphicsContext); + } else if (objectType == ObjectType.BIG_BOMB) { + return new Bomb(cordX, cordY, graphicsContext); + } else if (objectType == ObjectType.BOMB) { + return new Bomb(cordX, cordY, graphicsContext); + } else if (objectType == ObjectType.EXPLOSION) { + return new Explosion(cordX, cordY, graphicsContext); + } + throw new IllegalArgumentException(); + } + } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Explosion.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Explosion.java new file mode 100644 index 0000000000000000000000000000000000000000..4dc7bc0042e2f9ab9a22f0e32cc388a1baabd747 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Explosion.java @@ -0,0 +1,119 @@ +package de.hdm_stuttgart.battlearena.Model.Entity; + +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectStatus; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectType; +import javafx.geometry.BoundingBox; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.image.Image; + +import java.util.Objects; + +public class Explosion implements IEntity { + + private final int posX; + private final int posY; + private Image sprite; + private final GraphicsContext graphicsContext; + private BoundingBox boxCollider; + private boolean status; + private final ObjectType OBJECT_TYPE = ObjectType.EXPLOSION; + + private final ObjectStatus OBJECT_STATUS = ObjectStatus.UNUSED; + public Explosion(int posX, int posY, GraphicsContext graphicsContext) { + this.posX = posX; + this.posY = posY; + this.graphicsContext = graphicsContext; + + initializeEntity(); + } + @Override + public void initializeEntity() { + loadEntitySprites(); + boxCollider = new BoundingBox(posX+12, posY+12, 24, 24); + } + @Override + public void loadEntitySprites() { + sprite = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/vfx/smallexplosion.png"))); + } + + @Override + public void updateEntityMovement(GameSceneController gameScene) { + + } + + @Override + public void checkGameplayObjectInteraction(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void placeBomb(IEntity entity, IEntity entity2, GraphicsContext graphicsContext) { + + } + + @Override + public void attack(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void updateEntityWalkAnimation() { + + } + + @Override + public void renderEntity(GraphicsContext graphicsContext) { + graphicsContext.drawImage(sprite, posX, posY, 48, 48); + } + + @Override + public void healPlayer(int heal) { + + } + + @Override + public BoundingBox getBoxCollider() { + return boxCollider; + } + + @Override + public EntityDirection getEntityDirection() { + return null; + } + + @Override + public int getEntitySpeed() { + return 0; + } + + @Override + public void gotHit(int damageDone) { + + } + + @Override + public int getMapPosX() { + return posX; + } + + @Override + public int getMapPosY() { + return posY; + } + + public ObjectType getOBJECT_TYPE() { + return OBJECT_TYPE; + } + + @Override + public ObjectStatus getOBJECT_STATUS() { + return OBJECT_STATUS; + } + + @Override + public void setObjectStatus(ObjectStatus objectStatus) { + + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java new file mode 100644 index 0000000000000000000000000000000000000000..98d1d25c2fdec8b4a97fb8261593414df11d7992 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java @@ -0,0 +1,149 @@ +package de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects; + +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityDirection; +import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; + +import javafx.geometry.BoundingBox; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.image.Image; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +import java.util.Objects; + +public class Bomb implements IEntity { + private boolean status; + + private static final Logger log = LogManager.getLogger(Bomb.class); + private final int posX; + private final int posY; + private int frameIndex = 0; + private int frameCounter = 0; + private Image[] frames = new Image[4]; + private final GraphicsContext graphicsContext; + private BoundingBox boxCollider; + private final ObjectType OBJECT_TYPE = ObjectType.BOMB; + private ObjectStatus OBJECT_STATUS = ObjectStatus.UNUSED; + + public Bomb(int posX, int posY, GraphicsContext graphicsContext) { + this.posX = posX; + this.posY = posY; + this.graphicsContext = graphicsContext; + + initializeEntity(); + } + + @Override + public void initializeEntity() { + loadEntitySprites(); + boxCollider = new BoundingBox(posX + 12, posY + 12, 24, 24); + } + + @Override + public void loadEntitySprites() { + frames[0] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/bomb/bomb.png"))); + frames[1] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/vfx/bigexplosion.png"))); + frames[2] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/vfx/middleexplosion.png"))); + frames[3] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/vfx/smallexplosion.png"))); + } + + @Override + public void updateEntityMovement(GameSceneController gameScene) { + + } + + @Override + public void checkGameplayObjectInteraction(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void placeBomb(IEntity entity, IEntity entity2, GraphicsContext graphicsContext) { + + } + + @Override + public void attack(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void updateEntityWalkAnimation() { + + } + + public void renderEntity(GraphicsContext graphicsContext) { + graphicsContext.drawImage(frames[frameIndex], posX, posY, 48, 48); + updateAnimation(); + } + + private void updateAnimation() { + frameCounter++; + + if (frameCounter > 10) { + if (frameIndex == 0) { + frameIndex = 1; + } else if (frameIndex == 1) { + frameIndex = 2; + } else if (frameIndex == 2) { + frameIndex = 3; + } else if (frameIndex == 3) { + OBJECT_STATUS = ObjectStatus.USED; + } + frameCounter = 0; + } + } + + @Override + public void healPlayer(int heal) { + + } + + @Override + public BoundingBox getBoxCollider() { + return boxCollider; + } + + @Override + public EntityDirection getEntityDirection() { + return null; + } + + @Override + public int getEntitySpeed() { + return 0; + } + + @Override + public void gotHit(int damageDone) { + + } + + @Override + public int getMapPosX() { + return posX; + } + + @Override + public int getMapPosY() { + return posY; + } + + @Override + public ObjectType getOBJECT_TYPE() { + return OBJECT_TYPE; + } + + @Override + public ObjectStatus getOBJECT_STATUS() { + return OBJECT_STATUS; + } + + @Override + public void setObjectStatus(ObjectStatus objectStatus) { + OBJECT_STATUS = objectStatus; + } + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Heart.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Heart.java new file mode 100644 index 0000000000000000000000000000000000000000..464e2a93cf37038e6882014231a295783412e242 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Heart.java @@ -0,0 +1,127 @@ +package de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects; + +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityDirection; +import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; + +import javafx.geometry.BoundingBox; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.image.Image; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +import java.util.Objects; + +public class Heart implements IEntity { + + private static final Logger log = LogManager.getLogger(Heart.class); + + private final int posX; + private final int posY; + private Image sprite; + private final GraphicsContext graphicsContext; + private BoundingBox boxCollider; + private final ObjectType OBJECT_TYPE = ObjectType.HEART; + private ObjectStatus OBJECT_STATUS = ObjectStatus.UNUSED; + + public Heart(int posX, int posY, GraphicsContext graphicsContext) { + this.posX = posX; + this.posY = posY; + this.graphicsContext = graphicsContext; + + initializeEntity(); + } + + @Override + public void initializeEntity() { + loadEntitySprites(); + boxCollider = new BoundingBox(posX+12, posY+12, 24, 24); + } + + @Override + public void loadEntitySprites() { + sprite = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/heal/heart.png"))); + } + + @Override + public void updateEntityMovement(GameSceneController gameScene) { + + } + + @Override + public void checkGameplayObjectInteraction(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void placeBomb(IEntity entity, IEntity entity2, GraphicsContext graphicsContext) { + + } + + @Override + public void attack(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void updateEntityWalkAnimation() { + + } + + @Override + public void renderEntity(GraphicsContext graphicsContext) { + graphicsContext.drawImage(sprite, posX, posY, 48, 48); + } + + @Override + public void healPlayer(int heal) { + + } + + @Override + public BoundingBox getBoxCollider() { + return boxCollider; + } + + @Override + public EntityDirection getEntityDirection() { + return null; + } + + @Override + public int getEntitySpeed() { + return 0; + } + + @Override + public void gotHit(int damageDone) { + + } + + @Override + public int getMapPosX() { + return posX; + } + + @Override + public int getMapPosY() { + return posY; + } + + @Override + public ObjectType getOBJECT_TYPE() { + return OBJECT_TYPE; + } + + @Override + public ObjectStatus getOBJECT_STATUS() { + return OBJECT_STATUS; + } + + @Override + public void setObjectStatus(ObjectStatus objectStatus) { + OBJECT_STATUS = objectStatus; + } + +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/ObjectStatus.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/ObjectStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..265e140799026fb35b7d8c4c241a6646c3de3d06 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/ObjectStatus.java @@ -0,0 +1,6 @@ +package de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects; + +public enum ObjectStatus { + USED, + UNUSED +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/ObjectType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/ObjectType.java new file mode 100644 index 0000000000000000000000000000000000000000..754ba6af47d0fe9b14d2dd364a4aa1692ffb73f5 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/ObjectType.java @@ -0,0 +1,8 @@ +package de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects; + +public enum ObjectType { + BIG_BOMB, + BOMB, + HEART, + EXPLOSION +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java index f98ddeb7452f60866c2dfe661dff29162c0004b7..48c41a2feedb132bc619b6f1afb6c92938dc9646 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java @@ -1,37 +1,46 @@ package de.hdm_stuttgart.battlearena.Model.Entity; import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectStatus; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectType; import javafx.geometry.BoundingBox; import javafx.scene.canvas.GraphicsContext; public interface IEntity { - void initializeEntity(); + void initializeEntity(); - void loadEntitySprites(); + void loadEntitySprites(); - void updateEntityMovement(GameSceneController gameScene); + void updateEntityMovement(GameSceneController gameScene); - void checkHealTile(IEntity entity, GraphicsContext graphicsContext); + //checks collision with GameplayObjects by iterating through GameplayObjects list + void checkGameplayObjectInteraction(IEntity entity, GraphicsContext graphicsContext); - void attack(IEntity entity, GraphicsContext graphicsContext); + void placeBomb(IEntity entity, IEntity entity2, GraphicsContext graphicsContext); - void updateEntityWalkAnimation(); + void attack(IEntity entity, GraphicsContext graphicsContext); - void renderEntity(GraphicsContext graphicsContext); + void updateEntityWalkAnimation(); + + void renderEntity(GraphicsContext graphicsContext); void healPlayer(int heal); BoundingBox getBoxCollider(); - EntityDirection getEntityDirection(); + EntityDirection getEntityDirection(); + + int getEntitySpeed(); - int getEntitySpeed(); + void gotHit(int damageDone); - void gotHit(int damageDone); + int getMapPosX(); - int getMapPosX(); + int getMapPosY(); - int getMapPosY(); + ObjectType getOBJECT_TYPE(); + ObjectStatus getOBJECT_STATUS(); + void setObjectStatus(ObjectStatus objectStatus); } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java index d045a108bf051f2e40573e084199808f2edbc630..ee49d28d3809907eb248e7967e5e12ce6c4afd79 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java @@ -2,6 +2,8 @@ package de.hdm_stuttgart.battlearena.Model.Entity; import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectStatus; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectType; import javafx.geometry.BoundingBox; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; @@ -37,7 +39,12 @@ class NetworkPlayerTwo implements IEntity{ } @Override - public void checkHealTile(IEntity entity, GraphicsContext graphicsContext) { + public void checkGameplayObjectInteraction(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void placeBomb(IEntity entity, IEntity entity2, GraphicsContext graphicsContext) { } @@ -94,4 +101,19 @@ class NetworkPlayerTwo implements IEntity{ return 0; } + @Override + public ObjectType getOBJECT_TYPE() { + return null; + } + + @Override + public ObjectStatus getOBJECT_STATUS() { + return null; + } + + @Override + public void setObjectStatus(ObjectStatus objectStatus) { + + } + } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java index c56d432e399e9203e9288c8d11589b2cb59ce129..4a6917349c104d037ca6fa3b698b37ee2dd65c8d 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java @@ -2,9 +2,12 @@ package de.hdm_stuttgart.battlearena.Model.Entity; import de.hdm_stuttgart.battlearena.Controller.Enum.PlayerMode; import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectStatus; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectType; import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; - import de.hdm_stuttgart.battlearena.Model.Map.TileManager; + import javafx.geometry.BoundingBox; import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; @@ -12,6 +15,7 @@ import javafx.scene.image.Image; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import java.util.List; import java.util.Objects; class Player implements IEntity { @@ -21,6 +25,9 @@ class Player implements IEntity { private final PlayerMode PLAYER_MODE; InputHandler inputHandler; + + RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); + CollisionHandler collisionHandler = new CollisionHandler(); GraphicsContext gameScene; @@ -49,7 +56,7 @@ class Player implements IEntity { private int spriteNumber = 1; private final int playerWidth = 19; - private final int playerHeight = 35; + private final int playerHeight = 20; private int scaledTileSize; @@ -61,9 +68,10 @@ class Player implements IEntity { private int playerSpeed; private EntityDirection playerDirection; + private ObjectStatus objectStatus = ObjectStatus.UNUSED; private int health; - private int maxPlayerHealth; + private int maxPlayerHealth; private int damage; public Player(GraphicsContext gameScene, InputHandler inputHandler, EntityClass entityClass, @@ -277,32 +285,117 @@ class Player implements IEntity { } } - boxCollider = new BoundingBox(mapPosX + 15, mapPosY + 10, playerWidth, playerHeight); + boxCollider = new BoundingBox(mapPosX + 15, mapPosY + 20, playerWidth, playerHeight); } + @Override - public void checkHealTile(IEntity entity, GraphicsContext graphicsContext){ + public void checkGameplayObjectInteraction(IEntity entity, GraphicsContext graphicsContext) { + + List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); + for (IEntity gameplayObject : gameplayObjects) { + if (gameplayObject.getOBJECT_TYPE() == ObjectType.HEART) { + if (gameplayObject.getBoxCollider().intersects(boxCollider)) { + log.info("Collision with heart"); + healPlayer(5); + gameplayObject.setObjectStatus(ObjectStatus.USED); + } + } else if (gameplayObject.getOBJECT_TYPE() == ObjectType.BOMB) { + if (gameplayObject.getBoxCollider().intersects(boxCollider)) { + log.info("Collision with bomb"); + gotHit(10); + } + } else if (gameplayObject.getOBJECT_TYPE() == ObjectType.EXPLOSION) { + if (gameplayObject.getBoxCollider().intersects(boxCollider)) { + log.info("Collision with explosion"); + gotHit(10); + } + } + } + } + + @Override + public void placeBomb(IEntity entity, IEntity entity2, GraphicsContext graphicsContext) { + + if (inputHandler.isBomb() && PLAYER_MODE == PlayerMode.PLAYER_ONE || + inputHandler.isSdBomb() && PLAYER_MODE == PlayerMode.PLAYER_TWO) { + int spawnCordX = mapPosX + 12; + int spawnCordY = mapPosY + 12; + + List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); + IEntity bomb = EntityFactory.createGameplayObject(ObjectType.BOMB, spawnCordX, spawnCordY, graphicsContext); + gameplayObjects.add(bomb); + runtimeInfo.setGameplayObjects(gameplayObjects); + log.info("bomb placed"); + } + } + + public void checkChangeTiles(IEntity entity) { + boolean isDestructible; int xTile = entity.getMapPosX() / gameSceneController.getScaledTileSize(); int yTile = entity.getMapPosY() / gameSceneController.getScaledTileSize(); - if(TileManager.tileMap[yTile][xTile +1 ] == 5){ - entity.healPlayer(1); - TileManager.tileMap[yTile][xTile +1] = 2; - log.info("Healed +1: " + health); + isDestructible = checkTileNon_Destructible(yTile, xTile); + if (isDestructible) { + TileManager.tileMap[yTile][xTile] = 7; + for (int i = 0; i < 3; i++) { + isDestructible = checkTileNon_Destructible(yTile + 1 + i, xTile); //If Tile solid , -> should stop comparing, + if (isDestructible && (yTile < 18 && xTile < 18)) { //because for now, Tile behind gets destroyed aswell + TileManager.tileMap[yTile + 1 + i][xTile] = 8; + /*if(entity || entity2) { + entity2.gotHit(2); //See if enemy or player hit + }*/ + } + isDestructible = checkTileNon_Destructible(yTile - 1 - i, xTile); + if (isDestructible && (yTile < 18 && xTile < 18 && yTile > 0 && xTile > 0)) { + TileManager.tileMap[yTile - 1 - i][xTile] = 8; + entity.gotHit(2); + } + isDestructible = checkTileNon_Destructible(yTile, xTile + 1 + i); + if (isDestructible && (yTile < 18 && xTile < 18 && yTile > 0 && xTile > 0)) { + TileManager.tileMap[yTile][xTile + 1 + i] = 8; + entity.gotHit(2); + } + isDestructible = checkTileNon_Destructible(yTile, xTile - 1 - i); + if (isDestructible && (yTile < 18 && xTile < 18 && yTile > 0 && xTile > 0)) { + TileManager.tileMap[yTile][xTile - 1 - i] = 8; + entity.gotHit(2); + } + } } } + /*isDestructible = checkTileNon_Destructible(yTile, xTile); //for loop + if(isDestructible){ + TileManager.tileMap[yTile][xTile] = 7; + isDestructible = checkTileNon_Destructible(yTile-1, xTile); //for loop + }else if(isDestructible) + TileManager.tileMap[yTile-1][xTile] = 8; + TileManager.tileMap[yTile-2][xTile] = 8; //Change it with a DestructionHandler like CollisionHandler + TileManager.tileMap[yTile+1][xTile] = 8; + TileManager.tileMap[yTile+2][xTile] = 8; //Why doesnt it work like in CollisionHandler with tileSet + TileManager.tileMap[yTile][xTile+1] = 8; + TileManager.tileMap[yTile][xTile+2] = 8; + TileManager.tileMap[yTile][xTile-1] = 8; + TileManager.tileMap[yTile][xTile-2] = 8;*/ + //} + //} + + public boolean checkTileNon_Destructible(int y, int x) { //Change it with a DestructionHandler like CollisionHandler + //tileSet[xTile].getDestruction(); + if (TileManager.tileMap[y][x] != 10 && TileManager.tileMap[y][x] != 3 && TileManager.tileMap[y][x] != 4) { + return true; + } + return false; + } + @Override public void attack(IEntity entity, GraphicsContext graphicsContext) { BoundingBox hitBox; int xTile = mapPosX / gameSceneController.getScaledTileSize(); int yTile = mapPosY / gameSceneController.getScaledTileSize(); - //log.info(xTile); - //log.info(yTile); - //int xTile = (int) (Math.random() * (18 - 1)); //Get xTile Coordinate +1 /-1 of playerTile - //int yTile = (int) (Math.random() * (18 - 1)); //Get yTile Coordinate +1 /-1 of playerTile + double dropChance = 0.5; double randomDropChance = Math.random() * 1; - //log.info(randomDropChance); //Added and subtracted numbers from variables are the pixel insets of the player sprite @@ -315,62 +408,45 @@ class Player implements IEntity { hitBox = new BoundingBox(mapPosX + playerWidth, mapPosY - 10, attackWidth, attackRange); graphicsContext.strokeRect(mapPosX + playerWidth, mapPosY - 10, attackWidth, attackRange); graphicsContext.drawImage(swordUp, mapPosX + 8, mapPosY - 10, 32, 32); - if (hitBox.intersects(entity.getBoxCollider())) { - entity.gotHit(damage); - graphicsContext.strokeText("Hit", 10, 10); - - if (((TileManager.tileMap[xTile][yTile] == 3) && randomDropChance > dropChance)|| - ((TileManager.tileMap[xTile][yTile] == 1) && randomDropChance > dropChance)) - TileManager.tileMap[yTile-1][xTile+1] = 5; - //TileManager.tileMap[yTile-2][xTile] = 5; - //TileManager.tileMap[yTile-3][xTile] = 5; - } + hitEnemy(entity, graphicsContext, hitBox, dropChance, randomDropChance); } else if (playerDirection == EntityDirection.DOWN) { hitBox = new BoundingBox(mapPosX + playerWidth, mapPosY + playerHeight, attackWidth, attackRange); graphicsContext.strokeRect(mapPosX + playerWidth, mapPosY + playerHeight, attackWidth, attackRange); graphicsContext.drawImage(swordDown, mapPosX + 8, mapPosY + playerHeight, 32, 32); - if (hitBox.intersects(entity.getBoxCollider())) { - entity.gotHit(damage); - graphicsContext.strokeText("Hit", 10, 10); - - if (((TileManager.tileMap[xTile][yTile] == 3) && randomDropChance > dropChance)|| - ((TileManager.tileMap[xTile][yTile] == 1) && randomDropChance > dropChance)) - TileManager.tileMap[yTile-1][xTile+1] = 5; - //TileManager.tileMap[yTile-2][xTile] = 5; - //TileManager.tileMap[yTile-3][xTile] = 5; - } + hitEnemy(entity, graphicsContext, hitBox, dropChance, randomDropChance); } else if (playerDirection == EntityDirection.LEFT) { hitBox = new BoundingBox(mapPosX - attackWidth, mapPosY + ((double) playerHeight / 2), attackRange, attackWidth); graphicsContext.strokeRect(mapPosX - attackWidth, mapPosY + ((double) playerHeight / 2), attackRange, attackWidth); graphicsContext.drawImage(swordLeft, mapPosX - 8, mapPosY + 8, 32, 32); - if (hitBox.intersects(entity.getBoxCollider())) { - entity.gotHit(damage); - graphicsContext.strokeText("Hit", 10, 10); - - if (((TileManager.tileMap[xTile][yTile] == 3) && randomDropChance > dropChance)|| - ((TileManager.tileMap[xTile][yTile] == 1) && randomDropChance > dropChance)) - TileManager.tileMap[yTile-1][xTile+1] = 5; - //TileManager.tileMap[yTile-2][xTile] = 5; - //TileManager.tileMap[yTile-3][xTile] = 5; - } + hitEnemy(entity, graphicsContext, hitBox, dropChance, randomDropChance); } else { hitBox = new BoundingBox(mapPosX + playerWidth + attackWidth, mapPosY + ((double) playerHeight / 2), attackRange, attackWidth); graphicsContext.strokeRect(mapPosX + playerWidth + attackWidth, mapPosY + ((double) playerHeight / 2), attackRange, attackWidth); graphicsContext.drawImage(swordRight, mapPosX + playerWidth + 8, mapPosY + 8, 32, 32); - if (hitBox.intersects(entity.getBoxCollider())) { - entity.gotHit(damage); - graphicsContext.strokeText("Hit", 10, 10); - - if (((TileManager.tileMap[xTile][yTile] == 3) && randomDropChance > dropChance)|| - ((TileManager.tileMap[xTile][yTile] == 1) && randomDropChance > dropChance)) - TileManager.tileMap[yTile-1][xTile+1] = 5; - //TileManager.tileMap[yTile-2][xTile] = 5; - //TileManager.tileMap[yTile-3][xTile] = 5; - } + hitEnemy(entity, graphicsContext, hitBox, dropChance, randomDropChance); + } + } + } + + private void hitEnemy(IEntity entity, GraphicsContext graphicsContext, BoundingBox hitBox, double dropChance, double randomDropChance) { + if (hitBox.intersects(entity.getBoxCollider())) { + entity.gotHit(damage); + log.info("Hit enemy"); + + //spawning heart entity + if (randomDropChance > dropChance) { + int spawnCordX = mapPosX + 48; + int spawnCordY = mapPosY + 48; + + List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); + IEntity heart = EntityFactory.createGameplayObject(ObjectType.HEART, spawnCordX, spawnCordY, graphicsContext); + gameplayObjects.add(heart); + runtimeInfo.setGameplayObjects(gameplayObjects); + log.info("heart dropped"); } } } @@ -438,6 +514,7 @@ class Player implements IEntity { public void gotHit(int damageDone) { health -= damageDone; } + @Override public void healPlayer(int healthRegenerated) { int regeneratedHealth = health + healthRegenerated; @@ -475,4 +552,19 @@ class Player implements IEntity { return mapPosY; } + @Override + public ObjectType getOBJECT_TYPE() { + return null; + } + + @Override + public ObjectStatus getOBJECT_STATUS() { + return null; + } + + @Override + public void setObjectStatus(ObjectStatus objectStatus) { + + } + } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java index 7954688cdd580766c6b2d46209e8762d78d0ab76..d65fd87e2145d57c442b18513b405065a09247ec 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java @@ -19,36 +19,47 @@ public class InputHandler { return inputHandler; } - //Local Player/Player one controls - private boolean moveUp, moveDown, moveLeft, moveRight, attack; + //general input + private boolean isPause = false; + + //Local + Network Player one controls + private boolean moveUp, moveDown, moveLeft, moveRight, attack, bomb; //Local player two controls - private boolean sdMoveUp, sdMoveDown, sdMoveLeft, sdMoveRight, sdAttack; + private boolean sdMoveUp, sdMoveDown, sdMoveLeft, sdMoveRight, sdAttack, sdBomb; public void handleKeyPress(KeyEvent event) { KeyCode code = event.getCode(); switch (code) { + case ESCAPE: + isPause = !isPause; + log.debug("Pause button pressed"); + break; case W: moveUp = true; - log.debug("Player move up"); + log.debug("Player one move up"); break; case S: moveDown = true; - log.debug("Player move down"); + log.debug("Player one move down"); break; case A: moveLeft = true; - log.debug("Player move left"); + log.debug("Player one move left"); break; case D: moveRight = true; - log.debug("Player move right"); + log.debug("Player one move right"); break; case E: attack = true; - log.debug("Player attack"); + log.debug("Player one attack"); + break; + case Q: + bomb = true; break; + //inputs for second player case UP: sdMoveUp = true; break; @@ -64,6 +75,9 @@ public class InputHandler { case MINUS: sdAttack = true; break; + case CONTROL: + sdBomb = true; + break; } } @@ -86,6 +100,10 @@ public class InputHandler { case E: attack = false; break; + case Q: + bomb = false; + break; + //inputs for second player case UP: sdMoveUp = false; break; @@ -101,9 +119,16 @@ public class InputHandler { case MINUS: sdAttack = false; break; + case CONTROL: + sdBomb = false; + break; } } + public boolean isPause() { + return isPause; + } + public boolean isMoveUp() { return moveUp; } @@ -143,4 +168,12 @@ public class InputHandler { public boolean isSdAttack() { return sdAttack; } + + public boolean isBomb(){ + return bomb; + } + + public boolean isSdBomb(){ + return sdBomb; + } } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/Biom.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/Biom.java new file mode 100644 index 0000000000000000000000000000000000000000..ee6ca402f3fc3ec6bd1219c6a335578386e166b1 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/Biom.java @@ -0,0 +1,8 @@ +package de.hdm_stuttgart.battlearena.Model.Map; + +public enum Biom { + BOMBERMAN, + DARK_LANDS, + FORREST, + GRASS +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java index 27e558d93ab99c6b8354abb6cd7983c8b279cc0f..e015433b349d8bc05c0cf4be43059424155ec61a 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java @@ -21,7 +21,7 @@ public class TileManager { private final int verticalTileCount; public TileManager(GraphicsContext graphicsContext2D, int diffTileCount, - int horizontalTileCount, int verticalTileCount, String mapString) { + int horizontalTileCount, int verticalTileCount, String mapString, Biom biom) { this.graphicsContext2D = graphicsContext2D; this.horizontalTileCount = horizontalTileCount; this.verticalTileCount = verticalTileCount; @@ -29,26 +29,284 @@ public class TileManager { tileSet = new BackgroundTile[diffTileCount]; tileMap = new int[horizontalTileCount][verticalTileCount]; - createTiles(); + createTiles(biom); generateMap(mapString, horizontalTileCount, verticalTileCount); } - private void createTiles() { - try { - tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Grass01.png"))), SFXLoop.GRASS); - tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Grass02.png"))),SFXLoop.GRASS); - tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Grass04.png"))), SFXLoop.GRASS); - tileSet[3] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Stone01.png"))), SFXLoop.NONE); - tileSet[4] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/Stone02.png"))), SFXLoop.NONE); - tileSet[5] = TileFactory.createTile(TileType.WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/finalheart.png"))), SFXLoop.GRASS); + //index 0-9: WALKABLE + NON_DESTRUCTIBLE, index 10-19: NON_WALKABLE + NON_DESTRUCTIBLE, index 20-29: DESTRUCTIBLE + private void createTiles(Biom biom) { + if (biom == Biom.GRASS) { + try { + //Textures of walkable tiles + tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand00.png")))); + tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand01.png")))); + tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassPathGrassLand02.png")))); + tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand03.png")))); + tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + //Textures of solid tiles + non destructible + tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGrassLand00.png")))); + tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneEndLeftGrassLand01.png")))); + tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneEndRightGrassLand02.png")))); + tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneWindowGrassLand03.png")))); + tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGateGrassLand04.png")))); + tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGrassLand05.png")))); + tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand04.png")))); + tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + //Testures of destructible tiles + tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + } catch (Exception e) { + log.error(e); + } + }else if(biom == Biom.DARK_LANDS){ + try { + //Textures of walkable tiles + tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand00.png")))); + tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand01.png")))); + tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassPathDarkLand02.png")))); + tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand03.png")))); + tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + //Textures of solid tiles + tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneDarkLand00.png")))); + tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneEndLeftDarkLand01.png")))); + tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneEndRightDarkLand02.png")))); + tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneWindowDarkLand03.png")))); + tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneGateDarkLand04.png")))); + tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/NoTexture.png")))); + tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/NoTexture.png")))); + tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + //Testures of destructible tiles + tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); } catch (Exception e) { - log.error(e); + log.error(e); + } + }else if(biom == Biom.BOMBERMAN){ + try { + //Textures of walkable tiles + tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand00.png")))); + tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand01.png")))); + tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand03.png")))); + tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand04.png")))); + tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + //Textures of solid tiles + tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand00.png")))); + tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand01.png")))); + tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + //Testures of destructible tiles + tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/box.png")))); + tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + } catch (Exception e) { + log.error(e); + } + }else if(biom == Biom.FORREST){ + try { + //Textures of walkable tiles + tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand00.png")))); + tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand01.png")))); + tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassPathWoodLand02.png")))); + tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand03.png")))); + tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + //Textures of solid tiles + tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + //Testures of destructible tiles + tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + } catch (Exception e) { + log.error(e); + } } } diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 82f13f3acc44df73c7402059105f847d4cae3f98..c00c6404a3761939513370db617f959fe9a36d3a 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -16,6 +16,7 @@ module gui { opens de.hdm_stuttgart.battlearena to javafx.fxml; opens de.hdm_stuttgart.battlearena.Model.Sound to javafx.media; opens de.hdm_stuttgart.battlearena.Controller.Utilities to javafx.fxml; + opens de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs to com.google.gson; exports de.hdm_stuttgart.battlearena.Main; exports de.hdm_stuttgart.battlearena.Controller; @@ -23,5 +24,6 @@ module gui { exports de.hdm_stuttgart.battlearena.Model.Inputs; exports de.hdm_stuttgart.battlearena.Model.Map; exports de.hdm_stuttgart.battlearena.Controller.Utilities; - + exports de.hdm_stuttgart.battlearena.Model.Multiplayer; + exports de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects to javafx.fxml; } \ No newline at end of file diff --git a/src/main/resources/fonts/AmaticSC-Bold.ttf b/src/main/resources/fonts/AmaticSC-Bold.ttf new file mode 100644 index 0000000000000000000000000000000000000000..63cd7ae5be0bce367f8c0aa0e30702d065680923 Binary files /dev/null and b/src/main/resources/fonts/AmaticSC-Bold.ttf differ diff --git a/src/main/resources/fonts/AmaticSC-Regular.ttf b/src/main/resources/fonts/AmaticSC-Regular.ttf new file mode 100644 index 0000000000000000000000000000000000000000..b860368bec2246d3c268c075167c9d7333d454d0 Binary files /dev/null and b/src/main/resources/fonts/AmaticSC-Regular.ttf differ diff --git a/src/main/resources/fonts/Arthemis-mLA22.ttf b/src/main/resources/fonts/Arthemis-mLA22.ttf new file mode 100644 index 0000000000000000000000000000000000000000..165d0d21fda6832a71ff683dcfafe042a5d2d016 Binary files /dev/null and b/src/main/resources/fonts/Arthemis-mLA22.ttf differ diff --git a/src/main/resources/fonts/ShadowsIntoLight-Regular.ttf b/src/main/resources/fonts/ShadowsIntoLight-Regular.ttf new file mode 100644 index 0000000000000000000000000000000000000000..d20640513b188b6627c3b11383721eba624f1b26 Binary files /dev/null and b/src/main/resources/fonts/ShadowsIntoLight-Regular.ttf differ diff --git a/src/main/resources/fxml/CreateAccount.fxml b/src/main/resources/fxml/CreateAccount.fxml new file mode 100644 index 0000000000000000000000000000000000000000..b75267745fd38367a38728324cf4b7a0aefa720c --- /dev/null +++ b/src/main/resources/fxml/CreateAccount.fxml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.RadioButton?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.control.ToggleGroup?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.CreateAccountController"> + <children> + <Pane VBox.vgrow="ALWAYS" /> + <VBox alignment="CENTER" VBox.vgrow="ALWAYS"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Tracking statistics:" /> + <HBox alignment="CENTER" spacing="30.0" VBox.vgrow="ALWAYS"> + <children> + <RadioButton fx:id="local" mnemonicParsing="false" text="Local"> + <toggleGroup> + <ToggleGroup fx:id="statistics" /> + </toggleGroup> + </RadioButton> + <RadioButton mnemonicParsing="false" text="Online" toggleGroup="$statistics" /> + </children> + </HBox> + </children> + </VBox> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Player Name:" /> + <TextField fx:id="playerName" alignment="CENTER" /> + <Label fx:id="passwordLabel" text="Password:" /> + <TextField fx:id="password" alignment="CENTER" /> + <Label fx:id="errorMessage" /> + <Button mnemonicParsing="false" onAction="#create" text="Create" /> + <Button mnemonicParsing="false" onAction="#back" text="Back" /> + <Pane VBox.vgrow="ALWAYS" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/GameScene.fxml b/src/main/resources/fxml/GameScene.fxml index f046db58280a8ea339f035b1879ac8e6e73b8115..6d70dc666e6853e4ab00cbc6f775eed560ad16dc 100644 --- a/src/main/resources/fxml/GameScene.fxml +++ b/src/main/resources/fxml/GameScene.fxml @@ -1,15 +1,84 @@ <?xml version="1.0" encoding="UTF-8"?> +<?import javafx.geometry.Insets?> <?import javafx.scene.canvas.Canvas?> -<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.Slider?> +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.StackPane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.shape.Rectangle?> -<AnchorPane prefHeight="864.0" prefWidth="864.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController"> - <children> - <StackPane prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> +<BorderPane fx:id="gameScene" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController"> + <center> + <StackPane fx:id="stackPane" prefHeight="400.0" prefWidth="600.0" BorderPane.alignment="CENTER"> <children> <Canvas fx:id="canvas2D" height="864.0" width="864.0" /> </children> + <BorderPane.margin> + <Insets /> + </BorderPane.margin> </StackPane> - </children> -</AnchorPane> + </center> + <top> + <VBox BorderPane.alignment="CENTER"> + <children> + <Pane prefHeight="50.0" VBox.vgrow="ALWAYS" /> + <HBox alignment="CENTER" spacing="30.0"> + <children> + <HBox alignment="CENTER_RIGHT" fillHeight="false" spacing="10.0"> + <children> + <Label text="Player HP" /> + <Pane fx:id="playerPane" nodeOrientation="RIGHT_TO_LEFT"> + <children> + <Rectangle fx:id="playerHealth" arcHeight="5.0" arcWidth="5.0" fill="#c92c1a" height="50.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="900.0" /> + </children> + </Pane> + <Label fx:id="playerHp" alignment="CENTER_RIGHT" /> + </children> + </HBox> + <HBox alignment="CENTER_LEFT" fillHeight="false" spacing="10.0"> + <children> + <Label fx:id="enemyHp" /> + <Pane fx:id="enemyPane" HBox.hgrow="ALWAYS"> + <children> + <Rectangle fx:id="enemyHealth" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="50.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="900.0" /> + </children> + </Pane> + <Label text="Enemy HP" /> + </children> + </HBox> + </children> + </HBox> + </children> + </VBox> + </top> + <left> + <VBox alignment="CENTER" prefHeight="200.0" prefWidth="300.0" BorderPane.alignment="CENTER"> + <children> + <Slider fx:id="slider" orientation="VERTICAL" value="100.0" /> + <Slider fx:id="slider2" orientation="VERTICAL" value="100.0" /> + </children> + </VBox> + </left> + <right> + <HBox BorderPane.alignment="CENTER"> + <children> + <VBox prefHeight="200.0"> + <children> + <Pane VBox.vgrow="ALWAYS" /> + <Label text="Time:" /> + <Label fx:id="time" text="00:30" /> + <Pane VBox.vgrow="ALWAYS" /> + <Label text="Round:" /> + <Label fx:id="round" text="1/3" /> + <Pane VBox.vgrow="ALWAYS" /> + </children> + </VBox> + <Pane prefWidth="200.0" HBox.hgrow="ALWAYS" /> + </children> + </HBox> + </right> +</BorderPane> diff --git a/src/main/resources/fxml/LoadingScreen.fxml b/src/main/resources/fxml/LoadingScreen.fxml new file mode 100644 index 0000000000000000000000000000000000000000..4e242f48920d3c22e5351886ead0da65eaa80b44 --- /dev/null +++ b/src/main/resources/fxml/LoadingScreen.fxml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.image.Image?> +<?import javafx.scene.image.ImageView?> +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.shape.Rectangle?> +<?import javafx.scene.text.Font?> + +<BorderPane id="loadingScreen" fx:id="parent" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.LoadingScreenController"> + <bottom> + <HBox alignment="BOTTOM_CENTER" BorderPane.alignment="BOTTOM_CENTER"> + <children> + <Rectangle arcHeight="5.0" arcWidth="5.0" fill="#ffffff00" height="180.0" stroke="TRANSPARENT" strokeType="INSIDE" width="180.0" HBox.hgrow="NEVER"> + <HBox.margin> + <Insets bottom="50.0" left="50.0" right="50.0" /> + </HBox.margin> + </Rectangle> + <Pane HBox.hgrow="ALWAYS" /> + <Label fx:id="tips" alignment="CENTER" contentDisplay="CENTER" text="If you see this, then something went wrong lmao" textFill="WHITE" wrapText="true"> + <font> + <Font name="Helvetica Neue LT Com 53 Extended" size="40.0" /> + </font> + <HBox.margin> + <Insets bottom="50.0" /> + </HBox.margin> + </Label> + <Pane HBox.hgrow="ALWAYS" /> + <ImageView fx:id="throbber" fitHeight="180.0" fitWidth="180.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/images/throbber.gif" /> + </image> + <HBox.margin> + <Insets bottom="50.0" left="50.0" right="50.0" /> + </HBox.margin> + </ImageView> + </children> + <BorderPane.margin> + <Insets /> + </BorderPane.margin> + </HBox> + </bottom> + <center> + <ImageView fx:id="logo" fitHeight="800.0" fitWidth="900.0" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER"> + <image> + <Image url="@../textures/images/logo_transparent.png" /> + </image> + </ImageView> + </center> +</BorderPane> diff --git a/src/main/resources/fxml/Login.fxml b/src/main/resources/fxml/Login.fxml new file mode 100644 index 0000000000000000000000000000000000000000..a63c7c127ff2c30d0499ffc963851e061324bf58 --- /dev/null +++ b/src/main/resources/fxml/Login.fxml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.LoginController"> + <children> + <Pane VBox.vgrow="ALWAYS" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Login with existing online account" /> + <Pane VBox.vgrow="ALWAYS" /> + <Pane VBox.vgrow="ALWAYS" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Player Name:" /> + <TextField fx:id="playerName" alignment="CENTER" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Password:" /> + <TextField fx:id="password" alignment="CENTER" /> + <Label fx:id="errorMessage" /> + <Button mnemonicParsing="false" onAction="#login" text="Login" /> + <Button mnemonicParsing="false" onAction="#back" text="Back" /> + <Pane VBox.vgrow="ALWAYS" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/Placeholder.fxml b/src/main/resources/fxml/Placeholder.fxml new file mode 100644 index 0000000000000000000000000000000000000000..5b08cde3dfdf168d0e09cc1f005c3f62ac8e09c5 --- /dev/null +++ b/src/main/resources/fxml/Placeholder.fxml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.layout.StackPane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.media.MediaView?> +<?import javafx.scene.text.Text?> + +<BorderPane fx:id="parent" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PlaceholderController"> + <center> + <StackPane BorderPane.alignment="CENTER"> + <children> + <MediaView fx:id="mediaView" fitHeight="200.0" fitWidth="200.0" /> + <VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" spacing="10.0"> + <children> + <Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="WELCOME!" /> + <Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="This page is still under construction" /> + <Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="please have some patience" /> + <Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Thank you" /> + <Button fx:id="button" mnemonicParsing="false" text="Get me out of here" /> + </children> + </VBox> + </children> + </StackPane> + </center> +</BorderPane> diff --git a/src/main/resources/fxml/PlayerCreateScene.fxml b/src/main/resources/fxml/PlayerCreateScene.fxml index 5200c6495466b6bf62772664a6f3a093ac2f5453..9a7e5e347bd49fc7a87467f5700922cbf3fdb937 100644 --- a/src/main/resources/fxml/PlayerCreateScene.fxml +++ b/src/main/resources/fxml/PlayerCreateScene.fxml @@ -1,27 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Button?> -<?import javafx.scene.layout.BorderPane?> -<?import javafx.scene.layout.StackPane?> +<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.VBox?> -<?import javafx.scene.media.MediaView?> -<?import javafx.scene.text.Text?> -<BorderPane fx:id="parent" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PlayerCreateController"> - <center> - <StackPane BorderPane.alignment="CENTER"> - <children> - <MediaView fx:id="mediaView" fitHeight="200.0" fitWidth="200.0" /> - <VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" spacing="10.0"> - <children> - <Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="WELCOME!" /> - <Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="This page is still under construction" /> - <Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="please have some patience" /> - <Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Thank you" /> - <Button fx:id="button" mnemonicParsing="false" text="Get me out of here" /> - </children> - </VBox> - </children> - </StackPane> - </center> -</BorderPane> + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="50.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PlayerCreateController"> + <children> + <Pane prefHeight="200.0" prefWidth="200.0" /> + <Button mnemonicParsing="false" onAction="#createScene" text="Create Account" /> + <Button mnemonicParsing="false" onAction="#loginScene" text="Login" /> + <Pane prefHeight="200.0" prefWidth="200.0" /> + <Button mnemonicParsing="false" onAction="#exit" text="Exit" /> + <Pane prefHeight="200.0" prefWidth="200.0" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/Settings.fxml b/src/main/resources/fxml/Settings.fxml index 7b8950fc2664c2e1e041ce2d05b7b46986f01d64..3f84b3167228690e174a053e4d5ba4128fc44e72 100644 --- a/src/main/resources/fxml/Settings.fxml +++ b/src/main/resources/fxml/Settings.fxml @@ -28,6 +28,7 @@ </VBox> </children> </HBox> + <Button mnemonicParsing="false" onAction="#account" text="Account" /> <Button mnemonicParsing="false" onAction="#creditScene" text="Credits" /> <Button mnemonicParsing="false" onAction="#backButton" text="Back" /> </children> diff --git a/src/main/resources/fxml/Statistics.fxml b/src/main/resources/fxml/Statistics.fxml index 6c98b4e5e5aa7e8efd880b6945b8c7091aa04d32..42b8646af9788053e25149e8a04a9d3d8f0bfb1f 100644 --- a/src/main/resources/fxml/Statistics.fxml +++ b/src/main/resources/fxml/Statistics.fxml @@ -7,11 +7,11 @@ <?import javafx.scene.layout.VBox?> <?import javafx.scene.text.Text?> -<VBox fx:id="parent" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="50.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.StatisticsController"> +<VBox fx:id="parent" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.StatisticsController"> <children> - <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="30.0" VBox.vgrow="ALWAYS"> + <HBox alignment="CENTER" prefHeight="411.0" prefWidth="677.0" spacing="30.0" VBox.vgrow="ALWAYS"> <children> - <VBox alignment="CENTER_RIGHT" prefHeight="200.0" prefWidth="100.0" spacing="10.0" HBox.hgrow="ALWAYS"> + <VBox alignment="CENTER_RIGHT" spacing="10.0" HBox.hgrow="ALWAYS"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Kills:" /> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Deaths:" /> @@ -21,7 +21,7 @@ <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Ingame time:" /> </children> </VBox> - <VBox alignment="CENTER_LEFT" prefHeight="200.0" prefWidth="100.0" spacing="10.0" HBox.hgrow="ALWAYS"> + <VBox alignment="CENTER_LEFT" spacing="10.0" HBox.hgrow="ALWAYS"> <children> <Text fx:id="kills" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> <Text fx:id="deaths" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" /> @@ -38,11 +38,11 @@ <children> <PieChart fx:id="kd" minHeight="-Infinity" minWidth="-Infinity" VBox.vgrow="ALWAYS"> <VBox.margin> - <Insets bottom="-200.0" /> + <Insets bottom="-200.0" top="-250.0" /> </VBox.margin></PieChart> <PieChart fx:id="wl" minHeight="-Infinity" minWidth="-Infinity" VBox.vgrow="ALWAYS"> <VBox.margin> - <Insets top="-40.0" /> + <Insets bottom="-250.0" top="-40.0" /> </VBox.margin></PieChart> </children> </VBox> diff --git a/src/main/resources/maps/coreMaps.json b/src/main/resources/maps/coreMaps.json index ba63b040f5afc06edf39a660e0cd815b3bb7963b..a4431c417df1d21599556d45b20a87e11f757254 100644 --- a/src/main/resources/maps/coreMaps.json +++ b/src/main/resources/maps/coreMaps.json @@ -1,16 +1,37 @@ [ { - "mapID": "09a02b54d05b5b7ebc29a4383ca12d3dda846b72", - "mapName": "Arena1", + "mapID": "b8f5da1a3619a3585978a6d9c8c683c3210193e6", + "mapName": "Ruins", "mapWidth": 18, "mapHeight": 18, - "mapData": "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12" + "mapData": "11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12" }, { - "mapID": "0ab15557ab6dc4be60dfe6a9b0288bac3036bd97", - "mapName": "Arena2", + "mapID": "6b9ff964a4afc821672645d5c2bb8fb2b0dcb2e8", + "mapName": "Outpost", "mapWidth": 18, "mapHeight": 18, - "mapData": "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12" + "mapData": "16 16 16 16 16 16 16 16 16 16 10 12 13 11 12 14 11 12 16 0 16 0 0 1 0 0 0 0 1 0 0 1 0 2 0 12 16 0 0 0 0 0 16 16 0 0 15 3 0 0 0 2 1 12 16 0 0 2 16 0 0 1 16 0 15 15 3 3 0 2 0 12 11 10 12 2 11 10 12 0 16 0 0 15 15 3 1 2 0 12 11 0 0 2 0 0 12 0 0 16 0 0 15 3 0 2 0 12 11 0 10 2 10 0 12 0 0 16 0 0 15 15 12 2 11 12 11 0 10 2 10 0 12 0 0 0 0 0 0 0 0 2 0 16 11 0 1 2 10 0 12 16 0 0 11 10 0 10 12 2 0 16 11 0 10 2 10 0 1 0 0 16 11 3 0 0 12 0 1 16 11 0 10 2 10 0 12 0 16 0 11 0 0 1 12 2 0 16 11 0 10 2 10 0 12 0 0 0 11 0 0 0 12 2 0 16 11 0 0 1 0 0 12 16 0 0 11 0 0 0 12 0 0 16 11 10 12 2 11 10 12 0 16 0 11 0 10 10 12 2 0 16 16 0 0 2 16 0 0 0 0 0 11 0 0 3 12 0 11 12 16 0 16 16 16 0 0 16 0 0 1 0 0 0 0 2 0 12 16 0 0 0 0 0 0 0 0 0 11 0 0 1 0 2 0 12 16 16 16 16 16 16 16 16 16 16 11 12 13 11 12 14 11 12" + }, + { + "mapID": "ac7c6f0fcaaf730804925aae280cce26f0da481e", + "mapName": "AsymmetricBomberman", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 1 20 1 20 1 20 1 20 1 20 1 20 1 1 10 10 1 1 20 10 20 10 20 10 20 10 20 10 20 10 20 1 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 1 10 10 1 1 20 10 20 10 20 10 20 10 20 10 20 10 1 1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10" + }, + { + "mapID": "ff52df212fcd29f16db9d7aa11d305cad9063c35", + "mapName": "SymmetricBomberman", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 20 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 10 10 1 20 1 20 1 20 1 20 1 20 20 1 20 20 1 1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10" + }, + { + "mapID": "8bf04771fc5eea669f8dda582fe8d8b159f15009", + "mapName": "SymmetricBombermanFullBoxed", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 10 10 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 10 10 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10" } ] \ No newline at end of file diff --git a/src/main/resources/player/appSettings.json b/src/main/resources/player/appSettings.json index d505d3363587cdf48cd7f98904e0247ffa321598..f7d371619fa1db8dd4701e6607908135293b820c 100644 --- a/src/main/resources/player/appSettings.json +++ b/src/main/resources/player/appSettings.json @@ -1,4 +1,4 @@ { - "sfxVolume": 52, + "sfxVolume": 100, "musicVolume": 0 } \ No newline at end of file diff --git a/src/main/resources/player/playerStatsLocal.json b/src/main/resources/player/playerStatsLocal.json index e51de779c74b6c93fe347b5bf263508c23fff2c9..4db3d0788fb3ff0fe8d593e5baed84279916821b 100644 --- a/src/main/resources/player/playerStatsLocal.json +++ b/src/main/resources/player/playerStatsLocal.json @@ -1,8 +1,8 @@ { - "gamesLost": 5, - "gamesWon": 9, - "kills": 30, - "deaths": 20, - "blocksDestroyed": 200, - "gameTime": 3966480 + "gamesLost": 0, + "gamesWon": 0, + "kills": 0, + "deaths": 0, + "blocksDestroyed": 0, + "gameTime": 0 } \ No newline at end of file diff --git a/src/main/resources/styles/style.css b/src/main/resources/styles/style.css index e676c8daadf56536c73d3bf8dd515a7c5a7533cd..c6d0d1c3446bc10e5bdcf9c19cc7c6d94fb33bce 100644 --- a/src/main/resources/styles/style.css +++ b/src/main/resources/styles/style.css @@ -8,18 +8,44 @@ } .root { - -fx-font-family: "Starship Shadow"; + -fx-font-family: "Arthemis"; -fx-text-fill: white; -fx-background-color: black; + -fx-font-size: 50 px; +} + +#tips { + -fx-font-family: "Amatic SC Bold"; + -fx-font-size: 40 px; +} + +#loadingScreen { + -fx-background-color: radial-gradient(focus-distance 0% , center 50% 50% , radius 45% , #a31c31, #542b27); } +.text-field { + -fx-background-color: transparent; + -fx-text-fill: black; + -fx-border-color: black; + -fx-border-width: 0 0 2 0; + -fx-prompt-text-fill: rgba(0, 0, 0, 0.5); + -fx-font-family: "Shadows Into Light"; +} + + #mainMenu{ -fx-background-image: url("../textures/images/background.png"); -fx-background-size: cover; } #gameTitle { - -fx-font-size: 100; + -fx-font-size: 100 px; + -fx-font-family: "Starship Shadow"; +} + +#gameScene { + -fx-background-image: url("../textures/images/game_scene_backgorund.jpg"); + -fx-background-size: cover; } .button { @@ -30,7 +56,7 @@ #btnLeft { -fx-skin: none; - -fx-text-fill: white; + -fx-text-fill: #7a7a7a; } .accordion { diff --git a/src/main/resources/textures/images/game_scene_backgorund.jpg b/src/main/resources/textures/images/game_scene_backgorund.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4582a8a16813744f793a6f78424321548071ca01 Binary files /dev/null and b/src/main/resources/textures/images/game_scene_backgorund.jpg differ diff --git a/src/main/resources/textures/images/logo_transparent.png b/src/main/resources/textures/images/logo_transparent.png new file mode 100644 index 0000000000000000000000000000000000000000..4aa46908f9c28d66b837bfc3d073aab080759127 Binary files /dev/null and b/src/main/resources/textures/images/logo_transparent.png differ diff --git a/src/main/resources/textures/images/logo_transparent_alt.png b/src/main/resources/textures/images/logo_transparent_alt.png new file mode 100644 index 0000000000000000000000000000000000000000..817ba0a2f3103c351277b8598614836c377ce058 Binary files /dev/null and b/src/main/resources/textures/images/logo_transparent_alt.png differ diff --git a/src/main/resources/textures/images/test.jpg b/src/main/resources/textures/images/test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0618af6c2edbd72fc986c19759f2a3c102dabcc5 Binary files /dev/null and b/src/main/resources/textures/images/test.jpg differ diff --git a/src/main/resources/textures/images/throbber.gif b/src/main/resources/textures/images/throbber.gif new file mode 100644 index 0000000000000000000000000000000000000000..45caf1ef603429f181feebcc5505f4b01f512728 Binary files /dev/null and b/src/main/resources/textures/images/throbber.gif differ diff --git a/src/main/resources/textures/map/NoTexture.png b/src/main/resources/textures/map/NoTexture.png new file mode 100644 index 0000000000000000000000000000000000000000..97d81e90559b742fa2098131248ce24bc7675069 Binary files /dev/null and b/src/main/resources/textures/map/NoTexture.png differ diff --git a/src/main/resources/textures/map/bomberman/building/StoneBombLand00.png b/src/main/resources/textures/map/bomberman/building/StoneBombLand00.png new file mode 100644 index 0000000000000000000000000000000000000000..46ca4543d42aa78de8ce196efc7df1142b9e45b2 Binary files /dev/null and b/src/main/resources/textures/map/bomberman/building/StoneBombLand00.png differ diff --git a/src/main/resources/textures/map/bomberman/building/StoneBombLand01.png b/src/main/resources/textures/map/bomberman/building/StoneBombLand01.png new file mode 100644 index 0000000000000000000000000000000000000000..1c61f1fafb63ae962d0ebfe751c57bce38409eb4 Binary files /dev/null and b/src/main/resources/textures/map/bomberman/building/StoneBombLand01.png differ diff --git a/src/main/resources/textures/map/bomberman/building/box.png b/src/main/resources/textures/map/bomberman/building/box.png new file mode 100644 index 0000000000000000000000000000000000000000..6c6cf965c67c4e8008c453bd87f27542d9ebe8a2 Binary files /dev/null and b/src/main/resources/textures/map/bomberman/building/box.png differ diff --git a/src/main/resources/textures/map/bomberman/ground/GrassBombLand00.png b/src/main/resources/textures/map/bomberman/ground/GrassBombLand00.png new file mode 100644 index 0000000000000000000000000000000000000000..df8c715b668007d41adc80069353521fbf6c6549 Binary files /dev/null and b/src/main/resources/textures/map/bomberman/ground/GrassBombLand00.png differ diff --git a/src/main/resources/textures/map/bomberman/ground/GrassBombLand01.png b/src/main/resources/textures/map/bomberman/ground/GrassBombLand01.png new file mode 100644 index 0000000000000000000000000000000000000000..0ea16c187324435fb1b410ffb1fbe221474f210e Binary files /dev/null and b/src/main/resources/textures/map/bomberman/ground/GrassBombLand01.png differ diff --git a/src/main/resources/textures/map/bomberman/ground/GrassBombLand03.png b/src/main/resources/textures/map/bomberman/ground/GrassBombLand03.png new file mode 100644 index 0000000000000000000000000000000000000000..235ee9314e9402c61ef3400096abde0a07ea8e39 Binary files /dev/null and b/src/main/resources/textures/map/bomberman/ground/GrassBombLand03.png differ diff --git a/src/main/resources/textures/map/bomberman/ground/GrassBombLand04.png b/src/main/resources/textures/map/bomberman/ground/GrassBombLand04.png new file mode 100644 index 0000000000000000000000000000000000000000..9985b27f06a1b46b4ae4f8eba609fd927d7bf09e Binary files /dev/null and b/src/main/resources/textures/map/bomberman/ground/GrassBombLand04.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/building/StoneDarkLand00.png b/src/main/resources/textures/map/dark_lands_biom/building/StoneDarkLand00.png new file mode 100644 index 0000000000000000000000000000000000000000..7141744f6029a09af2e65b7af0f5f766042ca75b Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/building/StoneDarkLand00.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/building/StoneEndLeftDarkLand01.png b/src/main/resources/textures/map/dark_lands_biom/building/StoneEndLeftDarkLand01.png new file mode 100644 index 0000000000000000000000000000000000000000..b71227d4148111cc979cfa08e68deac7236530b2 Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/building/StoneEndLeftDarkLand01.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/building/StoneEndRightDarkLand02.png b/src/main/resources/textures/map/dark_lands_biom/building/StoneEndRightDarkLand02.png new file mode 100644 index 0000000000000000000000000000000000000000..7dfab3fb95f3017893cc077b665dfc96a4736bda Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/building/StoneEndRightDarkLand02.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/building/StoneGateDarkLand04.png b/src/main/resources/textures/map/dark_lands_biom/building/StoneGateDarkLand04.png new file mode 100644 index 0000000000000000000000000000000000000000..ee9984315fc1f60ff9606ea8c2ca1fd89005887e Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/building/StoneGateDarkLand04.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/building/StoneWindowDarkLand03.png b/src/main/resources/textures/map/dark_lands_biom/building/StoneWindowDarkLand03.png new file mode 100644 index 0000000000000000000000000000000000000000..ca334756581f2cc2a55fbacc90f76d9b264b3bec Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/building/StoneWindowDarkLand03.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand00.png b/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand00.png new file mode 100644 index 0000000000000000000000000000000000000000..1d2c1ca9eaab73d2d221f59f1264e68f1ab354b7 Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand00.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand01.png b/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand01.png new file mode 100644 index 0000000000000000000000000000000000000000..2699381fb84e425ae3b20b119ed4b12a5cfc4d71 Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand01.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand03.png b/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand03.png new file mode 100644 index 0000000000000000000000000000000000000000..ff59e764b05b97b000573b245368329779b96823 Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/ground/GrassDarkLand03.png differ diff --git a/src/main/resources/textures/map/dark_lands_biom/ground/GrassPathDarkLand02.png b/src/main/resources/textures/map/dark_lands_biom/ground/GrassPathDarkLand02.png new file mode 100644 index 0000000000000000000000000000000000000000..75b3a83c783fcb392b405d5c42879db3dfecc72c Binary files /dev/null and b/src/main/resources/textures/map/dark_lands_biom/ground/GrassPathDarkLand02.png differ diff --git a/src/main/resources/textures/map/finalheart.png b/src/main/resources/textures/map/finalheart.png deleted file mode 100644 index b861b145ceb949abdd7222a2679fe8e10756340f..0000000000000000000000000000000000000000 Binary files a/src/main/resources/textures/map/finalheart.png and /dev/null differ diff --git a/src/main/resources/textures/map/forrest_biom/ground/GrassPathWoodLand02.png b/src/main/resources/textures/map/forrest_biom/ground/GrassPathWoodLand02.png new file mode 100644 index 0000000000000000000000000000000000000000..ff9e2ae306770e15731903d53865bc382703e9d6 Binary files /dev/null and b/src/main/resources/textures/map/forrest_biom/ground/GrassPathWoodLand02.png differ diff --git a/src/main/resources/textures/map/Grass01.png b/src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand00.png similarity index 84% rename from src/main/resources/textures/map/Grass01.png rename to src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand00.png index e835d4676d2f80105626ece4d99b485a30b289fe..48584467f86445ad1f78925eb9f9cf219d1a46c4 100644 Binary files a/src/main/resources/textures/map/Grass01.png and b/src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand00.png differ diff --git a/src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand01.png b/src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand01.png new file mode 100644 index 0000000000000000000000000000000000000000..5d13544cd45bf4968df0444b75d688e198ceb805 Binary files /dev/null and b/src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand01.png differ diff --git a/src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand03.png b/src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand03.png new file mode 100644 index 0000000000000000000000000000000000000000..aae4f73a84f5c03f1e448110853ccb0e5e3d6680 Binary files /dev/null and b/src/main/resources/textures/map/forrest_biom/ground/GrassWoodLand03.png differ diff --git a/src/main/resources/textures/map/Stone02.png b/src/main/resources/textures/map/grass_biom/building/StoneEndLeftGrassLand01.png similarity index 85% rename from src/main/resources/textures/map/Stone02.png rename to src/main/resources/textures/map/grass_biom/building/StoneEndLeftGrassLand01.png index 2ac41bee77062960aa2d8cfc921f66e45de629ba..afc98f647c69ff41538c540ad5f81dbddc9df2fd 100644 Binary files a/src/main/resources/textures/map/Stone02.png and b/src/main/resources/textures/map/grass_biom/building/StoneEndLeftGrassLand01.png differ diff --git a/src/main/resources/textures/map/grass_biom/building/StoneEndRightGrassLand02.png b/src/main/resources/textures/map/grass_biom/building/StoneEndRightGrassLand02.png new file mode 100644 index 0000000000000000000000000000000000000000..41fdeb5b6fb3096837434f98e0b779ec548779d2 Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/building/StoneEndRightGrassLand02.png differ diff --git a/src/main/resources/textures/map/grass_biom/building/StoneGateGrassLand04.png b/src/main/resources/textures/map/grass_biom/building/StoneGateGrassLand04.png new file mode 100644 index 0000000000000000000000000000000000000000..ee4e9538c461e7cd81843211bedfa1459863f098 Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/building/StoneGateGrassLand04.png differ diff --git a/src/main/resources/textures/map/Stone01.png b/src/main/resources/textures/map/grass_biom/building/StoneGrassLand00.png similarity index 85% rename from src/main/resources/textures/map/Stone01.png rename to src/main/resources/textures/map/grass_biom/building/StoneGrassLand00.png index b6cf13f66633060803264739b889f64c32877a0e..e31b2ac22af757240fd1a2d1fdf155161886866f 100644 Binary files a/src/main/resources/textures/map/Stone01.png and b/src/main/resources/textures/map/grass_biom/building/StoneGrassLand00.png differ diff --git a/src/main/resources/textures/map/grass_biom/building/StoneGrassLand05.png b/src/main/resources/textures/map/grass_biom/building/StoneGrassLand05.png new file mode 100644 index 0000000000000000000000000000000000000000..1c93eef9343e85ccaf5f27ee57acf8af255530cd Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/building/StoneGrassLand05.png differ diff --git a/src/main/resources/textures/map/grass_biom/building/StoneWindowGrassLand03.png b/src/main/resources/textures/map/grass_biom/building/StoneWindowGrassLand03.png new file mode 100644 index 0000000000000000000000000000000000000000..ae7119eeb0a21560093f3dc8fcb52a33bdb40708 Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/building/StoneWindowGrassLand03.png differ diff --git a/src/main/resources/textures/map/Grass02.png b/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand00.png similarity index 84% rename from src/main/resources/textures/map/Grass02.png rename to src/main/resources/textures/map/grass_biom/ground/GrassGrassLand00.png index 144fad81f75b681454b58768081394cb40aaeead..42f20fb577ca233a64f9e570ca2c448a125ce2cd 100644 Binary files a/src/main/resources/textures/map/Grass02.png and b/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand00.png differ diff --git a/src/main/resources/textures/map/Grass04.png b/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand01.png similarity index 63% rename from src/main/resources/textures/map/Grass04.png rename to src/main/resources/textures/map/grass_biom/ground/GrassGrassLand01.png index 4ce012b5eac6c41488efe96c5f66eb43c28c98ce..c0f799dfc6e5857b5cefa31c3b3732d4f1a84770 100644 Binary files a/src/main/resources/textures/map/Grass04.png and b/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand01.png differ diff --git a/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand03.png b/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand03.png new file mode 100644 index 0000000000000000000000000000000000000000..abdfbc8114e9e5a233757bf77a764fc1e753365b Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand03.png differ diff --git a/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand04.png b/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand04.png new file mode 100644 index 0000000000000000000000000000000000000000..2ea95c178f078c9adceba8de2a8d1af544200ca5 Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/ground/GrassGrassLand04.png differ diff --git a/src/main/resources/textures/map/grass_biom/ground/GrassPathGrassLand02.png b/src/main/resources/textures/map/grass_biom/ground/GrassPathGrassLand02.png new file mode 100644 index 0000000000000000000000000000000000000000..7a8050dfd2e9188c0c72d7000ae205c55864e6d8 Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/ground/GrassPathGrassLand02.png differ diff --git a/src/main/resources/textures/objects/big_bomb/bigbomb.png b/src/main/resources/textures/objects/big_bomb/bigbomb.png new file mode 100644 index 0000000000000000000000000000000000000000..27a153a8731d525576a01437499f4ade60b4d5fe Binary files /dev/null and b/src/main/resources/textures/objects/big_bomb/bigbomb.png differ diff --git a/src/main/resources/textures/objects/bomb/bomb.png b/src/main/resources/textures/objects/bomb/bomb.png new file mode 100644 index 0000000000000000000000000000000000000000..6f29b3f6124a917afe8492f2e318d15dd93ff7c7 Binary files /dev/null and b/src/main/resources/textures/objects/bomb/bomb.png differ diff --git a/src/main/resources/textures/objects/heal/heart.png b/src/main/resources/textures/objects/heal/heart.png new file mode 100644 index 0000000000000000000000000000000000000000..2eea9b2c91b68cb55d98fad6118da284e9d874a4 Binary files /dev/null and b/src/main/resources/textures/objects/heal/heart.png differ diff --git a/src/main/resources/textures/objects/vfx/bigexplosion.png b/src/main/resources/textures/objects/vfx/bigexplosion.png new file mode 100644 index 0000000000000000000000000000000000000000..f1e10d9d22cc8e0147dc55f8a9c6e2125f75bfd5 Binary files /dev/null and b/src/main/resources/textures/objects/vfx/bigexplosion.png differ diff --git a/src/main/resources/textures/objects/vfx/middleexplosion.png b/src/main/resources/textures/objects/vfx/middleexplosion.png new file mode 100644 index 0000000000000000000000000000000000000000..7639e02887afa6a80408de549113441b504b1a5a Binary files /dev/null and b/src/main/resources/textures/objects/vfx/middleexplosion.png differ diff --git a/src/main/resources/textures/objects/vfx/smallexplosion.png b/src/main/resources/textures/objects/vfx/smallexplosion.png new file mode 100644 index 0000000000000000000000000000000000000000..7639e02887afa6a80408de549113441b504b1a5a Binary files /dev/null and b/src/main/resources/textures/objects/vfx/smallexplosion.png differ diff --git a/src/main/resources/videos/rolling.mp4 b/src/main/resources/videos/rolling.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..07dd01a89cbc742e3a449aa8dae9c99b3f631e43 Binary files /dev/null and b/src/main/resources/videos/rolling.mp4 differ diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PersistenceTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PersistenceTest.java index 79b599da6c201b66ffe5d1c21293f44b9ee244e4..5b75327412c816a62ba58deac048f0ccde255afa 100644 --- a/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PersistenceTest.java +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PersistenceTest.java @@ -21,7 +21,7 @@ class PersistenceTest { OracleDB inst = new OracleDB(); - @Before + @BeforeEach public void setup() throws SQLException { persistenceSingleton = Persistence.getInstance(); persistenceSingleton.db = inst; @@ -42,7 +42,4 @@ class PersistenceTest { void loadPlayerStatistics() { } - - - } \ No newline at end of file diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/ParserTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/ParserTest.java index 6cbf6fc345bc7da7639d7b61c0299c9b89ac6930..758f7f0b77d2b3ec101e3219a6d8de52cae04b3c 100644 --- a/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/ParserTest.java +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/ParserTest.java @@ -140,7 +140,7 @@ class ParserTest { } @ParameterizedTest - @ValueSource(strings = {"12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12", + @ValueSource(strings = {"11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12", "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12", "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12"}) void mapDataValid(String test){