From 51727662169bc6c5c2ea79848f9e4d6ce411a4c9 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Mon, 2 Dec 2024 01:34:43 +0100 Subject: [PATCH 1/2] cleanup --- .../src/main/java/pp/monopoly/model/fields/FieldColor.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/FieldColor.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/FieldColor.java index 0b14722..2dd476b 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/FieldColor.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/FieldColor.java @@ -1,12 +1,10 @@ package pp.monopoly.model.fields; import com.jme3.math.ColorRGBA; -import com.jme3.network.serializing.Serializable; /** * Enum representing eight distinct colors for properties in the game. */ -// @Serializable public enum FieldColor { BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)), GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)), From add5dab611011808b2fda1528035d45b7a672932 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Mon, 2 Dec 2024 01:37:32 +0100 Subject: [PATCH 2/2] buyHouse complete --- .../main/java/pp/monopoly/client/gui/popups/BuyHouse.java | 2 ++ .../java/pp/monopoly/game/server/ServerGameLogic.java | 8 ++++++++ .../main/java/pp/monopoly/model/fields/BoardManager.java | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java index 3bc9f1d..d2b3c4e 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java @@ -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()); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java index 4077952..87b69af 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java @@ -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(); } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java index 7fbbd26..53a5665 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java @@ -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 }