mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 22:56:15 +01:00
mortage
This commit is contained in:
parent
7ace959f1f
commit
560bedc80b
@ -6,7 +6,6 @@ import com.simsilica.lemur.Axis;
|
|||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
import com.simsilica.lemur.ListBox;
|
|
||||||
import com.simsilica.lemur.Selector;
|
import com.simsilica.lemur.Selector;
|
||||||
import com.simsilica.lemur.TextField;
|
import com.simsilica.lemur.TextField;
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
@ -18,8 +17,9 @@ import pp.dialog.Dialog;
|
|||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
import pp.monopoly.message.client.AlterProperty;
|
||||||
import pp.monopoly.model.fields.BoardManager;
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -69,7 +69,7 @@ public class RepayMortage extends Dialog {
|
|||||||
Container downContainer = repayMortageContainer.addChild(new Container());
|
Container downContainer = repayMortageContainer.addChild(new Container());
|
||||||
|
|
||||||
// Text, der auf der Karte steht
|
// Text, der auf der Karte steht
|
||||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen
|
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text")));
|
||||||
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||||
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
|
|
||||||
@ -95,9 +95,10 @@ public class RepayMortage extends Dialog {
|
|||||||
confirmButton.setFontSize(32);
|
confirmButton.setFontSize(32);
|
||||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
// Send the "alter building" message to the server
|
AlterProperty msg = new AlterProperty("RepayMortage");
|
||||||
//app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
|
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
|
||||||
|
app.getGameLogic().send(msg);
|
||||||
|
close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
@ -128,10 +129,10 @@ public class RepayMortage extends Dialog {
|
|||||||
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
||||||
|
|
||||||
VersionedList<String> propertyOptions = new VersionedList<>();
|
VersionedList<String> propertyOptions = new VersionedList<>();
|
||||||
List<BuildingProperty> playerProperties = getPlayerProperties();
|
List<PropertyField> playerProperties = getPlayerProperties();
|
||||||
|
|
||||||
// Populate the dropdown with property names
|
// Populate the dropdown with property names
|
||||||
for (BuildingProperty property : playerProperties) {
|
for (PropertyField property : playerProperties) {
|
||||||
propertyOptions.add(property.getName());
|
propertyOptions.add(property.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,20 +147,26 @@ public class RepayMortage extends Dialog {
|
|||||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||||
|
|
||||||
|
// Set initial selection
|
||||||
|
if (!propertyOptions.isEmpty()) {
|
||||||
|
onDropdownSelectionChanged(propertySelector);
|
||||||
|
}
|
||||||
|
|
||||||
return dropdownContainer;
|
return dropdownContainer;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of properties owned by the current player.
|
* Retrieves the list of properties owned by the current player.
|
||||||
*
|
*
|
||||||
* @return List of BuildingProperty objects owned by the player.
|
* @return List of PropertyField objects owned by the player.
|
||||||
*/
|
*/
|
||||||
private List<BuildingProperty> getPlayerProperties() {
|
private List<PropertyField> getPlayerProperties() {
|
||||||
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
||||||
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
||||||
|
|
||||||
return boardManager.getPropertyFields(self.getProperties()).stream()
|
return boardManager.getPropertyFields(self.getProperties()).stream()
|
||||||
.filter(property -> property instanceof BuildingProperty)
|
.filter(property -> property instanceof PropertyField)
|
||||||
.map(property -> (BuildingProperty) property)
|
.map(property -> (PropertyField) property)
|
||||||
|
.filter(p -> p.isMortgaged())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +191,7 @@ public class RepayMortage extends Dialog {
|
|||||||
|
|
||||||
int cost = 0;
|
int cost = 0;
|
||||||
for (String s : selectedProperties) {
|
for (String s : selectedProperties) {
|
||||||
cost += ((BuildingProperty) app.getGameLogic().getBoardManager().getFieldByName(s)).getHousePrice();
|
cost += ((PropertyField) app.getGameLogic().getBoardManager().getFieldByName(s)).getHypo();
|
||||||
}
|
}
|
||||||
|
|
||||||
String display = String.join(" | ", selectedProperties);
|
String display = String.join(" | ", selectedProperties);
|
||||||
|
@ -6,7 +6,6 @@ import com.simsilica.lemur.Axis;
|
|||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
import com.simsilica.lemur.ListBox;
|
|
||||||
import com.simsilica.lemur.Selector;
|
import com.simsilica.lemur.Selector;
|
||||||
import com.simsilica.lemur.TextField;
|
import com.simsilica.lemur.TextField;
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
@ -18,8 +17,10 @@ import pp.dialog.Dialog;
|
|||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
import pp.monopoly.message.client.AlterProperty;
|
||||||
import pp.monopoly.model.fields.BoardManager;
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -69,7 +70,7 @@ public class TakeMortage extends Dialog {
|
|||||||
Container downContainer = takeMortageContainer.addChild(new Container());
|
Container downContainer = takeMortageContainer.addChild(new Container());
|
||||||
|
|
||||||
// Text, der auf der Karte steht
|
// Text, der auf der Karte steht
|
||||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen
|
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text")));
|
||||||
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||||
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
|
|
||||||
@ -95,8 +96,10 @@ public class TakeMortage extends Dialog {
|
|||||||
confirmButton.setFontSize(32);
|
confirmButton.setFontSize(32);
|
||||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
// Send the "alter building" message to the server
|
AlterProperty msg = new AlterProperty("TakeMortage");
|
||||||
//app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
|
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
|
||||||
|
app.getGameLogic().send(msg);
|
||||||
|
close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
@ -127,10 +130,10 @@ public class TakeMortage extends Dialog {
|
|||||||
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
||||||
|
|
||||||
VersionedList<String> propertyOptions = new VersionedList<>();
|
VersionedList<String> propertyOptions = new VersionedList<>();
|
||||||
List<BuildingProperty> playerProperties = getPlayerProperties();
|
List<PropertyField> playerProperties = getPlayerProperties();
|
||||||
|
|
||||||
// Populate the dropdown with property names
|
// Populate the dropdown with property names
|
||||||
for (BuildingProperty property : playerProperties) {
|
for (PropertyField property : playerProperties) {
|
||||||
propertyOptions.add(property.getName());
|
propertyOptions.add(property.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,20 +148,26 @@ public class TakeMortage extends Dialog {
|
|||||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||||
|
|
||||||
|
// Set initial selection
|
||||||
|
if (!propertyOptions.isEmpty()) {
|
||||||
|
onDropdownSelectionChanged(propertySelector);
|
||||||
|
}
|
||||||
|
|
||||||
return dropdownContainer;
|
return dropdownContainer;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of properties owned by the current player.
|
* Retrieves the list of properties owned by the current player.
|
||||||
*
|
*
|
||||||
* @return List of BuildingProperty objects owned by the player.
|
* @return List of PropertyField objects owned by the player.
|
||||||
*/
|
*/
|
||||||
private List<BuildingProperty> getPlayerProperties() {
|
private List<PropertyField> getPlayerProperties() {
|
||||||
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
||||||
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
||||||
|
|
||||||
return boardManager.getPropertyFields(self.getProperties()).stream()
|
return boardManager.getPropertyFields(self.getProperties()).stream()
|
||||||
.filter(property -> property instanceof BuildingProperty)
|
.filter(property -> property instanceof PropertyField)
|
||||||
.map(property -> (BuildingProperty) property)
|
.map(property -> (PropertyField) property)
|
||||||
|
.filter(p -> !p.isMortgaged())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +192,7 @@ public class TakeMortage extends Dialog {
|
|||||||
|
|
||||||
int cost = 0;
|
int cost = 0;
|
||||||
for (String s : selectedProperties) {
|
for (String s : selectedProperties) {
|
||||||
cost += ((BuildingProperty) app.getGameLogic().getBoardManager().getFieldByName(s)).getHousePrice();
|
cost += ((PropertyField) app.getGameLogic().getBoardManager().getFieldByName(s)).getHypo();
|
||||||
}
|
}
|
||||||
|
|
||||||
String display = String.join(" | ", selectedProperties);
|
String display = String.join(" | ", selectedProperties);
|
||||||
|
@ -10,7 +10,7 @@ import pp.monopoly.game.server.Player;
|
|||||||
@Serializable
|
@Serializable
|
||||||
public class BuildingProperty extends PropertyField {
|
public class BuildingProperty extends PropertyField {
|
||||||
|
|
||||||
private int houses;
|
private int houses = 2;
|
||||||
private final int housePrice;
|
private final int housePrice;
|
||||||
private final FieldColor color;
|
private final FieldColor color;
|
||||||
private final int rentFactor1 = 5;
|
private final int rentFactor1 = 5;
|
||||||
|
Loading…
Reference in New Issue
Block a user