diff --git a/Projekte/.run/MonopolyApp.run.xml b/Projekte/.run/MonopolyApp.run.xml
new file mode 100644
index 0000000..ccd1e2f
--- /dev/null
+++ b/Projekte/.run/MonopolyApp.run.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Projekte/.run/MonopolyServer.run.xml b/Projekte/.run/MonopolyServer.run.xml
new file mode 100644
index 0000000..d892cf3
--- /dev/null
+++ b/Projekte/.run/MonopolyServer.run.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Projekte/monopoly/client/build.gradle b/Projekte/monopoly/client/build.gradle
index 7582682..66985e3 100644
--- a/Projekte/monopoly/client/build.gradle
+++ b/Projekte/monopoly/client/build.gradle
@@ -7,6 +7,7 @@ description = 'Monopoly Client'
dependencies {
implementation project(":jme-common")
implementation project(":monopoly:model")
+ implementation project(":monopoly:server")
implementation libs.jme3.desktop
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 b2dfdbb..0a7df7d 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
@@ -9,8 +9,10 @@ import com.jme3.font.BitmapText;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
+
import com.jme3.system.AppSettings;
import com.simsilica.lemur.GuiGlobals;
+import com.simsilica.lemur.Label;
import com.simsilica.lemur.style.BaseStyles;
import pp.dialog.DialogBuilder;
@@ -23,6 +25,7 @@ import pp.monopoly.game.client.MonopolyClient;
import pp.monopoly.game.client.ServerConnection;
import pp.monopoly.notification.GameEventListener;
import pp.monopoly.notification.InfoTextEvent;
+import pp.monopoly.server.MonopolyServer;
public class MonopolyApp extends SimpleApplication implements MonopolyClient, GameEventListener {
private BitmapText topText;
@@ -37,6 +40,8 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
private TestWorld testWorld;
private boolean isSettingsMenuOpen = false;
private boolean inputBlocked = false;
+ private MonopolyServer monopolyServer;
+
/**
* Path to the styles script for GUI elements.
*/
@@ -207,5 +212,20 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
StartMenu.createStartMenu(this); // Zeige das Startmenü erneut
}
+ /**
+ * Startet den Server in einem neuen Thread.
+ */
+ public void startServer() {
+ new Thread(() -> {
+ try {
+ monopolyServer = new MonopolyServer(); // Erstelle Serverinstanz
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }).start();
+ }
+ public MonopolyServer getMonopolyServer() {
+ return monopolyServer;
+ }
}
diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java
index cc76a4d..d3529b0 100644
--- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java
@@ -29,8 +29,6 @@ public class CreateGameMenu {
private final Container menuContainer;
private Geometry background;
private Label serverStatusLabel;
- private MonopolyServer monopolyServer;
- private Client client;
public CreateGameMenu(MonopolyApp app) {
this.app = app;
@@ -72,7 +70,7 @@ public class CreateGameMenu {
// "Selber hosten"-Button
Button hostButton = buttonContainer.addChild(new Button("Selber hosten"));
hostButton.setPreferredSize(new Vector3f(120, 40, 0));
- hostButton.addClickCommands(source -> startServer());
+ hostButton.addClickCommands(source -> app.startServer());
// "Beitreten"-Button (vorerst funktionslos)
Button joinButton = buttonContainer.addChild(new Button("Beitreten"));
@@ -125,37 +123,4 @@ public class CreateGameMenu {
app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild
StartMenu.createStartMenu(app);
}
-
- /**
- * Startet den Server in einem neuen Thread.
- */
- private void startServer() {
- if (monopolyServer == null) {
- serverStatusLabel.setText("Serverstatus: Wird gestartet...");
- new Thread(() -> {
- try {
- monopolyServer = new MonopolyServer(); // Erstelle Serverinstanz
- serverStatusLabel.setText("Serverstatus: Läuft auf Port " + monopolyServer.getConfig().getPort());
- } catch (Exception e) {
- serverStatusLabel.setText("Serverstatus: Fehler beim Starten");
- e.printStackTrace();
- }
- }).start();
- } else {
- serverStatusLabel.setText("Serverstatus: Bereits gestartet!");
- }
- }
-
- private void joinGame(String host, String port) {
- try {
- int portNumber = Integer.parseInt(port);
- client = Network.connectToServer(host, portNumber); // Verbindet sich mit Server
- client.start();
- JOptionPane.showMessageDialog(null, "Erfolgreich mit dem Server verbunden: " + host + ":" + port);
- // Hier kannst du zusätzliche Logik für das Verbinden hinzufügen
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Fehler beim Verbinden mit dem Server: " + e.getMessage(),
- "Verbindungsfehler", JOptionPane.ERROR_MESSAGE);
- }
- }
}
diff --git a/Projekte/monopoly/server/src/main/java/pp/monopoly/server/MonopolyServer.java b/Projekte/monopoly/server/src/main/java/pp/monopoly/server/MonopolyServer.java
index 73aaa17..f02f48d 100644
--- a/Projekte/monopoly/server/src/main/java/pp/monopoly/server/MonopolyServer.java
+++ b/Projekte/monopoly/server/src/main/java/pp/monopoly/server/MonopolyServer.java
@@ -65,7 +65,7 @@ public class MonopolyServer implements MessageListener, Connec
/**
* Creates the server.
*/
- MonopolyServer() {
+ public MonopolyServer() {
config.readFromIfExists(CONFIG_FILE);
LOGGER.log(Level.INFO, "Configuration: {0}", config); //NON-NLS
logic = new ServerGameLogic(this, config);