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/battleship/client/src/main/java/pp/battleship/client/Menu.java b/Projekte/battleship/client/src/main/java/pp/battleship/client/Menu.java
index 9143899..44a9a74 100644
--- a/Projekte/battleship/client/src/main/java/pp/battleship/client/Menu.java
+++ b/Projekte/battleship/client/src/main/java/pp/battleship/client/Menu.java
@@ -7,22 +7,21 @@
package pp.battleship.client;
+import java.io.File;
+import java.io.IOException;
+import java.util.prefs.Preferences;
+
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Checkbox;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.style.ElementId;
+import static pp.battleship.Resources.lookup;
import pp.battleship.client.gui.GameMusic;
import pp.battleship.client.gui.VolumeSlider;
import pp.dialog.Dialog;
import pp.dialog.StateCheckboxModel;
import pp.dialog.TextInputDialog;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.prefs.Preferences;
-
-import static pp.battleship.Resources.lookup;
import static pp.util.PreferencesUtils.getPreferences;
/**
@@ -39,7 +38,7 @@ class Menu extends Dialog {
private final VolumeSlider slider;
/**
- * Constructs the Menu dialog for the Battleship application.
+ * Constructs the Menu dialog for the Battleship application.+
*
* @param app the BattleshipApp instance
*/
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 baac5f7..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.
*/
@@ -206,4 +211,21 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
guiNode.detachAllChildren(); // Entferne die GUI
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/StartMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java
index e1796cc..302bd55 100644
--- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java
@@ -1,7 +1,6 @@
package pp.monopoly.client;
import com.jme3.material.Material;
-import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
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 3705593..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
@@ -1,10 +1,11 @@
package pp.monopoly.client.gui;
-import com.jme3.input.KeyInput;
-import com.jme3.input.controls.ActionListener;
-import com.jme3.input.controls.KeyTrigger;
+import javax.swing.JOptionPane;
+
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
+import com.jme3.network.Client;
+import com.jme3.network.Network;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
@@ -17,6 +18,7 @@ import com.simsilica.lemur.component.SpringGridLayout;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.StartMenu;
+import pp.monopoly.server.MonopolyServer;
/**
* CreateGameMenu class represents the menu for creating a new game.
@@ -26,6 +28,7 @@ public class CreateGameMenu {
private final MonopolyApp app;
private final Container menuContainer;
private Geometry background;
+ private Label serverStatusLabel;
public CreateGameMenu(MonopolyApp app) {
this.app = app;
@@ -64,15 +67,18 @@ public class CreateGameMenu {
cancelButton.setPreferredSize(new Vector3f(120, 40, 0));
cancelButton.addClickCommands(source -> goBackToStartMenu());
- // "Spiel hosten"-Button (funktionslos)
- Button hostButton = buttonContainer.addChild(new Button("Spiel hosten"));
+ // "Selber hosten"-Button
+ Button hostButton = buttonContainer.addChild(new Button("Selber hosten"));
hostButton.setPreferredSize(new Vector3f(120, 40, 0));
- // Keine Funktion zugewiesen
+ hostButton.addClickCommands(source -> app.startServer());
- // "Beitreten"-Button (ebenfalls funktionslos, falls benötigt)
+ // "Beitreten"-Button (vorerst funktionslos)
Button joinButton = buttonContainer.addChild(new Button("Beitreten"));
joinButton.setPreferredSize(new Vector3f(120, 40, 0));
- // Keine Funktion zugewiesen
+
+ // Serverstatus-Label
+ serverStatusLabel = menuContainer.addChild(new Label("Serverstatus: Noch nicht gestartet"));
+ serverStatusLabel.setFontSize(24);
// Zentrierung des Containers
menuContainer.setLocalTranslation(
@@ -81,10 +87,17 @@ public class CreateGameMenu {
1 // Höhere Z-Ebene für den Vordergrund
);
- app.getGuiNode().attachChild(menuContainer);
+ app.getInputManager().addMapping("OpenTestWorld", new com.jme3.input.controls.KeyTrigger(com.jme3.input.KeyInput.KEY_T));
+ app.getInputManager().addListener(new com.jme3.input.controls.ActionListener() {
+ @Override
+ public void onAction(String name, boolean isPressed, float tpf) {
+ if (name.equals("OpenTestWorld") && isPressed) {
+ app.startTestWorld(); // Öffnet die TestWorld
+ }
+ }
+ }, "OpenTestWorld");
- // Key-Mapping für Taste "T"
- setupKeyMappings();
+ app.getGuiNode().attachChild(menuContainer);
}
/**
@@ -110,30 +123,4 @@ public class CreateGameMenu {
app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild
StartMenu.createStartMenu(app);
}
-
- /**
- * Fügt ein Key-Mapping hinzu, um die TestWorld mit der Taste "T" zu öffnen.
- */
- private void setupKeyMappings() {
- app.getInputManager().addMapping("OpenTestWorld", new KeyTrigger(KeyInput.KEY_T));
- app.getInputManager().addListener(actionListener, "OpenTestWorld");
- }
-
- /**
- * ActionListener, um auf Tastendrücke zu reagieren.
- */
- private final ActionListener actionListener = (name, isPressed, tpf) -> {
- if (name.equals("OpenTestWorld") && isPressed) {
- openTestWorld();
- }
- };
-
- /**
- * Öffnet die TestWorld.
- */
- private void openTestWorld() {
- app.getGuiNode().detachChild(menuContainer);
- app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild
- app.startTestWorld(); // Öffne die TestWorld
- }
}
diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ServerScreen.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ServerScreen.java
new file mode 100644
index 0000000..c2794ab
--- /dev/null
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ServerScreen.java
@@ -0,0 +1,89 @@
+package pp.monopoly.client.gui;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+
+public class ServerScreen {
+ private JFrame frame;
+ private JTextField inputField;
+ private JLabel label;
+ private JButton startButton;
+ private JButton stopButton;
+
+ public ServerScreen() {
+ initialize();
+ }
+
+ private void initialize() {
+ // Erstelle das Hauptfenster
+ frame = new JFrame("Server Placeholder"); // Setze den Titel
+ frame.setSize(400, 200);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setLayout(new BorderLayout());
+
+ // Eingabefeld und Label im oberen Bereich
+ JPanel topPanel = new JPanel();
+ topPanel.setLayout(new FlowLayout());
+
+ label = new JLabel("Server-Port:");
+ inputField = new JTextField("42069", 10);
+ topPanel.add(label);
+ topPanel.add(inputField);
+
+ // Buttons im unteren Bereich
+ JPanel bottomPanel = new JPanel();
+ bottomPanel.setLayout(new FlowLayout());
+
+ startButton = new JButton("Start Server");
+ stopButton = new JButton("Stop Server");
+ stopButton.setEnabled(false); // Stop-Button ist anfangs deaktiviert
+
+ bottomPanel.add(startButton);
+ bottomPanel.add(stopButton);
+
+ // Füge die Panels zum Hauptfenster hinzu
+ frame.add(topPanel, BorderLayout.NORTH);
+ frame.add(bottomPanel, BorderLayout.SOUTH);
+
+ // Aktion für Start-Button
+ startButton.addActionListener(e -> startServer());
+
+ // Aktion für Stop-Button
+ stopButton.addActionListener(e -> stopServer());
+
+ // Zeige das Fenster
+ frame.setVisible(true);
+ }
+
+ private void startServer() {
+ String port = inputField.getText();
+ try {
+ int portNumber = Integer.parseInt(port);
+ // Server-Startlogik hier einfügen
+ JOptionPane.showMessageDialog(frame, "Server gestartet auf Port " + portNumber);
+ startButton.setEnabled(false); // Deaktiviere den Start-Button
+ stopButton.setEnabled(true); // Aktiviere den Stop-Button
+ } catch (NumberFormatException e) {
+ JOptionPane.showMessageDialog(frame, "Ungültiger Port: " + port, "Fehler", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ private void stopServer() {
+ // Server-Stoplogik hier einfügen
+ JOptionPane.showMessageDialog(frame, "Server gestoppt.");
+ startButton.setEnabled(true); // Aktiviere den Start-Button
+ stopButton.setEnabled(false); // Deaktiviere den Stop-Button
+ }
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(ServerScreen::new);
+ }
+}
diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java
index 6de6968..74d320b 100644
--- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java
+++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java
@@ -56,6 +56,7 @@ public class SettingsMenu extends Dialog {
Button quitButton = settingsContainer.addChild(new Button("Beenden", new ElementId("menu-button")));
quitButton.setFontSize(32);
quitButton.addClickCommands(source -> app.stop());
+
// Zentriere das Menü
settingsContainer.setLocalTranslation(
diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/MonopolyConfig.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/MonopolyConfig.java
index b65c514..3a5da01 100644
--- a/Projekte/monopoly/model/src/main/java/pp/monopoly/MonopolyConfig.java
+++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/MonopolyConfig.java
@@ -7,13 +7,10 @@
package pp.monopoly;
-import pp.util.config.Config;
-
-import java.util.Map;
-import java.util.TreeMap;
-
import static java.lang.Math.max;
+import pp.util.config.Config;
+
/**
* Provides access to the configuration settings for the Monopoly game.
*
@@ -31,7 +28,7 @@ public class MonopolyConfig extends Config {
* The default port number for the Monopoly server.
*/
@Property("port")
- private int port = 1234;
+ private int port = 42069;
/**
* The width of the game map in terms of grid units.
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);