mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-17 12:40:59 +02:00
Compare commits
No commits in common. "bcf4956d2df746b5b28055ad7c984d28e4a778e6" and "fa20a6cb2ae534aa94dda219fdcae457ceccdcd1" have entirely different histories.
bcf4956d2d
...
fa20a6cb2a
@ -25,7 +25,7 @@ import java.lang.System.Logger.Level;
|
||||
import static pp.monopoly.Resources.lookup;
|
||||
|
||||
/**
|
||||
* Manages the network connection for the Monopoly application.
|
||||
* Manages the network connection for the Battleship application.
|
||||
* Handles connecting to and disconnecting from the server, and sending messages.
|
||||
*/
|
||||
public class NetworkSupport implements MessageListener<Client>, ClientStateListener, ServerConnection {
|
||||
@ -34,9 +34,9 @@ public class NetworkSupport implements MessageListener<Client>, ClientStateListe
|
||||
private Client client;
|
||||
|
||||
/**
|
||||
* Constructs a NetworkSupport instance for the given Monopoly application.
|
||||
* Constructs a NetworkSupport instance for the given Battleship application.
|
||||
*
|
||||
* @param app The Monopoly application instance.
|
||||
* @param app The Battleship application instance.
|
||||
*/
|
||||
public NetworkSupport(MonopolyApp app) {
|
||||
this.app = app;
|
||||
@ -44,7 +44,6 @@ public class NetworkSupport implements MessageListener<Client>, ClientStateListe
|
||||
|
||||
/**
|
||||
* Return the client connections Id
|
||||
*
|
||||
* @return the client id
|
||||
*/
|
||||
public int getId() {
|
||||
@ -53,9 +52,9 @@ public class NetworkSupport implements MessageListener<Client>, ClientStateListe
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Monopoly application instance.
|
||||
* Returns the Battleship application instance.
|
||||
*
|
||||
* @return Monopoly application instance
|
||||
* @return Battleship application instance
|
||||
*/
|
||||
public MonopolyApp getApp() {
|
||||
return app;
|
||||
|
@ -14,6 +14,7 @@ import com.simsilica.lemur.Checkbox;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
|
||||
import static pp.monopoly.Resources.lookup;
|
||||
import pp.monopoly.client.GameMusic;
|
||||
import pp.monopoly.client.GameSound;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
|
@ -12,7 +12,6 @@ import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.client.gui.popups.AcceptTrade;
|
||||
import pp.monopoly.client.gui.popups.BuildingPropertyCard;
|
||||
import pp.monopoly.client.gui.popups.ConfirmTrade;
|
||||
import pp.monopoly.client.gui.popups.EventCardPopup;
|
||||
@ -22,14 +21,12 @@ import pp.monopoly.client.gui.popups.Gulag;
|
||||
import pp.monopoly.client.gui.popups.GulagInfo;
|
||||
import pp.monopoly.client.gui.popups.LooserPopUp;
|
||||
import pp.monopoly.client.gui.popups.NoMoneyWarning;
|
||||
import pp.monopoly.client.gui.popups.RejectTrade;
|
||||
import pp.monopoly.client.gui.popups.Rent;
|
||||
import pp.monopoly.client.gui.popups.TimeOut;
|
||||
import pp.monopoly.client.gui.popups.WinnerPopUp;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
import pp.monopoly.message.server.NotificationMessage;
|
||||
import pp.monopoly.message.server.TradeReply;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.model.fields.FoodField;
|
||||
import pp.monopoly.model.fields.GateField;
|
||||
@ -388,11 +385,7 @@ public class TestWorld implements GameEventListener {
|
||||
new GulagInfo(app, 1).open();
|
||||
} else if (event.msg().equals("jailpay")) {
|
||||
new GulagInfo(app, 3).open();
|
||||
} else if (event.msg().equals("tradepos")) {
|
||||
new AcceptTrade(app, (TradeReply) event.message()).open();
|
||||
} else if (event.msg().equals("tradeneg")) {
|
||||
new RejectTrade(app, (TradeReply) event.message()).open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,8 +13,6 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.message.server.TradeReply;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
/**
|
||||
* Bankrupt is a Warning-Popup which appears when the balance is negative at the end of a player´s turn
|
||||
@ -27,7 +25,7 @@ public class AcceptTrade extends Dialog {
|
||||
|
||||
|
||||
|
||||
public AcceptTrade(MonopolyApp app, TradeReply msg) {
|
||||
public AcceptTrade(MonopolyApp app) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
|
||||
@ -57,7 +55,7 @@ public class AcceptTrade extends Dialog {
|
||||
|
||||
// Text, der im Popup steht
|
||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
||||
textContainer.addChild(new Label("Du hast Spieler"+ msg.getTradeHandler().getReceiver().getName() + "einen Handel vorgeschlagen", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Du hast Spieler XXX einen Handel vorgeschlagen", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Der Handel wurde angenommen", new ElementId("label-Text")));
|
||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
@ -68,10 +66,7 @@ public class AcceptTrade extends Dialog {
|
||||
// Beenden-Button
|
||||
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
||||
quitButton.setFontSize(32);
|
||||
quitButton.addClickCommands(source -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
close();
|
||||
}));
|
||||
quitButton.addClickCommands(source -> close());
|
||||
|
||||
|
||||
// Zentriere das Popup
|
||||
|
@ -147,11 +147,6 @@ public class BuyHouse extends Dialog {
|
||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||
|
||||
// Set initial selection
|
||||
if (!propertyOptions.isEmpty()) {
|
||||
onDropdownSelectionChanged(propertySelector);
|
||||
}
|
||||
|
||||
return dropdownContainer;
|
||||
}
|
||||
/**
|
||||
|
@ -13,8 +13,6 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.message.server.TradeReply;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
/**
|
||||
* Bankrupt is a Warning-Popup which appears when the balance is negative at the end of a player´s turn
|
||||
@ -27,7 +25,7 @@ public class RejectTrade extends Dialog {
|
||||
|
||||
|
||||
|
||||
public RejectTrade(MonopolyApp app, TradeReply msg) {
|
||||
public RejectTrade(MonopolyApp app) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
|
||||
@ -57,7 +55,7 @@ public class RejectTrade extends Dialog {
|
||||
|
||||
// Text, der im Popup steht
|
||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
||||
textContainer.addChild(new Label("Du hast Spieler"+ msg.getTradeHandler().getReceiver().getName() + "einen Handel vorgeschlagen", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Du hast Spieler XXX einen Handel vorgeschlagen", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Der Handel wurde abgelehnt", new ElementId("label-Text")));
|
||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
@ -68,10 +66,7 @@ public class RejectTrade extends Dialog {
|
||||
// Beenden-Button
|
||||
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
||||
quitButton.setFontSize(32);
|
||||
quitButton.addClickCommands(source -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
close();
|
||||
}));
|
||||
quitButton.addClickCommands(source -> close());
|
||||
|
||||
|
||||
// Zentriere das Popup
|
||||
|
@ -6,6 +6,7 @@ import com.simsilica.lemur.Axis;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.ListBox;
|
||||
import com.simsilica.lemur.Selector;
|
||||
import com.simsilica.lemur.TextField;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
@ -17,9 +18,8 @@ import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.client.gui.SettingsMenu;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.message.client.AlterProperty;
|
||||
import pp.monopoly.model.fields.BoardManager;
|
||||
import pp.monopoly.model.fields.PropertyField;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -69,7 +69,7 @@ public class RepayMortage extends Dialog {
|
||||
Container downContainer = repayMortageContainer.addChild(new Container());
|
||||
|
||||
// Text, der auf der Karte steht
|
||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text")));
|
||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen
|
||||
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
@ -95,10 +95,9 @@ public class RepayMortage extends Dialog {
|
||||
confirmButton.setFontSize(32);
|
||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
AlterProperty msg = new AlterProperty("RepayMortage");
|
||||
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
|
||||
app.getGameLogic().send(msg);
|
||||
close();
|
||||
// Send the "alter building" message to the server
|
||||
//app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
|
||||
|
||||
}));
|
||||
|
||||
// Zentriere das Popup
|
||||
@ -129,10 +128,10 @@ public class RepayMortage extends Dialog {
|
||||
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
||||
|
||||
VersionedList<String> propertyOptions = new VersionedList<>();
|
||||
List<PropertyField> playerProperties = getPlayerProperties();
|
||||
List<BuildingProperty> playerProperties = getPlayerProperties();
|
||||
|
||||
// Populate the dropdown with property names
|
||||
for (PropertyField property : playerProperties) {
|
||||
for (BuildingProperty property : playerProperties) {
|
||||
propertyOptions.add(property.getName());
|
||||
}
|
||||
|
||||
@ -147,26 +146,20 @@ public class RepayMortage extends Dialog {
|
||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||
|
||||
// Set initial selection
|
||||
if (!propertyOptions.isEmpty()) {
|
||||
onDropdownSelectionChanged(propertySelector);
|
||||
}
|
||||
|
||||
return dropdownContainer;
|
||||
}
|
||||
/**
|
||||
* Retrieves the list of properties owned by the current player.
|
||||
*
|
||||
* @return List of PropertyField objects owned by the player.
|
||||
* @return List of BuildingProperty objects owned by the player.
|
||||
*/
|
||||
private List<PropertyField> getPlayerProperties() {
|
||||
private List<BuildingProperty> getPlayerProperties() {
|
||||
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
||||
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
||||
|
||||
return boardManager.getPropertyFields(self.getProperties()).stream()
|
||||
.filter(property -> property instanceof PropertyField)
|
||||
.map(property -> (PropertyField) property)
|
||||
.filter(p -> p.isMortgaged())
|
||||
.filter(property -> property instanceof BuildingProperty)
|
||||
.map(property -> (BuildingProperty) property)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ -191,7 +184,7 @@ public class RepayMortage extends Dialog {
|
||||
|
||||
int cost = 0;
|
||||
for (String s : selectedProperties) {
|
||||
cost += ((PropertyField) app.getGameLogic().getBoardManager().getFieldByName(s)).getHypo();
|
||||
cost += ((BuildingProperty) app.getGameLogic().getBoardManager().getFieldByName(s)).getHousePrice();
|
||||
}
|
||||
|
||||
String display = String.join(" | ", selectedProperties);
|
||||
|
@ -21,7 +21,7 @@ import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.client.gui.SettingsMenu;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.message.client.AlterProperty;
|
||||
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||
import pp.monopoly.model.fields.BoardManager;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.notification.Sound;
|
||||
@ -73,7 +73,7 @@ public class SellHouse extends Dialog {
|
||||
Container downContainer = sellhouseContainer.addChild(new Container());
|
||||
|
||||
// Text, der auf der Karte steht
|
||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text")));
|
||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen
|
||||
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
@ -99,16 +99,9 @@ public class SellHouse extends Dialog {
|
||||
confirmButton.setFontSize(32);
|
||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
AlterProperty msg = new AlterProperty("SellHouse");
|
||||
for (String string : selectedProperties) {
|
||||
System.out.println(string);
|
||||
}
|
||||
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
|
||||
for (Integer integer : msg.getProperties()) {
|
||||
System.out.println("ID des verkaufs: "+integer);
|
||||
}
|
||||
app.getGameLogic().send(msg);
|
||||
close();
|
||||
// Send the "alter building" message to the server
|
||||
//app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
|
||||
|
||||
}));
|
||||
|
||||
// Zentriere das Popup
|
||||
@ -156,11 +149,6 @@ public class SellHouse extends Dialog {
|
||||
selectionDisplay = new TextField(""); // Create TextField for displaying selections
|
||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||
|
||||
// Set initial selection
|
||||
if (!propertyOptions.isEmpty()) {
|
||||
onDropdownSelectionChanged(propertySelector);
|
||||
}
|
||||
|
||||
return dropdownContainer;
|
||||
}
|
||||
@ -176,7 +164,6 @@ public class SellHouse extends Dialog {
|
||||
return boardManager.getPropertyFields(self.getProperties()).stream()
|
||||
.filter(property -> property instanceof BuildingProperty)
|
||||
.map(property -> (BuildingProperty) property)
|
||||
.filter(p -> app.getGameLogic().getBoardManager().canSell(p))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.simsilica.lemur.Axis;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.ListBox;
|
||||
import com.simsilica.lemur.Selector;
|
||||
import com.simsilica.lemur.TextField;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
@ -17,10 +18,8 @@ import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.client.gui.SettingsMenu;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.message.client.AlterProperty;
|
||||
import pp.monopoly.model.fields.BoardManager;
|
||||
import pp.monopoly.model.fields.PropertyField;
|
||||
import pp.monopoly.model.fields.PropertyField;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -70,7 +69,7 @@ public class TakeMortage extends Dialog {
|
||||
Container downContainer = takeMortageContainer.addChild(new Container());
|
||||
|
||||
// Text, der auf der Karte steht
|
||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text")));
|
||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen
|
||||
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
@ -96,10 +95,8 @@ public class TakeMortage extends Dialog {
|
||||
confirmButton.setFontSize(32);
|
||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
AlterProperty msg = new AlterProperty("TakeMortage");
|
||||
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
|
||||
app.getGameLogic().send(msg);
|
||||
close();
|
||||
// Send the "alter building" message to the server
|
||||
//app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
|
||||
}));
|
||||
|
||||
// Zentriere das Popup
|
||||
@ -130,10 +127,10 @@ public class TakeMortage extends Dialog {
|
||||
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
||||
|
||||
VersionedList<String> propertyOptions = new VersionedList<>();
|
||||
List<PropertyField> playerProperties = getPlayerProperties();
|
||||
List<BuildingProperty> playerProperties = getPlayerProperties();
|
||||
|
||||
// Populate the dropdown with property names
|
||||
for (PropertyField property : playerProperties) {
|
||||
for (BuildingProperty property : playerProperties) {
|
||||
propertyOptions.add(property.getName());
|
||||
}
|
||||
|
||||
@ -148,26 +145,20 @@ public class TakeMortage extends Dialog {
|
||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||
|
||||
// Set initial selection
|
||||
if (!propertyOptions.isEmpty()) {
|
||||
onDropdownSelectionChanged(propertySelector);
|
||||
}
|
||||
|
||||
return dropdownContainer;
|
||||
}
|
||||
/**
|
||||
* Retrieves the list of properties owned by the current player.
|
||||
*
|
||||
* @return List of PropertyField objects owned by the player.
|
||||
* @return List of BuildingProperty objects owned by the player.
|
||||
*/
|
||||
private List<PropertyField> getPlayerProperties() {
|
||||
private List<BuildingProperty> getPlayerProperties() {
|
||||
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
||||
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
||||
|
||||
return boardManager.getPropertyFields(self.getProperties()).stream()
|
||||
.filter(property -> property instanceof PropertyField)
|
||||
.map(property -> (PropertyField) property)
|
||||
.filter(p -> !p.isMortgaged())
|
||||
.filter(property -> property instanceof BuildingProperty)
|
||||
.map(property -> (BuildingProperty) property)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ -192,7 +183,7 @@ public class TakeMortage extends Dialog {
|
||||
|
||||
int cost = 0;
|
||||
for (String s : selectedProperties) {
|
||||
cost += ((PropertyField) app.getGameLogic().getBoardManager().getFieldByName(s)).getHypo();
|
||||
cost += ((BuildingProperty) app.getGameLogic().getBoardManager().getFieldByName(s)).getHousePrice();
|
||||
}
|
||||
|
||||
String display = String.join(" | ", selectedProperties);
|
||||
|
@ -53,7 +53,7 @@ public class WinnerPopUp extends Dialog {
|
||||
backgroundContainer.setPreferredSize(WinnerContainer.getPreferredSize().addLocal(padding, padding, 0));
|
||||
|
||||
// Titel
|
||||
Label winnerTitle = WinnerContainer.addChild(new Label("Herzlichen Glückwunsch, du bist der neue Monopoly Champion!", new ElementId("header")));
|
||||
Label winnerTitle = WinnerContainer.addChild(new Label("Herlichen Glückwunsch, du bist der neue Monopoly Champion!", new ElementId("header")));
|
||||
winnerTitle.setFontSize(25);
|
||||
// winnerTitle.setColor(ColorRGBA.Black);
|
||||
// Create the image container
|
||||
|
@ -307,10 +307,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
public void received(TradeReply msg) {
|
||||
if (msg.isAccepted()) {
|
||||
playSound(Sound.TRADE_ACCEPTED);
|
||||
notifyListeners(new PopUpEvent("tradepos", msg));
|
||||
} else {
|
||||
playSound(Sound.TRADE_REJECTED);
|
||||
notifyListeners(new PopUpEvent("tradeneg", msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,32 +382,27 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
public void received(AlterProperty msg, int from) {
|
||||
Player sender = playerHandler.getPlayerById(from);
|
||||
|
||||
Set<PropertyField> properties = new HashSet<>();
|
||||
for (Integer integer : msg.getProperties()) {
|
||||
properties.add( (PropertyField)boardManager.getFieldAtIndex(integer));
|
||||
}
|
||||
|
||||
if (msg.getKeyword().equals("TakeMortage")) {
|
||||
for (PropertyField field : properties) {
|
||||
for (PropertyField field : sender.getPropertyFields()) {
|
||||
field.setMortgaged(true);
|
||||
sender.earnMoney(field.getHypo());
|
||||
}
|
||||
} else if (msg.getKeyword().equals("RepayMortage")) {
|
||||
for (PropertyField field : properties) {
|
||||
for (PropertyField field : sender.getPropertyFields()) {
|
||||
if(sender.getAccountBalance() >= field.getHypo()) {
|
||||
field.setMortgaged(false);
|
||||
sender.pay(field.getHypo());
|
||||
}
|
||||
}
|
||||
} else if(msg.getKeyword().equals("BuyHouse")) {
|
||||
for (BuildingProperty field : properties.stream().map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||
for (BuildingProperty field : sender.getPropertyFields().stream().filter(p -> p instanceof BuildingProperty).map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||
if (boardManager.canBuild(field) && sender.getAccountBalance() >= field.getHousePrice()) {
|
||||
field.build();
|
||||
sender.pay(field.getHousePrice());
|
||||
}
|
||||
}
|
||||
} else if(msg.getKeyword().equals("SellHouse")) {
|
||||
for (BuildingProperty field : properties.stream().map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||
for (BuildingProperty field : sender.getPropertyFields().stream().filter(p -> p instanceof BuildingProperty).map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||
if (boardManager.canSell(field)) {
|
||||
field.sell();
|
||||
sender.earnMoney(field.getHousePrice());
|
||||
@ -425,11 +420,11 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
} 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());
|
||||
}
|
||||
playerHandler.getPlayerAtIndex(0).earnMoney(20000);
|
||||
}
|
||||
|
||||
updateAllPlayers();
|
||||
|
@ -10,7 +10,7 @@ import pp.monopoly.game.server.Player;
|
||||
@Serializable
|
||||
public class BuildingProperty extends PropertyField {
|
||||
|
||||
private int houses = 2;
|
||||
private int houses;
|
||||
private final int housePrice;
|
||||
private final FieldColor color;
|
||||
private final int rentFactor1 = 5;
|
||||
|
Loading…
Reference in New Issue
Block a user