diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java index 6ff0998..4a77ec0 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java @@ -24,6 +24,7 @@ public class BuildingAdminMenu extends Dialog { private final Button takeMortgageButton = new Button("Hypothek aufnehmen"); private final Button payMortgageButton = new Button("Hypothek bezahlen"); private final Button overviewButton = new Button("Übersicht"); + private Geometry background; public BuildingAdminMenu(MonopolyApp app) { super(app.getDialogManager()); @@ -42,7 +43,7 @@ public class BuildingAdminMenu extends Dialog { // Add content mainContainer.addChild(createContent()); // Attach main container to GUI node - app.getGuiNode().attachChild(mainContainer); + attachChild(mainContainer); mainContainer.setLocalTranslation( (app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2, @@ -146,29 +147,23 @@ public class BuildingAdminMenu extends 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); + 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 "Zurück" action. - */ - private void handleBack() { - app.getGameLogic().playSound(Sound.BUTTON); - close(); + attachChild(background); } @Override public void escape() { - handleBack(); + new SettingsMenu(app).open(); } @Override - public void update(float delta) { - // Periodic updates if necessary + public void close() { + detachChild(background); + detachChild(mainContainer); + super.close(); } } \ No newline at end of file diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java index be513a5..a6dd56d 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java @@ -93,7 +93,7 @@ public class PropertyOverviewMenu extends Dialog { */ private void populatePlayerProperties() { // Fetch the current player - Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayers().get(0); + Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()); // Iterate through the player's properties for (PropertyField property : currentPlayer.getPropertyFields()) { diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index d3e82fc..7958d33 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -220,6 +220,8 @@ public class Toolbar extends Dialog implements GameEventListener { @Override public void receivedEvent(UpdatePlayerView event) { + + System.out.println("Update Player View"); accountContainer.clearChildren(); overviewContainer.clearChildren(); @@ -266,4 +268,10 @@ public class Toolbar extends Dialog implements GameEventListener { public void escape() { new SettingsMenu(app).open(); } + + @Override + public void update() { + receivedEvent(new UpdatePlayerView()); + super.update(); + } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java index df976b0..25c6489 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyCard.java @@ -28,7 +28,7 @@ public class BuyCard extends Dialog { this.app = app; //Generate the corresponfing field - int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();; + int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); // Create the background container diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java index c7b75b6..14138cd 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java @@ -32,7 +32,7 @@ public class FoodFieldCard extends Dialog { this.app = app; //Generate the corresponfing field - int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID(); + int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); FoodField field = (FoodField) app.getGameLogic().getBoardManager().getFieldAtIndex(index); // Halbtransparentes Overlay hinzufügen diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java index 413cefa..610f383 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java @@ -31,7 +31,7 @@ public class GateFieldCard extends Dialog { this.app = app; //Generate the corresponfing field - int index = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID(); + int index = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); GateField field = (GateField) app.getGameLogic().getBoardManager().getFieldAtIndex(index); // Halbtransparentes Overlay hinzufügen diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java index 872eed0..05bbba5 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java @@ -71,7 +71,7 @@ public class SellHouse extends Dialog { VersionedList listModel = new VersionedList<>(); // Retrieve current player and their properties - Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayers().get(0); + Player currentPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()); BoardManager boardManager = app.getGameLogic().getBoardManager(); List playerProperties = boardManager.getPropertyFields( diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index 31c97d1..3a275bf 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -269,6 +269,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { @Override public void received(PlayerStatusUpdate msg) { playerHandler = msg.getPlayerHandler(); + System.out.println("Update Player"); notifyListeners(new UpdatePlayerView()); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java index 00066fd..21e1c4d 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java @@ -152,6 +152,7 @@ public class ServerGameLogic implements ClientInterpreter { System.out.println("Properties:" +player.getProperties().toString()); LOGGER.log(Level.INFO, "Player {0} bought property {1}", player.getName(), property.getName()); } + updateAllPlayers(); } /** @@ -173,6 +174,7 @@ public class ServerGameLogic implements ClientInterpreter { send(player, new PlayerStatusUpdate(playerHandler)); } } + updateAllPlayers(); } /** @@ -218,6 +220,7 @@ public class ServerGameLogic implements ClientInterpreter { if (player != null) { send(player, player.rollDice()); } + updateAllPlayers(); } /** @@ -266,9 +269,13 @@ public class ServerGameLogic implements ClientInterpreter { if (sender != null) { LOGGER.log(Level.DEBUG, "Processing ViewAssetsRequest for player {0}", sender.getName()); send(sender, new ViewAssetsResponse(boardManager)); - for (Player player : playerHandler.getPlayers()) { - send(player, new PlayerStatusUpdate(playerHandler)); - } + updateAllPlayers(); + } + } + + private void updateAllPlayers() { + for (Player player : playerHandler.getPlayers()) { + send(player, new PlayerStatusUpdate(playerHandler)); } }