7 Commits

Author SHA1 Message Date
Johannes Schmelz
4703afd656 Merge branch 'logic' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into logic 2024-11-25 06:53:56 +01:00
Johannes Schmelz
d26c29b561 Merge branch 'logic' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into logic 2024-11-18 17:11:40 +01:00
Johannes Schmelz
4279d130dd Merge branch 'logic' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into logic 2024-11-18 16:53:11 +01:00
Johannes Schmelz
fc5315d35a Merge branch 'logic' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into logic 2024-11-18 05:00:36 +01:00
Johannes Schmelz
c7c2d95aed refactor for java 20 2024-11-18 05:00:31 +01:00
Johannes Schmelz
84e68d9fa8 Merge branch 'gui' into 'logic'
Gui

See merge request progproj/gruppen-ht24/Gruppe-02!8
2024-11-18 03:50:55 +00:00
Johannes Schmelz
465aef567e Gui 2024-11-18 03:50:54 +00:00
40 changed files with 472 additions and 834 deletions

View File

@@ -1,5 +1,6 @@
// Styling of Lemur components
// For documentation, see:
// For documentation, see:
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
import com.jme3.math.ColorRGBA
@@ -11,7 +12,6 @@ import com.simsilica.lemur.Command
import com.simsilica.lemur.HAlignment
import com.simsilica.lemur.Insets3f
import com.simsilica.lemur.component.QuadBackgroundComponent
import com.simsilica.lemur.component.TbtQuadBackgroundComponent
def bgColor = color(1, 1, 1, 1)
def buttonEnabledColor = color(0, 0, 0, 1)
@@ -19,7 +19,7 @@ def buttonDisabledColor = color(0.8, 0.9, 1, 0.2)
def buttonBgColor = color(1, 1, 1, 1)
def sliderColor = color(0.6, 0.8, 0.8, 1)
def sliderBgColor = color(0.5, 0.75, 0.75, 1)
def gradientColor = color(0.5, 0.75, 0.85, 0.5)
def gradientColor = color(1, 1, 1, 1)
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
def solidWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1, 1, 1, 1))
def greyBackground = new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
@@ -30,10 +30,8 @@ def lightGrey = color(0.6, 0.6, 0.6, 1.0)
def gradient = TbtQuadBackgroundComponent.create(
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
generateMips: false),
1, 1, 1, 126, 126,
1f, false)
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png", generateMips: false),
1, 1, 1, 126, 126, 1f, false)
def doubleGradient = new QuadBackgroundComponent(gradientColor)
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
@@ -79,6 +77,7 @@ selector("header", "pp") {
textVAlignment = VAlignment.Center
}
// Container Stil
selector("container", "pp") {
background = solidWhiteBackground.clone()
background.setColor(bgColor)
@@ -91,8 +90,8 @@ selector("toolbar") {
}
selector("slider", "pp") {
background = gradient.clone()
background.setColor(bgColor)
insets = new Insets3f(5, 10, 5, 10) // Abstand
background = new QuadBackgroundComponent(sliderBgColor)
}
def pressedCommand = new Command<Button>() {
@@ -113,30 +112,6 @@ def enabledCommand = new Command<Button>() {
}
}
def repeatCommand = new Command<Button>() {
private long startTime
private long lastClick
void execute(Button source) {
// Only do the repeating click while the mouse is
// over the button (and pressed of course)
if (source.isPressed() && source.isHighlightOn()) {
long elapsedTime = System.currentTimeMillis() - startTime
// After half a second pause, click 8 times a second
if (elapsedTime > 500 && elapsedTime > lastClick + 125) {
source.click()
// Try to quantize the last click time to prevent drift
lastClick = ((elapsedTime - 500) / 125) * 125 + 500
}
}
else {
startTime = System.currentTimeMillis()
lastClick = 0
}
}
}
def stdButtonCommands = [
(ButtonAction.Down) : [pressedCommand],
(ButtonAction.Up) : [pressedCommand],

View File

@@ -1,110 +0,0 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.monopoly.client;
import com.jme3.input.controls.ActionListener;
import com.jme3.scene.Node;
import com.jme3.system.AppSettings;
import pp.monopoly.client.MonopolyAppState;
import pp.monopoly.client.gui.TestWorld;
import pp.monopoly.model.IntPoint;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
/**
* Represents the state responsible for managing the battle interface within the Battleship game.
* This state handles the display and interaction of the battle map, including the opponent's map.
* It manages GUI components, input events, and the layout of the interface when this state is enabled.
*/
public class GameAppState extends MonopolyAppState {
private static final Logger LOGGER = System.getLogger(MonopolyAppState.class.getName());
private static final float DEPTH = 0f;
private static final float GAP = 20f;
/**
* A listener for handling click events in the battle interface.
* When a click is detected, it triggers the corresponding actions on the opponent's map.
*/
private final ActionListener clickListener = (name, isPressed, tpf) -> click(isPressed);
/**
* The root node for all GUI components in the battle state.
*/
private final Node battleNode = new Node("Game"); //NON-NLS
/**
* A view representing the opponent's map in the GUI.
*/
private TestWorld testWorld;
/**
* Enables the battle state by initializing, laying out, and adding GUI components.
* Attaches the components to the GUI node and registers input listeners.
*/
@Override
protected void enableState() {
battleNode.detachAllChildren();
initializeGuiComponents();
layoutGuiComponents();
addGuiComponents();
getApp().getGuiNode().attachChild(battleNode);
}
/**
* Disables the battle state by removing GUI components and unregistering input listeners.
* Also handles cleanup of resources, such as the opponent's map view.
*/
@Override
protected void disableState() {
getApp().getGuiNode().detachChild(battleNode);
getApp().getInputManager().removeListener(clickListener);
}
/**
* Initializes the GUI components used in the battle state.
* Creates the opponent's map view and adds a grid overlay to it.
*/
private void initializeGuiComponents() {
testWorld = new TestWorld(getApp());
testWorld.initializeScene();
}
/**
* Adds the initialized GUI components to the battle node.
* Currently, it attaches the opponent's map view to the node.
*/
private void addGuiComponents() {
}
/**
* Lays out the GUI components within the window, positioning them appropriately.
* The opponent's map view is positioned based on the window's dimensions and a specified gap.
*/
private void layoutGuiComponents() {
final AppSettings s = getApp().getContext().getSettings();
final float windowWidth = s.getWidth();
final float windowHeight = s.getHeight();
}
/**
* Handles click events in the battle interface. If the event indicates a click (not a release),
* it translates the cursor position to the model's coordinate system and triggers the game logic
* for interacting with the opponent's map.
*
* @param isPressed whether the mouse button is currently pressed (true) or released (false)
*/
private void click(boolean isPressed) {
}
@Override
public void update(float tpf) {
testWorld.update(tpf);
super.update(tpf);
}
}

View File

@@ -1,30 +1,26 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.monopoly.client;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.prefs.Preferences;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.prefs.Preferences;
import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.asset.AssetLoadException;
import com.jme3.asset.AssetNotFoundException;
import com.jme3.audio.AudioData;
import com.jme3.audio.AudioNode;
import pp.monopoly.notification.GameEventListener;
import pp.monopoly.notification.SoundEvent;
import static pp.util.PreferencesUtils.getPreferences;
/**
* An application state that plays sounds.
* An application state that plays sounds based on game events.
*/
public class GameSound extends AbstractAppState implements GameEventListener {
private static final Logger LOGGER = System.getLogger(GameSound.class.getName());
@@ -71,7 +67,6 @@ public class GameSound extends AbstractAppState implements GameEventListener {
/**
* Sets the enabled state of this AppState.
* Overrides {@link com.jme3.app.state.AbstractAppState#setEnabled(boolean)}
*
* @param enabled {@code true} to enable the AppState, {@code false} to disable it.
*/
@@ -79,16 +74,15 @@ public class GameSound extends AbstractAppState implements GameEventListener {
public void setEnabled(boolean enabled) {
if (isEnabled() == enabled) return;
super.setEnabled(enabled);
LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled); //NON-NLS
LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled);
PREFERENCES.putBoolean(ENABLED_PREF, enabled);
}
/**
* Initializes the sound effects for the game.
* Overrides {@link AbstractAppState#initialize(AppStateManager, Application)}
* Initializes the sound effects for the game and stores the application reference.
*
* @param stateManager The state manager
* @param app The application
* @param app The application instance
*/
@Override
public void initialize(AppStateManager stateManager, Application app) {
@@ -109,18 +103,16 @@ public class GameSound extends AbstractAppState implements GameEventListener {
/**
* Loads a sound from the specified file.
*
* @param app The application
* @param name The name of the sound file.
* @return The loaded AudioNode.
*/
private AudioNode loadSound(Application app, String name) {
private AudioNode loadSound(String name) {
try {
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
sound.setLooping(false);
sound.setPositional(false);
return sound;
}
catch (AssetLoadException | AssetNotFoundException ex) {
} catch (Exception ex) {
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
}
return null;
@@ -239,4 +231,4 @@ public class GameSound extends AbstractAppState implements GameEventListener {
case BUTTON -> button();
}
}
}
}//heloo

View File

@@ -18,6 +18,7 @@ import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.system.AppSettings;
import com.jme3.texture.Texture;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.style.BaseStyles;
@@ -221,7 +222,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
/**
* Returns the current configuration settings for the Battleship client.
*
* @return The {@link BattleshipClientConfig} instance. //TODO Fehler im Kommentar
* @return The {@link BattleshipClientConfig} instance.
*/
@Override
public MonopolyAppConfig getConfig() {
@@ -279,7 +280,19 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
private void handleB(boolean isPressed) {
if (isPressed) {
Dialog tmp = new BuyCard(this);
tmp.open();
if (eventCard != null && isBuyCardPopupOpen) {
// Schließe das SettingsMenu
System.out.println("Schließe BuyCardPopup...");
eventCard.close();
eventCard = null;
tmp.open();
} else {
// Öffne das SettingsMenu
System.out.println("Öffne BuyCardPopup...");
eventCard = new EventCard(this);
eventCard.open();
dialogManager.close(tmp);
}
}
}
@@ -308,7 +321,6 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
attachGameSound();
attachGameMusic();
stateManager.attach(new GameAppState());
}
/**
@@ -432,7 +444,6 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
*/
@Override
public void receivedEvent(ClientStateEvent event) {
stateManager.getState(GameAppState.class).setEnabled(true);
}
/**
@@ -493,9 +504,4 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
public void disconnect() {
serverConnection.disconnect();
}
public int getId() {
if (serverConnection != null && serverConnection instanceof NetworkSupport) return ((NetworkSupport) serverConnection).getId();
return 0;
}
}

View File

@@ -3,8 +3,10 @@ package pp.monopoly.client.gui;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import pp.monopoly.model.Board;
import pp.monopoly.model.Item;
import pp.monopoly.model.Item;
import pp.monopoly.model.Visitor;
import pp.monopoly.notification.GameEventListener;
import pp.monopoly.notification.ItemAddedEvent;
@@ -24,10 +26,14 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
*
* @param board the game board to synchronize
* @param root the root node to which the view representations of the board items are attached
* @param board the game board to synchronize
* @param root the root node to which the view representations of the board items are attached
*/
protected BoardSynchronizer(Board board, Node root) {
protected BoardSynchronizer(Board board, Node root) {
super(root);
this.board = board;
this.board = board;
}
/**
@@ -42,6 +48,7 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
}
/**
* Adds the existing items from the board to the view during initialization.
* Adds the existing items from the board to the view during initialization.
*/
protected void addExisting() {
@@ -49,26 +56,36 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
}
/**
* Handles the event when an item is removed from the board.
* Handles the event when an item is removed from the board.
*
* @param event the event indicating that an item has been removed from the board
* @param event the event indicating that an item has been removed from the board
*/
@Override
public void receivedEvent(ItemRemovedEvent event) {
if (board == event.getBoard()) {
delete(event.getItem());
}
if (board == event.getBoard()) {
delete(event.getItem());
}
}
/**
* Handles the event when an item is added to the board.
* Handles the event when an item is added to the board.
*
* @param event the event indicating that an item has been added to the board
* @param event the event indicating that an item has been added to the board
*/
@Override
public void receivedEvent(ItemAddedEvent event) {
if (board == event.getBoard()) {
add(event.getItem());
}
if (board == event.getBoard()) {
add(event.getItem());
}
}
}

View File

@@ -7,142 +7,48 @@ import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.Selector;
import com.simsilica.lemur.TextField;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout;
import com.simsilica.lemur.core.VersionedList;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.notification.Sound;
public class ChoosePartner extends Dialog {
private final MonopolyApp app;
private Selector<String> playerSelector;
private final Button cancelButton = new Button("Abbrechen");
private final Button confirmButton = new Button("Bestätigen");
private final Container mainContainer;
private Container lowerLeftMenu;
private Container lowerRightMenu;
private Geometry background;
QuadBackgroundComponent translucentWhiteBackground =
new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));
/**
* Constructs the ChoosePartner dialog.
*
* @param app The Monopoly application instance.
*/
private final MonopolyApp app;
private final Container menuContainer;
private Geometry background;
public ChoosePartner(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
// Background Image
// Hintergrundbild laden und hinzufügen
addBackgroundImage();
// Main container for the UI components
mainContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
mainContainer.setPreferredSize(new Vector3f(1000, 600, 0));
mainContainer.setBackground(translucentWhiteBackground);
QuadBackgroundComponent translucentWhiteBackground =
new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));
// Add title with background
Label headerLabel = mainContainer.addChild(new Label("Wähle deinen Handelspartner:", new ElementId("label-Bold")));
headerLabel.setFontSize(40);
headerLabel.setBackground(new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)));
menuContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
menuContainer.setPreferredSize(new Vector3f(1000, 600, 0)); // Fixed size of the container
menuContainer.setBackground(translucentWhiteBackground);
// Dropdown for player selection
mainContainer.addChild(createDropdown());
// Create a smaller horizontal container for the label, input field, and spacers
Container horizontalContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
horizontalContainer.setPreferredSize(new Vector3f(600, 40, 0)); // Adjust container size
horizontalContainer.setBackground(null);
// Add buttons
mainContainer.addChild(createButtonContainer());
Label title = horizontalContainer.addChild(new Label("Wähle deinen Handelspartner:", new ElementId("label-Bold")));
title.setFontSize(40);
// Attach main container to GUI node
app.getGuiNode().attachChild(mainContainer);
mainContainer.setLocalTranslation(
(app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2,
4
);
}
/**
* Creates the dropdown menu for selecting a partner.
*
* @return The dropdown container.
*/
private Container createDropdown() {
Container dropdownContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
dropdownContainer.setPreferredSize(new Vector3f(100, 80, 0));
dropdownContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
VersionedList<String> playerOptions = new VersionedList<>();
playerOptions.add("Spieler 1");
playerOptions.add("Spieler 2");
playerOptions.add("Spieler 3");
playerOptions.add("Spieler 4");
playerSelector = new Selector<>(playerOptions, "glass");
dropdownContainer.addChild(playerSelector);
Vector3f dimens = dropdownContainer.getPreferredSize();
Vector3f dimens2 = playerSelector.getPopupContainer().getPreferredSize();
dimens2.setX( dimens.getX() );
playerSelector.getPopupContainer().setPreferredSize(new Vector3f(200,200,3));
playerSelector.setLocalTranslation(0,0,5);
return dropdownContainer;
}
/**
* Creates the button container with cancel and confirm buttons.
*
* @return The button container.
*/
private Container createButtonContainer() {
Container buttonContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
buttonContainer.setBackground(translucentWhiteBackground);
// "Abbrechen" button
lowerLeftMenu = new Container();
cancelButton.setPreferredSize(new Vector3f(200, 60, 0));
cancelButton.setFontSize(30);
cancelButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
close();
}));
lowerLeftMenu.addChild(cancelButton);
// Position the container near the bottom-left corner
lowerLeftMenu.setLocalTranslation(new Vector3f(120, 170, 5)); // Adjust X and Y to align with the bottom-left corner
app.getGuiNode().attachChild(lowerLeftMenu);
// "Bestätigen" button
lowerRightMenu = new Container();
confirmButton.setPreferredSize(new Vector3f(200, 60, 0));
confirmButton.setFontSize(30);
confirmButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
String selectedPlayer = playerSelector.getSelectedItem();
System.out.println("Selected player: " + selectedPlayer);
close();
new TradeMenu(app).open();
}));
lowerRightMenu.addChild(confirmButton);
// Position the container near the bottom-right corner
lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 320, 170, 5)); // X: 220px from the right, Y: 50px above the bottom
app.getGuiNode().attachChild(lowerRightMenu);
return buttonContainer;
}
/**
* Adds a background image to the dialog.
* Lädt das Hintergrundbild und fügt es als geometrische Ebene hinzu.
*/
private void addBackgroundImage() {
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
@@ -151,38 +57,8 @@ public class ChoosePartner extends Dialog {
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
backgroundMaterial.setTexture("ColorMap", backgroundImage);
background.setMaterial(backgroundMaterial);
background.setLocalTranslation(0, 0, 3); // Position behind other GUI elements
background.setLocalTranslation(0, 0, -1); // Hintergrundebene
app.getGuiNode().attachChild(background);
}
/**
* Handles the escape action for the dialog.
*/
@Override
public void escape() {
new SettingsMenu(app).open();
}
/**
* Updates the dialog periodically, called by the dialog manager.
*
* @param delta The time elapsed since the last update.
*/
@Override
public void update(float delta) {
// Periodic updates (if needed) can be implemented here
}
@Override
public void close() {
app.getGuiNode().detachChild(playerSelector);
app.getGuiNode().detachChild(lowerLeftMenu);
app.getGuiNode().detachChild(lowerRightMenu);
app.getGuiNode().detachChild(mainContainer);
app.getGuiNode().detachChild(background);
super.close();
}
}

View File

@@ -88,7 +88,6 @@ public class LobbyMenu extends Dialog {
// Dropdowns and Labels
Container dropdownContainer = menuContainer.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
dropdownContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
dropdownContainer.setPreferredSize(new Vector3f(800, 200, 0));
dropdownContainer.setBackground(null);
dropdownContainer.setInsets(new Insets3f(10, 0, 0, 0));
@@ -123,11 +122,6 @@ public class LobbyMenu extends Dialog {
figureDropdown.setBackground(new QuadBackgroundComponent(ColorRGBA.DarkGray));
figureDropdown.setPreferredSize(new Vector3f(100, 20, 0));
figureDropdownContainer.addChild(figureDropdown);
Vector3f dimens = dropdownContainer.getPreferredSize();
Vector3f dimens2 = figureDropdown.getPopupContainer().getPreferredSize();
dimens2.setX( dimens.getX() );
figureDropdown.getPopupContainer().setPreferredSize(new Vector3f(200,200,5));
addSelectionActionListener(figureDropdown, this::onDropdownSelectionChanged);

View File

@@ -6,12 +6,17 @@ import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.HAlignment;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.HAlignment;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout;
import com.simsilica.lemur.component.SpringGridLayout;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.notification.Sound;
@@ -20,10 +25,12 @@ import pp.monopoly.notification.Sound;
* Constructs the startup menu dialog for the Monopoly application.
import pp.monopoly.client.gui.GameMenu;
*/
*/
public class StartMenu extends Dialog {
private final MonopolyApp app;
/**
* Constructs the Startup Menu dialog for the Monopoly application.
* Constructs the Startup Menu dialog for the Monopoly application.
*
* @param app the MonopolyApp instance
@@ -41,8 +48,10 @@ public class StartMenu extends Dialog {
Geometry background = new Geometry("Background", quad);
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
backgroundMaterial.setTexture("ColorMap", backgroundImage);
backgroundMaterial.setTexture("ColorMap", backgroundImage);
background.setMaterial(backgroundMaterial);
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
app.getGuiNode().attachChild(background);
// Center container for title and play button

View File

@@ -1,6 +1,8 @@
package pp.monopoly.client.gui;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
@@ -19,7 +21,6 @@ public class TestWorld {
private final MonopolyApp app;
private CameraController cameraController; // Steuert die Kamera
private Toolbar toolbar;
/**
* Konstruktor für TestWorld.
@@ -50,8 +51,7 @@ public class TestWorld {
);
// Füge die Toolbar hinzu
toolbar = new Toolbar(app);
toolbar.open();
new Toolbar(app).open();
cameraController.setPosition(0);
}

View File

@@ -0,0 +1,80 @@
package pp.monopoly.client.gui;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;
import com.jme3.system.JmeCanvasContext;
import com.jme3.system.AppSettings;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class TestWorldWithMenu extends SimpleApplication {
public static void createAndShowGUI() {
// Create JFrame
JFrame frame = new JFrame("Test World with Menu");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.setSize(800, 600);
// Create Menu Bar
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenuItem exitItem = new JMenuItem(new AbstractAction("Exit") {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
fileMenu.add(exitItem);
menuBar.add(fileMenu);
frame.setJMenuBar(menuBar);
// Create Canvas for jMonkey
AppSettings settings = new AppSettings(true);
settings.setWidth(800);
settings.setHeight(600);
TestWorldWithMenu app = new TestWorldWithMenu();
app.setSettings(settings);
app.createCanvas(); // Create a canvas for embedding
JmeCanvasContext ctx = (JmeCanvasContext) app.getContext();
ctx.setSystemListener(app);
Canvas canvas = ctx.getCanvas();
canvas.setSize(800, 600);
// Add the canvas to JFrame
frame.add(canvas, BorderLayout.CENTER);
// Show the frame
frame.setVisible(true);
// Start the jMonkeyEngine application
app.startCanvas();
}
@Override
public void simpleInitApp() {
// Erstelle ein Quadrat
Box box = new Box(1, 0.01f, 1); // Dünnes Quadrat für die Textur
Geometry geom = new Geometry("Box", box);
// Setze das Material mit Textur
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
Texture texture = assetManager.loadTexture("Pictures/board.png"); // Replace with the path to your image
mat.setTexture("ColorMap", texture);
geom.setMaterial(mat);
// Füge das Quadrat zur Szene hinzu
rootNode.attachChild(geom);
// Setze die Kameraposition, um das Quadrat zu fokussieren
cam.setLocation(new Vector3f(0, 0, 3)); // Kamera auf der Z-Achse, nah am Quadrat
cam.lookAt(geom.getLocalTranslation(), Vector3f.UNIT_Y);
}
}

View File

@@ -1,7 +1,6 @@
package pp.monopoly.client.gui;
import java.util.List;
import java.util.Random;
import com.jme3.font.BitmapText;
@@ -17,28 +16,22 @@ import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.game.server.Player;
import pp.monopoly.game.server.PlayerHandler;
import pp.monopoly.message.client.EndTurn;
import pp.monopoly.message.client.RollDice;
import pp.monopoly.notification.DiceRollEvent;
import pp.monopoly.notification.GameEventListener;
import pp.monopoly.notification.Sound;
/**
* Toolbar Klasse, die am unteren Rand der Szene angezeigt wird.
* Die Buttons bewegen den Würfel auf dem Spielfeld.
*/
public class Toolbar extends Dialog implements GameEventListener{
public class Toolbar extends Dialog {
private final MonopolyApp app;
private final Container toolbarContainer;
private Label imageLabel;
private Label imageLabel2;
private Container overviewContainer;
private Container accountContainer;
private PlayerHandler playerHandler;
private final BitmapText positionText; // Anzeige für die aktuelle Position
private final float boardLimit = 0.95f; // Grenzen des Bretts
private final float stepSize = 0.18f; // Schrittgröße pro Bewegung
private int currentPosition = 0; // Aktuelle Position auf dem Spielfeld
private final int positionsPerSide = 10; // Anzahl der Positionen pro Seite
private final Random random = new Random(); // Zufallsgenerator für den Würfelwurf
/**
* Konstruktor für die Toolbar.
@@ -49,9 +42,6 @@ public class Toolbar extends Dialog implements GameEventListener{
super(app.getDialogManager());
this.app = app;
app.getGameLogic().addListener(this);
playerHandler = app.getGameLogic().getPlayerHandler();
// Erstelle die Toolbar
toolbarContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y), "toolbar");
@@ -64,29 +54,31 @@ public class Toolbar extends Dialog implements GameEventListener{
toolbarContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 200, 0)); // Volle Breite
// Füge Buttons zur Toolbar hinzu
//initializeButtons();
// Menü-Container: Ein Nested-Container für Kontostand und "Meine Gulag Frei Karten"
accountContainer = toolbarContainer.addChild(new Container());
Container accountContainer = toolbarContainer.addChild(new Container());
accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold")));
accountContainer.addChild(new Label(playerHandler.getPlayerById(app.getId()).getAccountBalance() + " EUR", new ElementId("label-Text")));
accountContainer.addChild(new Label("6666€", new ElementId("label-Text"))); //TODO Variable hier einsetzen
accountContainer.addChild(new Label("Gulag Frei Karten", new ElementId("label-Bold")));
accountContainer.addChild(new Label(playerHandler.getPlayerById(app.getId()).getNumJailCard()+"", new ElementId("label-Text")));
accountContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Add a spacer between accountContainer and overviewContainer
Panel spacer = new Panel(); // Create an empty panel as a spacer
spacer.setPreferredSize(new Vector3f(5, 0, 0)); // Adjust the width as needed
spacer.setBackground(null);
toolbarContainer.addChild(spacer);
// Menü-Container: Ein Container für Übersicht
overviewContainer = toolbarContainer.addChild(new Container());
Container overviewContainer = toolbarContainer.addChild(new Container());
overviewContainer.addChild(new Label("Übersicht", new ElementId("label-Bold")));
for (Player player : playerHandler.getPlayers()) {
if (player.getId() != app.getId()) { // Skip the current player (host)
overviewContainer.addChild(new Label(
player.getName() + ": " + player.getAccountBalance() + " EUR",
new ElementId("label-Text")
));
}
}
overviewContainer.addChild(new Label("„Spieler 1“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.addChild(new Label("„Spieler 2“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.addChild(new Label("„Spieler 3“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.addChild(new Label("„Spieler 4“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.addChild(new Label("„Spieler 5“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Menü-Container: Ein Container für Würfel
@@ -101,12 +93,12 @@ public class Toolbar extends Dialog implements GameEventListener{
Container leftContainer = new Container();
leftContainer.setPreferredSize(new Vector3f(100, 150, 0)); // Adjust size as needed
imageLabel = new Label("");
Label imageLabel = new Label("");
IconComponent icon = new IconComponent("Pictures/dice/one.png"); // Icon mit Textur erstellen
icon.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes
imageLabel.setIcon(icon);
imageLabel2 = new Label("");
Label imageLabel2 = new Label("");
IconComponent icon2 = new IconComponent("Pictures/dice/two.png"); // Icon mit Textur erstellen
icon2.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes
imageLabel2.setIcon(icon2);
@@ -140,7 +132,7 @@ public class Toolbar extends Dialog implements GameEventListener{
Button diceButton = new Button("Würfeln");
diceButton.setPreferredSize(new Vector3f(200, 50, 0)); // Full width for Würfeln button
diceButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().send(new RollDice());
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
}));
diceContainer.addChild(diceButton);
@@ -150,49 +142,146 @@ public class Toolbar extends Dialog implements GameEventListener{
// Menü-Container: Ein Nested-Container für Handeln, Grundstücke und Zug beenden
Container menuContainer = toolbarContainer.addChild(new Container());
menuContainer.addChild(addTradeMenuButton());
menuContainer.addChild(addPropertyMenuButton());
menuContainer.addChild(addEndTurnButton());
menuContainer.addChild(new Button("Handeln"));
menuContainer.addChild(new Button("Grundstücke"));
menuContainer.addChild(new Button("Zug beenden"));
menuContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Füge die Toolbar zur GUI hinzu
app.getGuiNode().attachChild(toolbarContainer);
// Erstelle die Position-Anzeige
positionText = createPositionDisplay();
updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition
}
private Button addTradeMenuButton() {
Button tradebutton = new Button("Handeln");
tradebutton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
tradebutton.addClickCommands(s -> ifTopDialog( () -> {
/**
* Initialisiert die Buttons in der Toolbar.
*/
private void initializeButtons() {
addTradeMenuButton(); // Bewegung nach vorne
addEndTurnButton(); // Bewegung nach hinten
addDiceRollButton(); // Würfel-Button
}
/**
* Fügt einen Button mit einer Bewegung hinzu.
*
* @param label Der Text des Buttons
* @param step Schrittweite (+1 für vorwärts, -1 für rückwärts)
*/
/*private void addButton(String label, int step) {
Button button = new Button(label);
button.setPreferredSize(new Vector3f(150, 50, 0)); // Größe der Buttons
button.addClickCommands(source -> moveCube(step));
toolbarContainer.addChild(button);
}*/
/**
* Fügt den Würfel-Button hinzu, der die Figur entsprechend der gewürfelten Zahl bewegt.
*/
private Button addDiceRollButton() {
Button diceButton = new Button("Würfeln");
diceButton.setPreferredSize(new Vector3f(50, 20, 0));
diceButton.addClickCommands(s -> ifTopDialog(() -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
}));
toolbarContainer.addChild(diceButton);
return diceButton;
}
private void addTradeMenuButton() {
Button diceButton = new Button("Handeln");
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
diceButton.addClickCommands(s -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
this.close();
System.out.println("test");
new ChoosePartner(app).open();
});
toolbarContainer.addChild(diceButton);
}// TODO Funktion der Buttons Überarbeiten und prüfen
private void addEndTurnButton() {
Button diceButton = new Button("Grundstücke");
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
diceButton.addClickCommands(s -> ifTopDialog(() -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
}));
return tradebutton;
toolbarContainer.addChild(diceButton);
}
private Button addPropertyMenuButton() {
Button propertyMenuButton = new Button("Grundstücke");
propertyMenuButton.setFontSize(30.0f);
propertyMenuButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
private void addPropertyMenuButton() {
Button diceButton = new Button("Zug beenden");
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
diceButton.addClickCommands(s -> ifTopDialog(() -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
//TODO open property dialog
}));
return propertyMenuButton;
toolbarContainer.addChild(diceButton);
}
private Button addEndTurnButton() {
Button endTurnButton = new Button("Zug beenden");
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
app.getGameLogic().send(new EndTurn());
}));
return endTurnButton;
/**
* Simuliert einen Würfelwurf und bewegt die Figur entsprechend.
*/
private void rollDice() {
int diceRoll = random.nextInt(6) + 1; // Zahl zwischen 1 und 6
System.out.println("Gewürfelt: " + diceRoll);
}
/**
* Berechnet die neue Position des Würfels basierend auf der aktuellen Brettseite und Position.
*
* @param position Aktuelle Position auf dem Spielfeld
* @return Die berechnete Position als Vector3f
*/
private Vector3f calculatePosition(int position) {
int side = position / positionsPerSide; // Seite des Bretts (0 = unten, 1 = rechts, 2 = oben, 3 = links)
int offset = position % positionsPerSide; // Position auf der aktuellen Seite
switch (side) {
case 0: // Unten (positive x-Achse)
return new Vector3f(-boardLimit + offset * stepSize, 0.1f, -boardLimit + 0.05f);
case 1: // Rechts (positive z-Achse)
return new Vector3f(boardLimit - 0.05f, 0.1f, -boardLimit + offset * stepSize);
case 2: // Oben (negative x-Achse)
return new Vector3f(boardLimit - offset * stepSize, 0.1f, boardLimit - 0.05f);
case 3: // Links (negative z-Achse)
return new Vector3f(-boardLimit + 0.05f, 0.1f, boardLimit - offset * stepSize);
default:
throw new IllegalArgumentException("Ungültige Position: " + position);
}
}
/**
* Erstellt die Anzeige für die aktuelle Position.
*
* @return Das BitmapText-Objekt für die Anzeige
*/
private BitmapText createPositionDisplay() {
BitmapText text = new BitmapText(app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"), false);
text.setSize(20); // Schriftgröße
text.setLocalTranslation(10, app.getCamera().getHeight() - 10, 0); // Oben links
app.getGuiNode().attachChild(text);
return text;
}
/**
* Aktualisiert die Anzeige für die aktuelle Position.
*/
private void updatePositionDisplay() {
positionText.setText("Feld-ID: " + currentPosition);
}
@Override
public void close() {
app.getGuiNode().detachChild(toolbarContainer);
app.getGuiNode().detachChild(positionText);
super.close();
}
@@ -200,47 +289,4 @@ public class Toolbar extends Dialog implements GameEventListener{
public void escape() {
new SettingsMenu(app).open();
}
@Override
public void receivedEvent(DiceRollEvent event) {
updateDiceImages(event.a(), event.b());
}
private void updateDiceImages(int a, int b) {
//TODO dice toll animation
IconComponent icon1 = new IconComponent(diceToString(a));
IconComponent icon2 = new IconComponent(diceToString(b));
icon1.setIconSize(new Vector2f(100, 100));
icon2.setIconSize(new Vector2f(100, 100));
imageLabel.setIcon(icon1);
imageLabel2.setIcon(icon2);
System.out.println("Dice images set");
}
private String diceToString(int i) {
switch (i) {
case 1:
return "Pictures/dice/one.png";
case 2:
return "Pictures/dice/two.png";
case 3:
return "Pictures/dice/three.png";
case 4:
return "Pictures/dice/four.png";
case 5:
return "Pictures/dice/five.png";
case 6:
return "Pictures/dice/six.png";
default:
throw new IllegalArgumentException("Invalid dice number: " + i);
}
}
}

View File

@@ -1,178 +0,0 @@
package pp.monopoly.client.gui;
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;
import com.jme3.texture.Texture;
import com.simsilica.lemur.*;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout;
import com.simsilica.lemur.core.VersionedList;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.notification.Sound;
public class TradeMenu extends Dialog {
private final MonopolyApp app;
private final Container mainContainer;
private Selector<String> leftBuildingSelector, leftCurrencySelector, leftSpecialCardSelector;
private Selector<String> rightBuildingSelector, rightCurrencySelector, rightSpecialCardSelector;
private final Button cancelButton = new Button("Abbrechen");
private final Button tradeButton = new Button("Handeln");
private Container lowerLeftMenu, lowerRightMenu;
QuadBackgroundComponent translucentWhiteBackground =
new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.White));
/**
* Constructs the TradeMenu dialog.
*
* @param app The Monopoly application instance.
*/
public TradeMenu(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
// Background Image
addBackgroundImage();
// Main container for the UI components
mainContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
mainContainer.setPreferredSize(new Vector3f(1200, 800, 0));
mainContainer.setBackground(translucentWhiteBackground);
// Add title with background
Label headerLabel = mainContainer.addChild(new Label("Handelsmenu", new ElementId("label-Bold")));
headerLabel.setFontSize(40);
headerLabel.setBackground(new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)));
// Add main content (three columns: left, middle, right)
mainContainer.addChild(createMainContent());
// Attach main container to GUI node
app.getGuiNode().attachChild(mainContainer);
mainContainer.setLocalTranslation(
(app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2,
7
);
}
//TODO Logik
//TODO Ebenen prüfen und eine Ebene Hochsetzen
//TODO Farben der Label anpassen
/**
* Creates the main content layout (left, middle, right columns).
*
* @return The main content container.
*/
private Container createMainContent() {
Container mainContent = new Container(new SpringGridLayout(Axis.X, Axis.Y));
// Left Column
mainContent.addChild(createTradeColumn("Wähle Handelsobjekt:", true));
// Middle Section
Container middleSection = mainContent.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X)));
middleSection.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f)));
TextField leftSelectionsField = middleSection.addChild(new TextField("Quellobjekte..."));
Label arrows = middleSection.addChild(new Label(""));
arrows.setFontSize(40);
TextField rightSelectionsField = middleSection.addChild(new TextField("Zielobjekte..."));
// Right Column
mainContent.addChild(createTradeColumn("Wähle Zielobjekt:", false));
return mainContent;
}
/**
* Creates a column for trade objects (left or right side).
*
* @param label The label for the column.
* @param isLeft Whether this column is the left side.
* @return The column container.
*/
private Container createTradeColumn(String label, boolean isLeft) {
Container column = new Container(new SpringGridLayout(Axis.Y, Axis.X));
column.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
Label columnLabel = column.addChild(new Label(label));
columnLabel.setFontSize(24);
columnLabel.setBackground(translucentWhiteBackground);
// Add dropdowns
column.addChild(new Label("Gebäude:"));
Selector<String> buildingSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
column.addChild(new Label("Währung:"));
Selector<String> currencySelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
column.addChild(new Label("Sonderkarten:"));
Selector<String> specialCardSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
// Assign selectors to corresponding fields
if (isLeft) {
leftBuildingSelector = buildingSelector;
leftCurrencySelector = currencySelector;
leftSpecialCardSelector = specialCardSelector;
} else {
rightBuildingSelector = buildingSelector;
rightCurrencySelector = currencySelector;
rightSpecialCardSelector = specialCardSelector;
}
return column;
}
/**
* Provides sample dropdown items.
*/
private VersionedList<String> getSampleItems() {
VersionedList<String> items = new VersionedList<>();
items.add("Option 1");
items.add("Option 2");
items.add("Option 3");
return items;
}
/**
* Adds a background image to the dialog.
*/
private void addBackgroundImage() {
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
Geometry background = new Geometry("Background", quad);
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
backgroundMaterial.setTexture("ColorMap", backgroundImage);
background.setMaterial(backgroundMaterial);
background.setLocalTranslation(0, 0, 6); // Position behind other GUI elements
app.getGuiNode().attachChild(background);
}
/**
* Handles the escape action for the dialog.
*/
@Override
public void escape() {
new SettingsMenu(app).open();
}
/**
* Updates the dialog periodically, called by the dialog manager.
*
* @param delta The time elapsed since the last update.
*/
@Override
public void update(float delta) {
// Periodic updates (if needed) can be implemented here
}
}

View File

@@ -15,13 +15,13 @@ import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.gui.SettingsMenu;
import pp.monopoly.model.fields.BoardManager;
import pp.monopoly.model.fields.BuildingProperty;
import pp.monopoly.notification.Sound;
/**
* SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann.
*/
public class BuyCard extends Dialog {
private final MonopolyApp app;
private final Geometry overlayBackground;
private final Container buyCardContainer;
private final Container backgroundContainer;
@@ -34,18 +34,22 @@ public class BuyCard extends Dialog {
//Generate the corresponfing field
BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index);
// Halbtransparentes Overlay hinzufügen
overlayBackground = createOverlayBackground();
app.getGuiNode().attachChild(overlayBackground);
// Create the background container
backgroundContainer = new Container();
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
attachChild(backgroundContainer);
app.getGuiNode().attachChild(backgroundContainer);
// Hauptcontainer für die Gebäudekarte
buyCardContainer = new Container();
Label title = buyCardContainer.addChild(new Label( field.getName(), new ElementId("label-Bold")));
title.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
title.setFontSize(48);
buyCardContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
Label settingsTitle = buyCardContainer.addChild(new Label( field.getName(), new ElementId("settings-title")));
settingsTitle.setFontSize(48);
// Text, der auf der Karte steht
// Die Preise werden dynamisch dem BoardManager entnommen
@@ -66,17 +70,9 @@ public class BuyCard extends Dialog {
// Beenden-Button
Button quitButton = buyCardContainer.addChild(new Button("Beenden", new ElementId("button")));
quitButton.setFontSize(32);
quitButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
close();
}));
// Kaufen-Button
Button buyButton = buyCardContainer.addChild(new Button("Kaufen", new ElementId("button")));
buyButton.setFontSize(32);
buyButton.addClickCommands(s -> ifTopDialog( () -> {
app.getGameLogic().playSound(Sound.BUTTON);
//TODO send buy property request
}));
float padding = 10; // Padding around the settingsContainer for the background
backgroundContainer.setPreferredSize(buyCardContainer.getPreferredSize().addLocal(padding, padding, 0));
@@ -98,6 +94,22 @@ public class BuyCard extends Dialog {
app.getGuiNode().attachChild(buyCardContainer);
}
/**
* Erstellt einen halbtransparenten Hintergrund für das Menü.
*
* @return Geometrie des Overlays
*/
private Geometry createOverlayBackground() {
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
Geometry overlay = new Geometry("Overlay", quad);
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
overlay.setMaterial(material);
overlay.setLocalTranslation(0, 0, 0);
return overlay;
}
/**
* Schließt das Menü und entfernt die GUI-Elemente.
*/
@@ -105,6 +117,7 @@ public class BuyCard extends Dialog {
public void close() {
app.getGuiNode().detachChild(buyCardContainer); // Entferne das Menü
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
super.close();
}

View File

@@ -34,13 +34,13 @@ public class MonopolyConfig extends Config {
* The width of the game map in terms of grid units.
*/
@Property("map.width")
private int mapWidth = 10;
private int mapWidth = 12;
/**
* The height of the game map in terms of grid units.
*/
@Property("map.height")
private int mapHeight = 10;
private int mapHeight = 12;
/**
* Creates an instance of {@code MonopolyConfig} with default settings.

View File

@@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.List;
import pp.monopoly.game.server.Player;
import pp.monopoly.game.server.PlayerHandler;
import pp.monopoly.message.client.ClientMessage;
import pp.monopoly.message.server.BuyPropertyResponse;
import pp.monopoly.message.server.DiceResult;
@@ -25,7 +24,6 @@ import pp.monopoly.model.Board;
import pp.monopoly.model.IntPoint;
import pp.monopoly.model.fields.BoardManager;
import pp.monopoly.notification.ClientStateEvent;
import pp.monopoly.notification.DiceRollEvent;
import pp.monopoly.notification.GameEvent;
import pp.monopoly.notification.GameEventBroker;
import pp.monopoly.notification.GameEventListener;
@@ -54,7 +52,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
/** The current state of the client game logic. */
private ClientState state = new LobbyState(this);
private PlayerHandler playerHandler;
private List<Player> players;
private BoardManager boardManager = new BoardManager();
@@ -96,8 +94,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
state.entry();
}
public PlayerHandler getPlayerHandler() {
return playerHandler;
public List<Player> getPlayers() {
return players;
}
/**
@@ -201,10 +199,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
@Override
public void received(BuyPropertyResponse msg) {
if (msg.isSuccessful()) {
setInfoText("You successfully bought " + msg.getPropertyName() + "!");
playSound(Sound.MONEY_LOST);
} else {
setInfoText("Unable to buy " + msg.getPropertyName() + ". Reason: " + msg.getReason());
}
}
@@ -215,9 +213,9 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/
@Override
public void received(DiceResult msg) {
setInfoText("You rolled a " + msg.calcTotal() + "!");
//Set the dice images
playSound(Sound.DICE_ROLL);
System.out.println("Message kam an");
notifyListeners(new DiceRollEvent(msg.getRollResult().get(0), msg.getRollResult().get(1)));
}
/**
@@ -227,7 +225,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/
@Override
public void received(EventDrawCard msg) {
setInfoText("Event card drawn: " + msg.getCardDescription());
// Kartenlogik
playSound(Sound.EVENT_CARD);
}
@@ -240,11 +238,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
@Override
public void received(GameOver msg) {
if (msg.isWinner()) {
setInfoText("Congratulations! You have won the game!");
//Winner popup
playSound(Sound.WINNER);
} else {
setInfoText("Game over. Better luck next time!");
// Looser popup
playSound(Sound.LOSER);
}
@@ -257,9 +255,9 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/
@Override
public void received(GameStart msg) {
playerHandler = msg.getPlayerHandler();
players = msg.getPlayers();
setInfoText("The game has started! Good luck!");
setState(new WaitForTurnState(this));
}
/**
@@ -270,10 +268,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
@Override
public void received(JailEvent msg) {
if (msg.isGoingToJail()) {
setInfoText("You are sent to jail!");
playSound(Sound.GULAG);
} else {
setInfoText("You are out of jail!");
}
}
@@ -285,7 +283,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
@Override
public void received(PlayerStatusUpdate msg) {
setInfoText("Player " + msg.getPlayerName() + " status updated: " + msg.getStatus());
}
/**
@@ -295,7 +293,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/
@Override
public void received(TimeOutWarning msg) {
setInfoText("Warning! Time is running out. You have " + msg.getRemainingTime() + " seconds left.");
}
/**
@@ -305,7 +303,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/
@Override
public void received(ViewAssetsResponse msg) {
setInfoText("Your current assets are being displayed.");
}
/**
@@ -316,10 +314,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
@Override
public void received(TradeReply msg) {
if (msg.getTradeHandler().getStatus()) {
setInfoText("Trade accepted by " + msg.getTradeHandler().getReceiver().getName() + ".");
playSound(Sound.TRADE_ACCEPTED);
} else {
setInfoText("Trade rejected by " + msg.getTradeHandler().getReceiver().getName() + ".");
playSound(Sound.TRADE_REJECTED);
}
}
@@ -331,7 +329,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/
@Override
public void received(TradeRequest msg) {
setInfoText("Trade offer received from " + msg.getTradeHandler().getSender().getName());
// playSound(Sound.TRADE_REQUEST); no sound effect
// notifyListeners();
}
@@ -343,8 +341,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/
@Override
public void received(NextPlayerTurn msg) {
System.out.println("Du bsit am zug message empfangen");
setInfoText("It's your turn!");
setState(new ActiveState(this));
}
}

View File

@@ -40,8 +40,8 @@ public class Player implements FieldVisitor<Void>{
private int getOutOfJailCard;
private int fieldID;
private DiceResult rollResult;
private transient final PlayerHandler handler;
private transient PlayerState state = new LobbyState();
private final PlayerHandler handler;
private PlayerState state = new LobbyState();
/**
* Default constructor for serialization purposes.
@@ -395,7 +395,6 @@ public class Player implements FieldVisitor<Void>{
* @return the result of a dice roll (1 to 6)
*/
private static int rollDice() {
System.out.println("Gewuerfelt");
return random.nextInt(6) + 1;
}
}
@@ -440,7 +439,7 @@ public class Player implements FieldVisitor<Void>{
@Override
public DiceResult rollDice() {
List<Integer> roll = List.of(Dice.rollDice(), Dice.rollDice());
rollResult = new DiceResult(roll.get(0), roll.get(1));
rollResult = new DiceResult(roll);
return rollResult;
}
@@ -492,7 +491,7 @@ public class Player implements FieldVisitor<Void>{
@Override
public DiceResult rollDice() {
List<Integer> roll = List.of(Dice.rollDice(), Dice.rollDice());
rollResult = new DiceResult(roll.get(0), roll.get(1));
rollResult = new DiceResult(roll);
if (rollResult.isDoublets()) {
state = new ActiveState();
} else if (DoubletsCounter == 0) {

View File

@@ -1,9 +1,9 @@
package pp.monopoly.game.server;
import java.util.LinkedList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -16,9 +16,9 @@ import pp.monopoly.model.LimitedLinkedList;
*/
@Serializable
public class PlayerHandler {
private List<Player> players = new LinkedList<>();
private List<Player> players = new LimitedLinkedList<>(6);
private Set<Player> readyPlayers = new HashSet<>();
private transient ServerGameLogic logic;
private ServerGameLogic logic;
private Player hostPlayer;
private Player extra = null;
@@ -168,7 +168,6 @@ public class PlayerHandler {
public Player getPlayerById(int id) {
for (Player player : players) {
if (player.getId() == id) return player;
System.out.println(player.getId());
}
throw new NoSuchElementException("Player mit id "+id+" existiert nicht");
}

View File

@@ -175,7 +175,7 @@ public class ServerGameLogic implements ClientInterpreter {
LOGGER.log(Level.DEBUG, "Ending turn for player {0}", player.getName());
Player next = playerHandler.nextPlayer();
next.setActive();
send(next, new NextPlayerTurn());
send(next, new NextPlayerTurn(next));
}
}
}
@@ -204,10 +204,10 @@ public class ServerGameLogic implements ClientInterpreter {
if(playerHandler.allPlayersReady()) {
playerHandler.setStartBalance(startMoney);
for (Player p : playerHandler.getPlayers()) {
send(p, new GameStart(playerHandler));
send(p, new GameStart(playerHandler.getPlayers()));
}
playerHandler.randomOrder();
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn());
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn(playerHandler.getPlayerAtIndex(0)));
}
}
@@ -220,8 +220,7 @@ public class ServerGameLogic implements ClientInterpreter {
@Override
public void received(RollDice msg, int from) {
Player player = playerHandler.getPlayerById(from);
if (player != null) {
System.out.println("Ergebniss gesendet");
if (player != null && state == ServerState.INGAME) {
send(player, player.rollDice());
}
}

View File

@@ -11,7 +11,7 @@ public class RollDice extends ClientMessage{
/**
* Default constructor for serialization purposes.
*/
public RollDice() { /* empty */ }
private RollDice() { /* empty */ }
@Override
public void accept(ClientInterpreter interpreter, int from) {

View File

@@ -7,24 +7,19 @@ import com.jme3.network.serializing.Serializable;
@Serializable
public class DiceResult extends ServerMessage{
private final int a;
private final int b;
private List<Integer> rollResult;
/**
* Default constructor for serialization purposes.
*/
private DiceResult() {
a = 1;
b = 1;
}
private DiceResult() { /* empty */ }
public DiceResult(int a, int b) {
this.a = a;
this.b = b;
public DiceResult(List<Integer> rollResult) {
this.rollResult = rollResult;
}
public List<Integer> getRollResult() {
return List.of(a,b);
return rollResult;
}
@Override
@@ -39,10 +34,10 @@ public class DiceResult extends ServerMessage{
}
public boolean isDoublets() {
return a == b;
return rollResult.get(0) == rollResult.get(1);
}
public int calcTotal() {
return a+b;
return rollResult.get(0)+rollResult.get(1);
}
}

View File

@@ -1,25 +1,27 @@
package pp.monopoly.message.server;
import java.util.List;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.PlayerHandler;
import pp.monopoly.game.server.Player;
@Serializable
public class GameStart extends ServerMessage{
private PlayerHandler playerHandler;
private List<Player> players;
/**
* Default constructor for serialization purposes.
*/
private GameStart() { /* empty */ }
public GameStart(PlayerHandler playerHandler) {
this.playerHandler = playerHandler;
public GameStart(List<Player> players) {
this.players = players;
}
public PlayerHandler getPlayerHandler() {
return playerHandler;
public List<Player> getPlayers() {
return players;
}
@Override

View File

@@ -2,13 +2,20 @@ package pp.monopoly.message.server;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class NextPlayerTurn extends ServerMessage{
private Player player;
/**
* Default constructor for serialization purposes.
*/
public NextPlayerTurn() {
private NextPlayerTurn() { /* empty */ }
public NextPlayerTurn(Player player) {
this.player = player;
}
@Override
@@ -21,4 +28,9 @@ public class NextPlayerTurn extends ServerMessage{
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
}
public Player getPlayer() {
return player;
}
}

View File

@@ -16,38 +16,38 @@ public class DeckHelper{
public DeckHelper() {
cards = new LinkedList<Card>();
cards.add(new Card("Du wurdest mit einem Dienst KFZ geblitzt. Zahle: 800 EUR", "dienst-kfz-blitzer"));
cards.add(new Card("Du wurdest mit einem Dienst KFZ geblitzt. Zahle: 800", "dienst-kfz-blitzer"));
cards.add(new Card("Die erste Spoparty steht bevor. Ziehe vor zum 23er.", "spoparty"));
cards.add(new Card("Du kommst aus dem Gulak frei.", "gulak-frei-1"));
cards.add(new Card("Du kommst aus dem Gulak frei.", "gulak-frei-2"));
cards.add(new Card("Du hast den Dienstführerschein bestanden. Ziehe vor bis Teststrecke.", "dienstfuehrerschein"));
cards.add(new Card("Malkmus läd zum Pubquiz ein. Rücke vor bis zum 20er.", "pubquiz"));
cards.add(new Card("Du warst ohne Namensschild in der Truppenküche. Rücke vor zum 10er. Gehe nicht über Monatsgehalt. Ziehe keine 2000x EUR ein.", "namensschild-truppenkueche"));
cards.add(new Card("Du hast heute die Spendierhosen an und gibst eine Runde in der Unibar. Zahle jedem Spieler: 400 EUR", "spendierhosen-unibar"));
cards.add(new Card("Du warst ohne Namensschild in der Truppenküche. Rücke vor zum 10er. Gehe nicht über Monatsgehalt. Ziehe keine 2000x ein.", "namensschild-truppenkueche"));
cards.add(new Card("Du hast heute die Spendierhosen an und gibst eine Runde in der Unibar. Zahle jedem Spieler: 400", "spendierhosen-unibar"));
cards.add(new Card("Du warst in der Prüfungsphase krank. Gehe 3 Felder zurück.", "pruefungsphase-krank"));
cards.add(new Card("Ziehe vor bis zum nächsten Monatsgehalt.", "naechstes-monatsgehalt"));
cards.add(new Card("Du hast ein Antreten verschlafen. Zahle: 500 EUR", "antreten-verschlafen-1"));
cards.add(new Card("Du hast den Maibock organisiert. Du erhältst: 3000 EUR", "maibock-organisiert"));
cards.add(new Card("Der Spieß macht eine unangekündigte Inventur. Zahle für jedes Haus: 400 EUR und jedes Hotel: 2800 EUR", "inventur-haeuser-hotels"));
cards.add(new Card("Du hast ein Antreten verschlafen. Zahle: 500", "antreten-verschlafen-1"));
cards.add(new Card("Du hast den Maibock organisiert. Du erhältst: 3000", "maibock-organisiert"));
cards.add(new Card("Der Spieß macht eine unangekündigte Inventur. Zahle für jedes Haus: 400 und jedes Hotel: 2800", "inventur-haeuser-hotels"));
cards.add(new Card("Es gab keine Mozzarella Bällchen mehr für Thoma. Alle Spieler ziehen vor auf Gym.", "dienstsport-gym"));
cards.add(new Card("Auf deiner Stube wurde Schimmel gefunden. Gehe ins Gulak. Begib Dich direkt dorthin. Gehe nicht über Monatsgehalt. Ziehe nicht ein.", "schimmel-gulak"));
cards.add(new Card("Deine Stube ist nach einer Partynacht nicht mehr bewohnbar. Du ziehst ins Gulak. Begib Dich direkt dorthin. Gehe nicht über Monatsgehalt. Ziehe nicht ein.", "partynacht-gulak"));
cards.add(new Card("Das Jahresabschlussantreten steht an. Ziehe vor bis Schwimmhalle.", "jahresabschlussantreten"));
cards.add(new Card("Du wurdest beim Verkaufen von Versicherungen erwischt. Zahle: 4000 EUR", "verkaufen-versicherungen"));
cards.add(new Card("Du wurdest beim Verkaufen von Versicherungen erwischt. Zahle: 4000", "verkaufen-versicherungen"));
cards.add(new Card("Du musstest einen Rückstuferantrag stellen. Setze eine Runde aus.", "rueckstuferantrag"));
cards.add(new Card("Auf einer Hausfeier bist du betrunken auf der Treppe gestürzt und dabei auf einen Kameraden gefallen. Zahle: 800 EUR und gehe zurück zu SanZ.", "hausfeier-sturz"));
cards.add(new Card("Beförderung. Beim nächsten Monatsgehalt ziehst du ein: 3000 EUR", "befoerderung"));
cards.add(new Card("Du entscheidest dich für eine Dienstreise nach Lourd. Zahle: 1000 EUR und setze eine Runde aus.", "dienstreise-lourd"));
cards.add(new Card("Auf einer Hausfeier bist du betrunken auf der Treppe gestürzt und dabei auf einen Kameraden gefallen. Zahle: 800 und gehe zurück zu SanZ.", "hausfeier-sturz"));
cards.add(new Card("Beförderung. Beim nächsten Monatsgehalt ziehst du ein: 3000", "befoerderung"));
cards.add(new Card("Du entscheidest dich für eine Dienstreise nach Lourd. Zahle: 1000 und setze eine Runde aus.", "dienstreise-lourd"));
cards.add(new Card("Du warst fleißig Blutspenden und erhältst einen Tag Sonderurlaub. Du bist nochmal an der Reihe.", "blutspenden-sonderurlaub"));
cards.add(new Card("Dir wurde auf dem Oktoberfest dein Geldbeutel geklaut. Gebe 10% deines Vermögens ab.", "geldbeutel-oktoberfest"));
cards.add(new Card("Du wirst von deinem Chef für vorbildliches Verhalten gelobt. Du erhältst: 4000 EUR", "lob-chef"));
cards.add(new Card("Deine Bekanntschaft von letzter Nacht war eine Spo. Lasse dich testen und zahle: 200 EUR", "spo-testen"));
cards.add(new Card("Du wirst von deinem Chef für vorbildliches Verhalten gelobt. Du erhältst: 4000", "lob-chef"));
cards.add(new Card("Deine Bekanntschaft von letzter Nacht war eine Spo. Lasse dich testen und zahle: 200", "spo-testen"));
cards.add(new Card("Du wurdest von Kranz geexmattet. Gehe zurück zu Prüfungsamt.", "kranz-exmatrikulation"));
cards.add(new Card("Die letzte Party ist ein wenig eskaliert. Setze eine Runde aus.", "party-eskaliert"));
cards.add(new Card("Du wurdest zur VP gewählt und schmeißt eine Einstandsparty. Zahle: 800 EUR", "vp-einstandsparty"));
cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe ein: 1500 EUR", "party-gewinn"));
cards.add(new Card("Du wurdest zur VP gewählt und schmeißt eine Einstandsparty. Zahle: 800", "vp-einstandsparty"));
cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe ein: 1500", "party-gewinn"));
cards.add(new Card("Zur falschen Zeit am falschen Ort. Du musst einen Bergmarsch planen und setzt eine Runde aus.", "bergmarsch"));
cards.add(new Card("Dein Jodel eines Eispenis mit Unterhodenbeleuchtung geht viral. Ziehe ein: 1000 EUR", "jodel-eispenis"));
cards.add(new Card("Dein Jodel eines Eispenis mit Unterhodenbeleuchtung geht viral. Ziehe ein: 1000", "jodel-eispenis"));
}
public void visit(Card card, Player player) {

View File

@@ -3,11 +3,8 @@ package pp.monopoly.model.fields;
import java.util.ArrayList;
import java.util.List;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class BuildingProperty extends PropertyField {
private int houses;
@@ -20,12 +17,6 @@ public class BuildingProperty extends PropertyField {
private final int rentFactor4 = 55;
private final int rentFactorHotel = 70;
private BuildingProperty(){
super("", 0, 0, 0);
this.housePrice = 0;
this.color = null;
}
BuildingProperty(String name, int id, int price, int rent, int housePrice, FieldColor color) {
super(name, id, price, rent);
this.housePrice = housePrice;

View File

@@ -1,18 +1,11 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class EventField extends Field{
private EventField() {
super("", 0);
}
EventField(String name, int id) {
public EventField(String name, int id) {
super(name, id);
}

View File

@@ -1,19 +1,11 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public abstract class Field {
abstract class Field {
protected final String name;
protected final int id;
private Field() {
this.name = "";
this.id = 0;
}
protected Field(String name, int id) {
this.name = name;
this.id= id;

View File

@@ -1,12 +1,10 @@
package pp.monopoly.model.fields;
import com.jme3.math.ColorRGBA;
import com.jme3.network.serializing.Serializable;
/**
* Enum representing eight distinct colors for properties in the game.
*/
// @Serializable
public enum FieldColor {
BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)),
GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)),
@@ -19,10 +17,6 @@ public enum FieldColor {
private final ColorRGBA color;
private FieldColor() {
this.color = null;
}
/**
* Constructs a FieldColor with the specified ColorRGBA value.
*

View File

@@ -1,19 +1,11 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class FineField extends Field{
private final int fine;
private FineField() {
super("", 0);
this.fine = 0;
}
FineField(String name, int id, int fine) {
super(name, id);
this.fine = fine;

View File

@@ -1,17 +1,10 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class FoodField extends PropertyField {
private FoodField() {
super("", 0, 0, 0);
}
FoodField(String name, int id) {
public FoodField(String name, int id) {
super(name, id, 1500,0);
}

View File

@@ -1,14 +1,8 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class GateField extends PropertyField{
private GateField() {
super("", 0, 0, 0);
}
public class GateField extends PropertyField{
GateField(String name, int id) {
super(name, id, 2000, 25);

View File

@@ -1,12 +1,10 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class GoField extends Field{
GoField() {
public GoField() {
super("Monatsgehalt", 0);
}

View File

@@ -1,9 +1,7 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class GulagField extends Field{
private int bailCost = 500;

View File

@@ -1,14 +1,11 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* Represents an abstract property field in the Monopoly game.
* Contains attributes related to ownership, price, rent, and mortgage status.
*/
@Serializable
public abstract class PropertyField extends Field {
private final int price;
@@ -16,12 +13,6 @@ public abstract class PropertyField extends Field {
private Player owner;
private boolean mortgaged = false;
private PropertyField() {
super("", 0);
this.price = 0;
this.rent = 0;
}
/**
* Constructs a PropertyField with the specified name, ID, price, and rent.
*

View File

@@ -1,10 +1,7 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class TestStreckeField extends Field{
private int money;

View File

@@ -1,13 +1,10 @@
package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
@Serializable
public class WacheField extends Field{
WacheField() {
public WacheField() {
super("Wache", 30);
}

View File

@@ -1,10 +0,0 @@
package pp.monopoly.notification;
public record DiceRollEvent(int a, int b) implements GameEvent{
@Override
public void notifyListener(GameEventListener listener) {
listener.receivedEvent(this);
}
}

View File

@@ -45,6 +45,4 @@ public interface GameEventListener {
* @param event the received event
*/
default void receivedEvent(ClientStateEvent event) { /* do nothing */ }
default void receivedEvent(DiceRollEvent event) { /*Do nothing */}
}

View File

@@ -1,26 +1,25 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.monopoly.notification;
/**
* Event when an item is added to a map.
* Event when a sound needs to be played.
*
* @param sound the sound to be played
* @param soundFileName the sound file to be played
*/
public record SoundEvent(Sound sound) implements GameEvent {
public class SoundEvent implements GameEvent {
private final String soundFileName;
public SoundEvent(Sound sound) {
this.soundFileName = sound.getFileName(); // Angenommen, Sound hat eine Methode getFileName()
}
public String getSoundFileName() {
return soundFileName;
}
/**
* Notifies the game event listener of this event.
*
* @param listener the game event listener
*/
@Override
public void notifyListener(GameEventListener listener) {
listener.receivedEvent(this);
}
}

View File

@@ -6,37 +6,37 @@
########################################
#
monopoly.name=Monopoly
button.play=Spiel starten
button.ready=Bereit
button.rotate=Drehen
server.connection.failed=Fehler beim Herstellen einer Serververbindung.
its.your.turn=Du bist am Zug! Klicke auf das Feld des Gegners, um zu schießen...
lost.connection.to.server=Verbindung zum Server verloren. Das Spiel wurde beendet.
place.ships.in.your.map=Platziere Schiffe auf deiner Karte.
wait.for.an.opponent=Warte auf einen Gegner!
wait.for.opponent=Warte auf deinen Gegner!
confirm.leaving=Möchtest du das Spiel wirklich beenden?
you.lost.the.game=Du hast das Spiel verloren!
you.won.the.game=Du hast das Spiel gewonnen!
button.yes=Ja
button.no=Nein
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=Verbinden
button.cancel=Abbrechen
button.connect=Connect
button.cancel=Cancel
server.dialog=Server
host.name=Host
port.number=Port
wait.its.not.your.turn=Warte, es ist nicht dein Zug!!
menu.quit=Spiel beenden
menu.return-to-game=Zum Spiel zurückkehren
menu.sound-enabled=Ton eingeschaltet
menu.background-sound-enabled=Hintergrundmusik eingeschaltet
menu.map.load=Karte aus Datei laden...
menu.map.save=Karte in Datei speichern...
label.file=Datei:
label.connecting=Verbinde...
dialog.error=Fehler
dialog.question=Frage
port.must.be.integer=Port muss eine ganze Zahl sein
map.doesnt.fit=Die Karte passt nicht zu diesem Spiel
client.server-start=Server starten
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

View File

@@ -37,7 +37,6 @@ import pp.monopoly.message.client.RollDice;
import pp.monopoly.message.client.TradeOffer;
import pp.monopoly.message.client.TradeResponse;
import pp.monopoly.message.client.ViewAssetsRequest;
import pp.monopoly.message.server.DiceResult;
import pp.monopoly.message.server.GameStart;
import pp.monopoly.message.server.NextPlayerTurn;
import pp.monopoly.message.server.ServerMessage;
@@ -131,7 +130,6 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
Serializer.registerClass(Player.class);
Serializer.registerClass(Figure.class);
Serializer.registerClass(PlayerHandler.class);
Serializer.registerClass(DiceResult.class);
}
private void registerListeners() {