added documentation for SellHouse

This commit is contained in:
Yvonne Schmidt 2024-12-02 08:58:41 +01:00
parent 531a3e263c
commit 821c9ec3fb

View File

@ -32,20 +32,43 @@ import java.util.Set;
import java.util.stream.Collectors;
/**
* SellHouse is a popup which appears when a player clicks on the "demolish"-button in the BuildingAdminMenu
* SellHouse is a popup that appears when a player clicks on the "Demolish" button
* in the BuildingAdminMenu.
* <p>
* This dialog allows players to select their properties and demolish houses or hotels
* for a partial refund of their purchase cost.
* </p>
*/
public class SellHouse extends Dialog {
/** Reference to the Monopoly application instance. */
private final MonopolyApp app;
/** Main container for the SellHouse dialog UI. */
private final Container sellhouseContainer;
/** Background container providing a styled border around the main dialog. */
private final Container backgroundContainer;
private TextField selectionDisplay; // TextField to display selections
/** Text field to display selected properties. */
private TextField selectionDisplay;
/** Reference to track selection changes in the property selector. */
private VersionedReference<Set<Integer>> selectionRef;
/** Dropdown selector for displaying available properties. */
private Selector<String> propertySelector;
/** Set of properties selected for selling. */
private Set<String> selectedProperties = new HashSet<>();
/** Label to display the total refund amount for the selected properties. */
private Label cost = new Label("0", new ElementId("label-Text"));
/**
* Constructs a new SellHouse dialog.
*
* @param app The MonopolyApp instance.
*/
public SellHouse(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
@ -180,6 +203,11 @@ public class SellHouse extends Dialog {
.collect(Collectors.toList());
}
/**
* Updates the dialog UI, tracking changes in the property selection.
*
* @param delta Time since the last update.
*/
@Override
public void update(float delta) {
if(selectionRef.update()) {
@ -188,7 +216,9 @@ public class SellHouse extends Dialog {
}
/**
* Handles property selection changes.
* Handles changes to the property selection.
*
* @param playerProperties The dropdown menu's selection state.
*/
private void onDropdownSelectionChanged(Selector<String> playerProperties) {
String selected = playerProperties.getSelectedItem();
@ -211,7 +241,7 @@ public class SellHouse extends Dialog {
}
/**
* Schließt das Menü und entfernt die GUI-Elemente.
* Closes the dialog and removes GUI elements from the screen.
*/
@Override
public void close() {
@ -220,6 +250,9 @@ public class SellHouse extends Dialog {
super.close();
}
/**
* Handles the escape action to close the dialog.
*/
@Override
public void escape() {
new SettingsMenu(app).open();