diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java index 81c1c73..d55b26e 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java @@ -31,16 +31,35 @@ import java.util.stream.Collectors; * BuyHouse is a popup which appears when a player clicks on the "Buy House"-button in the BuildingAdminMenu */ public class BuyHouse extends Dialog { + /** Reference to the Monopoly application instance. */ private final MonopolyApp app; + + /** Main container for the "Buy House" popup UI. */ private final Container buyHouseContainer; + + /** Background container providing a border for the popup. */ private final Container backgroundContainer; - private TextField selectionDisplay; // TextField to display selections + + /** TextField to display selected properties. */ + private TextField selectionDisplay; + + /** Reference for tracking dropdown selection changes. */ private VersionedReference> selectionRef; + + /** Dropdown selector for choosing properties to build houses on. */ private Selector propertySelector; + + /** Set of selected properties for house purchase. */ private Set selectedProperties = new HashSet<>(); - + + /** Label displaying the total cost of building houses on the selected properties. */ private Label cost = new Label("0", new ElementId("label-Text")); + /** + * Constructs the "Buy House" popup. + * + * @param app the Monopoly application instance + */ public BuyHouse(MonopolyApp app) { super(app.getDialogManager()); this.app = app; @@ -119,9 +138,9 @@ public class BuyHouse extends Dialog { } /** - * Creates a dropdown menu for selecting a property. + * Creates a dropdown menu for selecting properties eligible for house construction. * - * @return The dropdown container. + * @return The container holding the dropdown menu. */ private Container createPropertyDropdown() { Container dropdownContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X)); @@ -154,10 +173,11 @@ public class BuyHouse extends Dialog { return dropdownContainer; } + /** - * Retrieves the list of properties owned by the current player. + * Retrieves the list of properties owned by the current player that are eligible for house construction. * - * @return List of BuildingProperty objects owned by the player. + * @return A list of {@link BuildingProperty} objects owned by the player. */ private List getPlayerProperties() { Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()); @@ -170,6 +190,11 @@ public class BuyHouse extends Dialog { .collect(Collectors.toList()); } + /** + * Periodically updates the popup, tracking selection changes in the dropdown menu. + * + * @param delta Time since the last update in seconds. + */ @Override public void update(float delta) { if(selectionRef.update()) { @@ -178,7 +203,9 @@ public class BuyHouse extends Dialog { } /** - * Handles property selection changes. + * Handles property selection changes in the dropdown menu. + * + * @param playerProperties the dropdown selector for the player's properties */ private void onDropdownSelectionChanged(Selector playerProperties) { String selected = playerProperties.getSelectedItem(); @@ -200,6 +227,9 @@ public class BuyHouse extends Dialog { this.cost.setText(cost+""); } + /** + * Closes the popup and removes its GUI elements. + */ @Override public void close() { app.getGuiNode().detachChild(buyHouseContainer); @@ -207,6 +237,9 @@ public class BuyHouse extends Dialog { super.close(); } + /** + * Opens the settings menu when the escape key is pressed. + */ @Override public void escape() { new SettingsMenu(app).open();