mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 22:56:15 +01:00
can only trade fields without buildings
This commit is contained in:
parent
551786bf30
commit
b50b5e64d1
@ -18,11 +18,16 @@ import pp.dialog.Dialog;
|
|||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.message.client.TradeOffer;
|
import pp.monopoly.message.client.TradeOffer;
|
||||||
import pp.monopoly.model.TradeHandler;
|
import pp.monopoly.model.TradeHandler;
|
||||||
|
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.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the trade menu dialog in the Monopoly application.
|
* Represents the trade menu dialog in the Monopoly application.
|
||||||
@ -200,12 +205,34 @@ public class TradeMenu extends Dialog {
|
|||||||
* @return an iterable of property fields
|
* @return an iterable of property fields
|
||||||
*/
|
*/
|
||||||
private Iterable<PropertyField> getPropertyFields(boolean isLeft) {
|
private Iterable<PropertyField> getPropertyFields(boolean isLeft) {
|
||||||
return app.getGameLogic()
|
Set<PropertyField> building = app.getGameLogic()
|
||||||
.getBoardManager()
|
.getBoardManager()
|
||||||
.getPropertyFields(app.getGameLogic()
|
.getPropertyFields(app.getGameLogic()
|
||||||
.getPlayerHandler()
|
.getPlayerHandler()
|
||||||
.getPlayerById(isLeft ? tradeHandler.getSender().getId() : tradeHandler.getReceiver().getId())
|
.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<PropertyField> 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<PropertyField> 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. */
|
/** Creates a text field for currency input. */
|
||||||
private TextField createCurrencyInput() {
|
private TextField createCurrencyInput() {
|
||||||
|
Loading…
Reference in New Issue
Block a user