Merge remote-tracking branch 'origin/gui' into gui

This commit is contained in:
Yvonne Schmidt 2024-12-02 01:50:20 +01:00
commit fa20a6cb2a
4 changed files with 11 additions and 3 deletions

View File

@ -99,6 +99,7 @@ public class BuyHouse extends Dialog {
AlterProperty msg = new AlterProperty("BuyHouse"); AlterProperty msg = new AlterProperty("BuyHouse");
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet())); msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
app.getGameLogic().send(msg); app.getGameLogic().send(msg);
close();
})); }));
// Center the popup // Center the popup
@ -160,6 +161,7 @@ public class BuyHouse extends Dialog {
return boardManager.getPropertyFields(self.getProperties()).stream() return boardManager.getPropertyFields(self.getProperties()).stream()
.filter(property -> property instanceof BuildingProperty) .filter(property -> property instanceof BuildingProperty)
.map(property -> (BuildingProperty) property) .map(property -> (BuildingProperty) property)
.filter(property -> app.getGameLogic().getBoardManager().canBuild(property))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }

View File

@ -357,6 +357,7 @@ public class ServerGameLogic implements ClientInterpreter {
private void updateAllPlayers() { private void updateAllPlayers() {
for (Player player : playerHandler.getPlayers()) { for (Player player : playerHandler.getPlayers()) {
send(player, new PlayerStatusUpdate(playerHandler)); send(player, new PlayerStatusUpdate(playerHandler));
send(player, new ViewAssetsResponse(boardManager));
} }
} }
@ -418,7 +419,14 @@ public class ServerGameLogic implements ClientInterpreter {
playerHandler.getPlayerById(from).useJailCard(); playerHandler.getPlayerById(from).useJailCard();
} else if (msg.getA().equals("PayJail")) { } else if (msg.getA().equals("PayJail")) {
playerHandler.getPlayerById(from).payBail(); 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(); updateAllPlayers();
} }
} }

View File

@ -131,7 +131,7 @@ public class BoardManager {
.collect(Collectors.toList()); .collect(Collectors.toList());
// Check if the player owns all properties in the color group // 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 return false; // The player must own all properties in the color group
} }

View File

@ -1,12 +1,10 @@
package pp.monopoly.model.fields; package pp.monopoly.model.fields;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.network.serializing.Serializable;
/** /**
* Enum representing eight distinct colors for properties in the game. * Enum representing eight distinct colors for properties in the game.
*/ */
// @Serializable
public enum FieldColor { public enum FieldColor {
BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)), BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)),
GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)), GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)),