mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 18:23:44 +01:00
buyHouse complete
This commit is contained in:
parent
5172766216
commit
add5dab611
@ -99,6 +99,7 @@ public class BuyHouse extends Dialog {
|
||||
AlterProperty msg = new AlterProperty("BuyHouse");
|
||||
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
|
||||
app.getGameLogic().send(msg);
|
||||
close();
|
||||
}));
|
||||
|
||||
// Center the popup
|
||||
@ -160,6 +161,7 @@ public class BuyHouse extends Dialog {
|
||||
return boardManager.getPropertyFields(self.getProperties()).stream()
|
||||
.filter(property -> property instanceof BuildingProperty)
|
||||
.map(property -> (BuildingProperty) property)
|
||||
.filter(property -> app.getGameLogic().getBoardManager().canBuild(property))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -357,6 +357,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
private void updateAllPlayers() {
|
||||
for (Player player : playerHandler.getPlayers()) {
|
||||
send(player, new PlayerStatusUpdate(playerHandler));
|
||||
send(player, new ViewAssetsResponse(boardManager));
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +419,14 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
playerHandler.getPlayerById(from).useJailCard();
|
||||
} else if (msg.getA().equals("PayJail")) {
|
||||
playerHandler.getPlayerById(from).payBail();
|
||||
} else if(msg.getA().equals("hack")) {
|
||||
System.out.println("HAck ausgeführt");
|
||||
for (BuildingProperty bp : boardManager.getPropertyFields( List.of(1,3)).stream().filter(p -> p instanceof BuildingProperty).map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||
bp.setOwner(playerHandler.getPlayerById(0));
|
||||
playerHandler.getPlayerById(0).addProperty(bp.getId());
|
||||
}
|
||||
}
|
||||
|
||||
updateAllPlayers();
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class BoardManager {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Check if the player owns all properties in the color group
|
||||
if (!groupProperties.stream().allMatch(bp -> bp.getOwner() != null && bp.getOwner().equals(field.getOwner()))) {
|
||||
if (!groupProperties.stream().allMatch(bp -> bp.getOwner() != null && bp.getOwner().getId() == field.getOwner().getId())) {
|
||||
return false; // The player must own all properties in the color group
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user