From 86b8297c9d38b3e93323eb1cef924857bbde3c0c Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Wed, 13 Nov 2024 13:31:02 +0100 Subject: [PATCH] fixed bugs, game now compiles --- .../java/pp/monopoly/client/GameSound.java | 35 +------------------ .../java/pp/monopoly/client/MonopolyApp.java | 2 +- .../java/pp/monopoly/client/gui/GameMenu.java | 7 +--- .../monopoly/game/client/ClientGameLogic.java | 4 ++- .../src/main/resources/monopoly.properties | 35 +++++++++++++++++-- .../src/main/resources/monopoly_de.properties | 35 ++++++++++++++++++- 6 files changed, 73 insertions(+), 45 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java index d74df40..e09c724 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java @@ -31,10 +31,6 @@ public class GameSound extends AbstractAppState implements GameEventListener { private static final Preferences PREFERENCES = getPreferences(GameSound.class); private static final String ENABLED_PREF = "enabled"; //NON-NLS - private AudioNode splashSound; - private AudioNode shipDestroyedSound; - private AudioNode explosionSound; - /** * Checks if sound is enabled in the preferences. * @@ -75,9 +71,6 @@ public class GameSound extends AbstractAppState implements GameEventListener { @Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); - shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav"); //NON-NLS - splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS - explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS } /** @@ -100,36 +93,10 @@ public class GameSound extends AbstractAppState implements GameEventListener { return null; } - /** - * Plays the splash sound effect. - */ - public void splash() { - if (isEnabled() && splashSound != null) - splashSound.playInstance(); - } - - /** - * Plays the explosion sound effect. - */ - public void explosion() { - if (isEnabled() && explosionSound != null) - explosionSound.playInstance(); - } - - /** - * Plays sound effect when a ship has been destroyed. - */ - public void shipDestroyed() { - if (isEnabled() && shipDestroyedSound != null) - shipDestroyedSound.playInstance(); - } - @Override public void receivedEvent(SoundEvent event) { switch (event.sound()) { - case EXPLOSION -> explosion(); - case SPLASH -> splash(); - case DESTROYED_SHIP -> shipDestroyed(); + } } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 36ebc19..1bb4c98 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -159,7 +159,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga */ private AppSettings makeSettings() { final AppSettings settings = new AppSettings(true); - settings.setTitle(lookup("Monopoly.name")); + settings.setTitle(lookup("monopoly.name")); settings.setResolution(config.getResolutionWidth(), config.getResolutionHeight()); settings.setFullscreen(config.fullScreen()); settings.setUseRetinaFrameBuffer(config.useRetinaFrameBuffer()); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GameMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GameMenu.java index b6efa2d..ef5dd78 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GameMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GameMenu.java @@ -7,7 +7,6 @@ import com.simsilica.lemur.Label; import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; -import pp.monopoly.client.StartMenu; public class GameMenu extends Dialog { private final MonopolyApp app; @@ -17,7 +16,7 @@ public class GameMenu extends Dialog { * * @param app the MonopolyApp instance */ - public SettingsMenu(MonopolyApp app) { + public GameMenu(MonopolyApp app) { super(app.getDialogManager()); this.app = app; @@ -41,10 +40,6 @@ public class GameMenu extends Dialog { // You can add more settings components here, like checkboxes or sliders. } - public GameMenu(MonopolyApp app) { - super(app.getDialogManager()); - } - /** * Returns to the StartMenu when the back button is clicked. */ diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index 4801307..13d20e3 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -39,7 +39,9 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { private Board ownMap; private Board harbor; private Board opponentMap; - private ClientState state = null; + private ClientState state = new ClientState(this) { + + }; /** * Constructs a ClientGameLogic with the specified sender object. diff --git a/Projekte/monopoly/model/src/main/resources/monopoly.properties b/Projekte/monopoly/model/src/main/resources/monopoly.properties index 6f9a85c..95ff4be 100644 --- a/Projekte/monopoly/model/src/main/resources/monopoly.properties +++ b/Projekte/monopoly/model/src/main/resources/monopoly.properties @@ -5,7 +5,38 @@ ## (c) Mark Minas (mark.minas@unibw.de) ######################################## # -battleship.name=Battleship -button.ready=Ready +monopoly.name=Monopoly button.play=Start Game +button.ready=Ready +button.rotate=Rotate +server.connection.failed=Failed to establish a server connection. +its.your.turn=It's your turn! Click on the opponent's field to shoot... +lost.connection.to.server=Lost connection to server. The game terminated. +place.ships.in.your.map=Place ships in your map. +wait.for.an.opponent=Wait for an opponent! +wait.for.opponent=Wait for your opponent! +confirm.leaving=Would you really like to leave the game? +you.lost.the.game=You lost the game! +you.won.the.game=You won the game! +button.yes=Yes +button.no=No +button.ok=Ok +button.connect=Connect +button.cancel=Cancel +server.dialog=Server +host.name=Host +port.number=Port +wait.its.not.your.turn=Wait, it's not your turn!! menu.quit=Quit game +menu.return-to-game=Return to game +menu.sound-enabled=Sound switched on +menu.background-sound-enabled=Background music switched on +menu.map.load=Load map from file... +menu.map.save=Save map in file... +label.file=File: +label.connecting=Connecting... +dialog.error=Error +dialog.question=Question +port.must.be.integer=Port must be an integer number +map.doesnt.fit=The map doesn't fit to this game +client.server-start=Start server diff --git a/Projekte/monopoly/model/src/main/resources/monopoly_de.properties b/Projekte/monopoly/model/src/main/resources/monopoly_de.properties index 868e433..95ff4be 100644 --- a/Projekte/monopoly/model/src/main/resources/monopoly_de.properties +++ b/Projekte/monopoly/model/src/main/resources/monopoly_de.properties @@ -6,4 +6,37 @@ ######################################## # monopoly.name=Monopoly -button.ready=Bereit +button.play=Start Game +button.ready=Ready +button.rotate=Rotate +server.connection.failed=Failed to establish a server connection. +its.your.turn=It's your turn! Click on the opponent's field to shoot... +lost.connection.to.server=Lost connection to server. The game terminated. +place.ships.in.your.map=Place ships in your map. +wait.for.an.opponent=Wait for an opponent! +wait.for.opponent=Wait for your opponent! +confirm.leaving=Would you really like to leave the game? +you.lost.the.game=You lost the game! +you.won.the.game=You won the game! +button.yes=Yes +button.no=No +button.ok=Ok +button.connect=Connect +button.cancel=Cancel +server.dialog=Server +host.name=Host +port.number=Port +wait.its.not.your.turn=Wait, it's not your turn!! +menu.quit=Quit game +menu.return-to-game=Return to game +menu.sound-enabled=Sound switched on +menu.background-sound-enabled=Background music switched on +menu.map.load=Load map from file... +menu.map.save=Save map in file... +label.file=File: +label.connecting=Connecting... +dialog.error=Error +dialog.question=Question +port.must.be.integer=Port must be an integer number +map.doesnt.fit=The map doesn't fit to this game +client.server-start=Start server