diff --git a/README.md b/README.md index 6c30d589325ca941958984f8a2899031ada2a677..33a38e29ae80d72e68453c54d0f8d9bdb48c5694 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ ### Known issues: - JavaFX Mediaplayer is buggy under Windows 11. Videos can have weird behaviors and sometimes won't load at all - SQL server is very slow (thanks Oracle) - - multiplayer connections gets established, but the enemy player doesn't get rendert while beeing - able to get hit by the player (simplified version of the multiplayer can be eccessed through the TestMap class) + - multiplayer connections gets established, but the enemy player doesn't get rendered while beeing + able to get hit by the player (simplified version of the multiplayer can be accessed through the TestMap class) <br> 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 0d86f9f932645df2dfb7c1692b319b7ee992a444..42c0d0d4f1baa3aa32b82b9fc7b8e53f0fb344f2 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java @@ -1,6 +1,7 @@ package de.hdm_stuttgart.battlearena.Controller; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer; import javafx.fxml.FXML; import javafx.scene.layout.VBox; import javafx.stage.Stage; @@ -9,6 +10,7 @@ public class PlayerCreateController { @FXML private VBox parent; private final SceneLoader sceneLoader = new SceneLoader(); + private final MusicPlayer player = MusicPlayer.getInstance(); private void switchScene(String name) { parent.getChildren().clear(); @@ -28,6 +30,7 @@ public class PlayerCreateController { @FXML private void exit() { Stage stage = (Stage) parent.getScene().getWindow(); + player.getScheduler().shutdown(); stage.close(); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java index 72a8aef6ccddc8a433a9f26b144fc4a757cd0e71..f60a790e0e8d9a686e88c5dc5f57e0f462701d12 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java @@ -229,6 +229,9 @@ public class BigBomb implements IEntity { final double dropChanceTeleportItemFrame = 0.13; double randomDropChance = Math.random() * 1; + int blocksDestroyed = runtimeInfo.getBlocksDestroyed(); + runtimeInfo.setBlocksDestroyed(blocksDestroyed + 1); + SfxOnce t = new SfxOnce(); t.startSound(SFX.WOOD_Destruction); 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 index f46b8c5926227c9bdda7b52da365cbc0e57cdfb5..11cb9ed670134df95fc06baae313c982180d15a9 100644 --- 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 @@ -221,6 +221,9 @@ public class Bomb implements IEntity { final double dropChanceTeleportItemFrame = 0.13; double randomDropChance = Math.random() * 1; + int blocksDestroyed = runtimeInfo.getBlocksDestroyed(); + runtimeInfo.setBlocksDestroyed(blocksDestroyed + 1); + SfxOnce t = new SfxOnce(); t.startSound(SFX.WOOD_Destruction); 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 ab57c5f658d6fe1e58c861eeca0ceafdb8a382c1..b3f7b025b2a3632e637c4c32b77701f07aa1541c 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 @@ -449,7 +449,7 @@ class Player implements IEntity { gameplayObject.setObjectStatus(ObjectStatus.USED); } } - } //TODO: Marker - AND other Bombs - get ONLY visually removed when explosion is set to USED ?? + } return false; } @@ -631,7 +631,7 @@ class Player implements IEntity { if (inputHandler.isAttack() && PLAYER_MODE == PlayerMode.PLAYER_ONE && attackRate == 0 || inputHandler.isSdAttack() && PLAYER_MODE == PlayerMode.PLAYER_TWO && attackRate == 0) { - attackRate = 25; + attackRate = 75; SfxOnce sfx = new SfxOnce(); sfx.startSound(SFX.SWORD_SWING); @@ -732,7 +732,7 @@ class Player implements IEntity { health -= damageDone; SfxOnce t = new SfxOnce(); t.startSound(SFX.DAMAGETAKEN); - iFrameCounter = 100; + iFrameCounter = 75; } else { if (!isDead) { SfxOnce t = new SfxOnce(); @@ -741,7 +741,7 @@ class Player implements IEntity { } isDead = true; health = 0; - iFrameCounter = 100; + iFrameCounter = 75; runtimeInfo.setDeaths(runtimeInfo.getDeaths() + 1); runtimeInfo.setKills(runtimeInfo.getKills() + 1); runtimeInfo.setGameWon(true); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java index 5e4fa7cfd6d7c38887d774210d8be8158c49860b..e0bcbd7402ce5a02c58e4f8960ffce80bdae4072 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java @@ -32,19 +32,23 @@ public class MusicPlayer { } public void startGameStateMonitoring() { + log.info("gamestatemonitoring started"); scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.scheduleAtFixedRate(() -> { GameState newGameState = RuntimeInfo.getInstance().getGameState(); if (currentGameState != newGameState) { currentGameState = newGameState; updateMusic(); + log.info("gamestate changed"); } }, 0, 1, TimeUnit.MILLISECONDS); } private void updateMusic() { + log.info("updating music..."); stopMusic(); playRandomMusic(); + } private void playRandomMusic() { @@ -83,6 +87,7 @@ public class MusicPlayer { private void stopMusic() { if (mediaPlayer != null) { + log.info("stop music"); mediaPlayer.dispose(); // Dispose of the MediaPlayer instance to ensure stoping } } @@ -92,6 +97,7 @@ public class MusicPlayer { mediaPlayer.setVolume((double) volume / 100); } public ScheduledExecutorService getScheduler() { + log.info("gamestatemonitoring stopped"); return scheduler; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SfxOnce.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SfxOnce.java index 1a54dde4ef7f1c6349b83ce3ba217ec3556eb609..2094ba422586238e4f28301419cdbd6119d32e97 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SfxOnce.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SfxOnce.java @@ -21,14 +21,13 @@ public class SfxOnce extends Thread { AudioClip audioClip = new AudioClip(Objects.requireNonNull(getClass().getResource(resource)).toExternalForm()); audioClip.setVolume((double) persistence.getSettings().getSfxVolume() / 100); this.isNotPlaying = false; + log.info("played soundeffect once"); audioClip.play(); } public void startSound(SFX sfx) { this.sfx = sfx; - start(); - } public boolean isNotPlaying() { diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundFileManager.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundFileManager.java index 9beacfbf10b361dbe9229e49dc65ed99c9045c14..19e08738bde67706206b7b1184e2b2f400cdb711 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundFileManager.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundFileManager.java @@ -1,5 +1,8 @@ package de.hdm_stuttgart.battlearena.Model.Sound; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -10,12 +13,15 @@ import java.util.stream.Collectors; import java.util.stream.Stream; class SoundFileManager { + + private static final Logger log = LogManager.getLogger(MusicPlayer.class); protected List<Path> getFilePathsFromResources(Path folderPath) throws IOException { List<Path> result; try (Stream<Path> walk = Files.walk(folderPath)) { result = walk.filter(Files::isRegularFile) .collect(Collectors.toList()); } + log.info("retrieved file paths"); return result; } @@ -24,10 +30,12 @@ class SoundFileManager { int min = 0; int max = paths.size() - 1; int randomIndex = random.nextInt(max - min + 1 ) + min; + log.info("choose random file"); return paths.get(randomIndex).toString(); } protected String convertPathToResourcePath(String randomPath){ String normalizedPath = Paths.get(randomPath).toString().replace('\\', '/'); + log.info("converted filepaths"); return normalizedPath.substring(18); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/WalkEffects.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/WalkEffects.java index 4c5cdf1aa290ee25ea53e6296307861ffd4500c8..fc4a6d0b5d3b211a78fbb1144f1c7bb1020e751e 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/WalkEffects.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/WalkEffects.java @@ -45,6 +45,7 @@ public class WalkEffects extends Thread{ AudioClip effect = new AudioClip(Objects.requireNonNull(getClass().getResource(resource)).toString()); effect.setVolume((double) persistence.getSettings().getSfxVolume() /100); effect.play(); + log.info("played walk sound"); sfxPaths.clear(); } diff --git a/src/main/resources/maps/coreMaps.json b/src/main/resources/maps/coreMaps.json index be06ca3226f294ae6ca929065d5653c413e2631c..8f8282e2ce3d4780332d0a4ecbc3997fdce2c756 100644 --- a/src/main/resources/maps/coreMaps.json +++ b/src/main/resources/maps/coreMaps.json @@ -13,6 +13,13 @@ "mapHeight": 18, "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": "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" + }, { "mapID": "f482b89b32ab4315a85108d83fb57ec09cdb7e09", "mapName": "Outpost", @@ -48,13 +55,6 @@ "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" - }, { "mapID": "09f4fbab8fd30c11a585ade60258aadebb424c23", "mapName": "HelloWorld", diff --git a/src/main/resources/player/playerStatsLocal.json b/src/main/resources/player/playerStatsLocal.json index f12f154bb978463d7d469c835d2f5228a4b5887f..5e8195f763080c5fbd5e6e8fa4b053c9c14edf95 100644 --- a/src/main/resources/player/playerStatsLocal.json +++ b/src/main/resources/player/playerStatsLocal.json @@ -1,8 +1,8 @@ { - "gamesLost": 5000, - "gamesWon": 500, - "kills": 500, - "deaths": 500, - "blocksDestroyed": 5000, - "gameTime": 5000 + "gamesWon": 0, + "gamesLost": 0, + "kills": 0, + "deaths": 0, + "blocksDestroyed": 0, + "gameTime": 0 } \ No newline at end of file