diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java index cb4a3d9..db55633 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java @@ -18,11 +18,16 @@ import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; import pp.monopoly.message.client.TradeOffer; import pp.monopoly.model.TradeHandler; +import pp.monopoly.model.fields.BuildingProperty; import pp.monopoly.model.fields.PropertyField; import pp.monopoly.notification.Sound; +import java.util.ArrayList; +import java.util.Comparator; import java.util.HashSet; +import java.util.List; import java.util.Set; +import java.util.stream.Collectors; /** * Represents the trade menu dialog in the Monopoly application. @@ -200,12 +205,34 @@ public class TradeMenu extends Dialog { * @return an iterable of property fields */ private Iterable getPropertyFields(boolean isLeft) { - return app.getGameLogic() + Set building = app.getGameLogic() .getBoardManager() .getPropertyFields(app.getGameLogic() .getPlayerHandler() .getPlayerById(isLeft ? tradeHandler.getSender().getId() : tradeHandler.getReceiver().getId()) - .getProperties()); + .getProperties()) + .stream() + .filter(p -> p instanceof BuildingProperty) + .map(p -> (BuildingProperty) p) + .filter(p -> p.getHouses() == 0) + .collect(Collectors.toSet()); + + Set rest = app.getGameLogic() + .getBoardManager() + .getPropertyFields(app.getGameLogic() + .getPlayerHandler() + .getPlayerById(isLeft ? tradeHandler.getSender().getId() : tradeHandler.getReceiver().getId()) + .getProperties()) + .stream() + .filter(p -> !(p instanceof BuildingProperty)) + .collect(Collectors.toSet()); + + + List combinedProperties = new ArrayList<>(); + combinedProperties.addAll(building); + combinedProperties.addAll(rest); + combinedProperties = combinedProperties.stream().sorted(Comparator.comparingInt(PropertyField::getId)).collect(Collectors.toList()); + return combinedProperties; } /** Creates a text field for currency input. */ private TextField createCurrencyInput() {