mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-19 00:06:16 +01:00
Merge remote-tracking branch 'origin/gui' into gui
This commit is contained in:
commit
580d81a621
@ -14,7 +14,6 @@ import com.simsilica.lemur.Checkbox;
|
|||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
import com.simsilica.lemur.style.ElementId;
|
import com.simsilica.lemur.style.ElementId;
|
||||||
|
|
||||||
import static pp.monopoly.Resources.lookup;
|
|
||||||
import pp.monopoly.client.GameMusic;
|
import pp.monopoly.client.GameMusic;
|
||||||
import pp.monopoly.client.GameSound;
|
import pp.monopoly.client.GameSound;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
|
@ -12,6 +12,7 @@ import com.jme3.renderer.ViewPort;
|
|||||||
import com.jme3.scene.control.AbstractControl;
|
import com.jme3.scene.control.AbstractControl;
|
||||||
|
|
||||||
import pp.monopoly.client.MonopolyApp;
|
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.BuildingPropertyCard;
|
||||||
import pp.monopoly.client.gui.popups.ConfirmTrade;
|
import pp.monopoly.client.gui.popups.ConfirmTrade;
|
||||||
import pp.monopoly.client.gui.popups.EventCardPopup;
|
import pp.monopoly.client.gui.popups.EventCardPopup;
|
||||||
@ -21,12 +22,14 @@ import pp.monopoly.client.gui.popups.Gulag;
|
|||||||
import pp.monopoly.client.gui.popups.GulagInfo;
|
import pp.monopoly.client.gui.popups.GulagInfo;
|
||||||
import pp.monopoly.client.gui.popups.LooserPopUp;
|
import pp.monopoly.client.gui.popups.LooserPopUp;
|
||||||
import pp.monopoly.client.gui.popups.NoMoneyWarning;
|
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.Rent;
|
||||||
import pp.monopoly.client.gui.popups.TimeOut;
|
import pp.monopoly.client.gui.popups.TimeOut;
|
||||||
import pp.monopoly.client.gui.popups.WinnerPopUp;
|
import pp.monopoly.client.gui.popups.WinnerPopUp;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.game.server.PlayerHandler;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
import pp.monopoly.message.server.NotificationMessage;
|
import pp.monopoly.message.server.NotificationMessage;
|
||||||
|
import pp.monopoly.message.server.TradeReply;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
import pp.monopoly.model.fields.FoodField;
|
import pp.monopoly.model.fields.FoodField;
|
||||||
import pp.monopoly.model.fields.GateField;
|
import pp.monopoly.model.fields.GateField;
|
||||||
@ -385,7 +388,11 @@ public class TestWorld implements GameEventListener {
|
|||||||
new GulagInfo(app, 1).open();
|
new GulagInfo(app, 1).open();
|
||||||
} else if (event.msg().equals("jailpay")) {
|
} else if (event.msg().equals("jailpay")) {
|
||||||
new GulagInfo(app, 3).open();
|
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
|
@Override
|
||||||
|
@ -13,6 +13,8 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|||||||
import com.simsilica.lemur.style.ElementId;
|
import com.simsilica.lemur.style.ElementId;
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
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
|
* Bankrupt is a Warning-Popup which appears when the balance is negative at the end of a player´s turn
|
||||||
@ -25,7 +27,7 @@ public class AcceptTrade extends Dialog {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AcceptTrade(MonopolyApp app) {
|
public AcceptTrade(MonopolyApp app, TradeReply msg) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ public class AcceptTrade extends Dialog {
|
|||||||
|
|
||||||
// Text, der im Popup steht
|
// Text, der im Popup steht
|
||||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
||||||
textContainer.addChild(new Label("Du hast Spieler XXX einen Handel vorgeschlagen", new ElementId("label-Text")));
|
textContainer.addChild(new Label("Du hast Spieler"+ msg.getTradeHandler().getReceiver().getName() + "einen Handel vorgeschlagen", new ElementId("label-Text")));
|
||||||
textContainer.addChild(new Label("", 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.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)));
|
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
@ -66,7 +68,10 @@ public class AcceptTrade extends Dialog {
|
|||||||
// Beenden-Button
|
// Beenden-Button
|
||||||
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
||||||
quitButton.setFontSize(32);
|
quitButton.setFontSize(32);
|
||||||
quitButton.addClickCommands(source -> close());
|
quitButton.addClickCommands(source -> ifTopDialog(() -> {
|
||||||
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
|
close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
|
@ -147,6 +147,11 @@ public class BuyHouse extends Dialog {
|
|||||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||||
|
|
||||||
|
// Set initial selection
|
||||||
|
if (!propertyOptions.isEmpty()) {
|
||||||
|
onDropdownSelectionChanged(propertySelector);
|
||||||
|
}
|
||||||
|
|
||||||
return dropdownContainer;
|
return dropdownContainer;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +13,8 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|||||||
import com.simsilica.lemur.style.ElementId;
|
import com.simsilica.lemur.style.ElementId;
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
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
|
* Bankrupt is a Warning-Popup which appears when the balance is negative at the end of a player´s turn
|
||||||
@ -25,7 +27,7 @@ public class RejectTrade extends Dialog {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public RejectTrade(MonopolyApp app) {
|
public RejectTrade(MonopolyApp app, TradeReply msg) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ public class RejectTrade extends Dialog {
|
|||||||
|
|
||||||
// Text, der im Popup steht
|
// Text, der im Popup steht
|
||||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
||||||
textContainer.addChild(new Label("Du hast Spieler XXX einen Handel vorgeschlagen", new ElementId("label-Text")));
|
textContainer.addChild(new Label("Du hast Spieler"+ msg.getTradeHandler().getReceiver().getName() + "einen Handel vorgeschlagen", new ElementId("label-Text")));
|
||||||
textContainer.addChild(new Label("", 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.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)));
|
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
@ -66,7 +68,10 @@ public class RejectTrade extends Dialog {
|
|||||||
// Beenden-Button
|
// Beenden-Button
|
||||||
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
||||||
quitButton.setFontSize(32);
|
quitButton.setFontSize(32);
|
||||||
quitButton.addClickCommands(source -> close());
|
quitButton.addClickCommands(source -> ifTopDialog(() -> {
|
||||||
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
|
close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
|
@ -6,7 +6,6 @@ import com.simsilica.lemur.Axis;
|
|||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
import com.simsilica.lemur.ListBox;
|
|
||||||
import com.simsilica.lemur.Selector;
|
import com.simsilica.lemur.Selector;
|
||||||
import com.simsilica.lemur.TextField;
|
import com.simsilica.lemur.TextField;
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
@ -18,8 +17,9 @@ import pp.dialog.Dialog;
|
|||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
import pp.monopoly.message.client.AlterProperty;
|
||||||
import pp.monopoly.model.fields.BoardManager;
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -69,7 +69,7 @@ public class RepayMortage extends Dialog {
|
|||||||
Container downContainer = repayMortageContainer.addChild(new Container());
|
Container downContainer = repayMortageContainer.addChild(new Container());
|
||||||
|
|
||||||
// Text, der auf der Karte steht
|
// Text, der auf der Karte steht
|
||||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen
|
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text")));
|
||||||
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||||
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
|
|
||||||
@ -95,9 +95,10 @@ public class RepayMortage extends Dialog {
|
|||||||
confirmButton.setFontSize(32);
|
confirmButton.setFontSize(32);
|
||||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
// Send the "alter building" message to the server
|
AlterProperty msg = new AlterProperty("RepayMortage");
|
||||||
//app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
|
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
|
||||||
|
app.getGameLogic().send(msg);
|
||||||
|
close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
@ -128,10 +129,10 @@ public class RepayMortage extends Dialog {
|
|||||||
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
||||||
|
|
||||||
VersionedList<String> propertyOptions = new VersionedList<>();
|
VersionedList<String> propertyOptions = new VersionedList<>();
|
||||||
List<BuildingProperty> playerProperties = getPlayerProperties();
|
List<PropertyField> playerProperties = getPlayerProperties();
|
||||||
|
|
||||||
// Populate the dropdown with property names
|
// Populate the dropdown with property names
|
||||||
for (BuildingProperty property : playerProperties) {
|
for (PropertyField property : playerProperties) {
|
||||||
propertyOptions.add(property.getName());
|
propertyOptions.add(property.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,20 +147,26 @@ public class RepayMortage extends Dialog {
|
|||||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||||
|
|
||||||
|
// Set initial selection
|
||||||
|
if (!propertyOptions.isEmpty()) {
|
||||||
|
onDropdownSelectionChanged(propertySelector);
|
||||||
|
}
|
||||||
|
|
||||||
return dropdownContainer;
|
return dropdownContainer;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of properties owned by the current player.
|
* Retrieves the list of properties owned by the current player.
|
||||||
*
|
*
|
||||||
* @return List of BuildingProperty objects owned by the player.
|
* @return List of PropertyField objects owned by the player.
|
||||||
*/
|
*/
|
||||||
private List<BuildingProperty> getPlayerProperties() {
|
private List<PropertyField> getPlayerProperties() {
|
||||||
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
||||||
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
||||||
|
|
||||||
return boardManager.getPropertyFields(self.getProperties()).stream()
|
return boardManager.getPropertyFields(self.getProperties()).stream()
|
||||||
.filter(property -> property instanceof BuildingProperty)
|
.filter(property -> property instanceof PropertyField)
|
||||||
.map(property -> (BuildingProperty) property)
|
.map(property -> (PropertyField) property)
|
||||||
|
.filter(p -> p.isMortgaged())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +191,7 @@ public class RepayMortage extends Dialog {
|
|||||||
|
|
||||||
int cost = 0;
|
int cost = 0;
|
||||||
for (String s : selectedProperties) {
|
for (String s : selectedProperties) {
|
||||||
cost += ((BuildingProperty) app.getGameLogic().getBoardManager().getFieldByName(s)).getHousePrice();
|
cost += ((PropertyField) app.getGameLogic().getBoardManager().getFieldByName(s)).getHypo();
|
||||||
}
|
}
|
||||||
|
|
||||||
String display = String.join(" | ", selectedProperties);
|
String display = String.join(" | ", selectedProperties);
|
||||||
|
@ -21,7 +21,7 @@ import pp.dialog.Dialog;
|
|||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.message.client.BuyPropertyResponse;
|
import pp.monopoly.message.client.AlterProperty;
|
||||||
import pp.monopoly.model.fields.BoardManager;
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
@ -73,7 +73,7 @@ public class SellHouse extends Dialog {
|
|||||||
Container downContainer = sellhouseContainer.addChild(new Container());
|
Container downContainer = sellhouseContainer.addChild(new Container());
|
||||||
|
|
||||||
// Text, der auf der Karte steht
|
// Text, der auf der Karte steht
|
||||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen
|
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text")));
|
||||||
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||||
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
|
|
||||||
@ -99,9 +99,16 @@ public class SellHouse extends Dialog {
|
|||||||
confirmButton.setFontSize(32);
|
confirmButton.setFontSize(32);
|
||||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
// Send the "alter building" message to the server
|
AlterProperty msg = new AlterProperty("SellHouse");
|
||||||
//app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
|
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();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
@ -149,6 +156,11 @@ public class SellHouse extends Dialog {
|
|||||||
selectionDisplay = new TextField(""); // Create TextField for displaying selections
|
selectionDisplay = new TextField(""); // Create TextField for displaying selections
|
||||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||||
|
|
||||||
|
// Set initial selection
|
||||||
|
if (!propertyOptions.isEmpty()) {
|
||||||
|
onDropdownSelectionChanged(propertySelector);
|
||||||
|
}
|
||||||
|
|
||||||
return dropdownContainer;
|
return dropdownContainer;
|
||||||
}
|
}
|
||||||
@ -164,6 +176,7 @@ public class SellHouse 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(p -> app.getGameLogic().getBoardManager().canSell(p))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import com.simsilica.lemur.Axis;
|
|||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
import com.simsilica.lemur.ListBox;
|
|
||||||
import com.simsilica.lemur.Selector;
|
import com.simsilica.lemur.Selector;
|
||||||
import com.simsilica.lemur.TextField;
|
import com.simsilica.lemur.TextField;
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
@ -18,8 +17,10 @@ import pp.dialog.Dialog;
|
|||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
import pp.monopoly.message.client.AlterProperty;
|
||||||
import pp.monopoly.model.fields.BoardManager;
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
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.HashSet;
|
import java.util.HashSet;
|
||||||
@ -69,7 +70,7 @@ public class TakeMortage extends Dialog {
|
|||||||
Container downContainer = takeMortageContainer.addChild(new Container());
|
Container downContainer = takeMortageContainer.addChild(new Container());
|
||||||
|
|
||||||
// Text, der auf der Karte steht
|
// Text, der auf der Karte steht
|
||||||
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text"))); //TODO hier überall die entsprechenden Variablen einfügen
|
upContainer.addChild(new Label("„Grundstück wählen:", new ElementId("label-Text")));
|
||||||
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
upContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||||
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
upContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
|
|
||||||
@ -95,8 +96,10 @@ public class TakeMortage extends Dialog {
|
|||||||
confirmButton.setFontSize(32);
|
confirmButton.setFontSize(32);
|
||||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
// Send the "alter building" message to the server
|
AlterProperty msg = new AlterProperty("TakeMortage");
|
||||||
//app.getGameLogic().sendMessage(new AlterBuildingMessage(selected.getId(), false)); TODO Message an Server
|
msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
|
||||||
|
app.getGameLogic().send(msg);
|
||||||
|
close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
@ -127,10 +130,10 @@ public class TakeMortage extends Dialog {
|
|||||||
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
||||||
|
|
||||||
VersionedList<String> propertyOptions = new VersionedList<>();
|
VersionedList<String> propertyOptions = new VersionedList<>();
|
||||||
List<BuildingProperty> playerProperties = getPlayerProperties();
|
List<PropertyField> playerProperties = getPlayerProperties();
|
||||||
|
|
||||||
// Populate the dropdown with property names
|
// Populate the dropdown with property names
|
||||||
for (BuildingProperty property : playerProperties) {
|
for (PropertyField property : playerProperties) {
|
||||||
propertyOptions.add(property.getName());
|
propertyOptions.add(property.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,20 +148,26 @@ public class TakeMortage extends Dialog {
|
|||||||
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
selectionDisplay.setPreferredSize(new Vector3f(300, 30, 0));
|
||||||
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
dropdownContainer.addChild(selectionDisplay); // Add it to the dropdown container
|
||||||
|
|
||||||
|
// Set initial selection
|
||||||
|
if (!propertyOptions.isEmpty()) {
|
||||||
|
onDropdownSelectionChanged(propertySelector);
|
||||||
|
}
|
||||||
|
|
||||||
return dropdownContainer;
|
return dropdownContainer;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of properties owned by the current player.
|
* Retrieves the list of properties owned by the current player.
|
||||||
*
|
*
|
||||||
* @return List of BuildingProperty objects owned by the player.
|
* @return List of PropertyField objects owned by the player.
|
||||||
*/
|
*/
|
||||||
private List<BuildingProperty> getPlayerProperties() {
|
private List<PropertyField> getPlayerProperties() {
|
||||||
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
Player self = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId());
|
||||||
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
BoardManager boardManager = app.getGameLogic().getBoardManager();
|
||||||
|
|
||||||
return boardManager.getPropertyFields(self.getProperties()).stream()
|
return boardManager.getPropertyFields(self.getProperties()).stream()
|
||||||
.filter(property -> property instanceof BuildingProperty)
|
.filter(property -> property instanceof PropertyField)
|
||||||
.map(property -> (BuildingProperty) property)
|
.map(property -> (PropertyField) property)
|
||||||
|
.filter(p -> !p.isMortgaged())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +192,7 @@ public class TakeMortage extends Dialog {
|
|||||||
|
|
||||||
int cost = 0;
|
int cost = 0;
|
||||||
for (String s : selectedProperties) {
|
for (String s : selectedProperties) {
|
||||||
cost += ((BuildingProperty) app.getGameLogic().getBoardManager().getFieldByName(s)).getHousePrice();
|
cost += ((PropertyField) app.getGameLogic().getBoardManager().getFieldByName(s)).getHypo();
|
||||||
}
|
}
|
||||||
|
|
||||||
String display = String.join(" | ", selectedProperties);
|
String display = String.join(" | ", selectedProperties);
|
||||||
|
@ -307,8 +307,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
public void received(TradeReply msg) {
|
public void received(TradeReply msg) {
|
||||||
if (msg.isAccepted()) {
|
if (msg.isAccepted()) {
|
||||||
playSound(Sound.TRADE_ACCEPTED);
|
playSound(Sound.TRADE_ACCEPTED);
|
||||||
|
notifyListeners(new PopUpEvent("tradepos", msg));
|
||||||
} else {
|
} else {
|
||||||
playSound(Sound.TRADE_REJECTED);
|
playSound(Sound.TRADE_REJECTED);
|
||||||
|
notifyListeners(new PopUpEvent("tradeneg", msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,27 +382,32 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
public void received(AlterProperty msg, int from) {
|
public void received(AlterProperty msg, int from) {
|
||||||
Player sender = playerHandler.getPlayerById(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")) {
|
if (msg.getKeyword().equals("TakeMortage")) {
|
||||||
for (PropertyField field : sender.getPropertyFields()) {
|
for (PropertyField field : properties) {
|
||||||
field.setMortgaged(true);
|
field.setMortgaged(true);
|
||||||
sender.earnMoney(field.getHypo());
|
sender.earnMoney(field.getHypo());
|
||||||
}
|
}
|
||||||
} else if (msg.getKeyword().equals("RepayMortage")) {
|
} else if (msg.getKeyword().equals("RepayMortage")) {
|
||||||
for (PropertyField field : sender.getPropertyFields()) {
|
for (PropertyField field : properties) {
|
||||||
if(sender.getAccountBalance() >= field.getHypo()) {
|
if(sender.getAccountBalance() >= field.getHypo()) {
|
||||||
field.setMortgaged(false);
|
field.setMortgaged(false);
|
||||||
sender.pay(field.getHypo());
|
sender.pay(field.getHypo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(msg.getKeyword().equals("BuyHouse")) {
|
} else if(msg.getKeyword().equals("BuyHouse")) {
|
||||||
for (BuildingProperty field : sender.getPropertyFields().stream().filter(p -> p instanceof BuildingProperty).map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
for (BuildingProperty field : properties.stream().map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||||
if (boardManager.canBuild(field) && sender.getAccountBalance() >= field.getHousePrice()) {
|
if (boardManager.canBuild(field) && sender.getAccountBalance() >= field.getHousePrice()) {
|
||||||
field.build();
|
field.build();
|
||||||
sender.pay(field.getHousePrice());
|
sender.pay(field.getHousePrice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(msg.getKeyword().equals("SellHouse")) {
|
} else if(msg.getKeyword().equals("SellHouse")) {
|
||||||
for (BuildingProperty field : sender.getPropertyFields().stream().filter(p -> p instanceof BuildingProperty).map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
for (BuildingProperty field : properties.stream().map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||||
if (boardManager.canSell(field)) {
|
if (boardManager.canSell(field)) {
|
||||||
field.sell();
|
field.sell();
|
||||||
sender.earnMoney(field.getHousePrice());
|
sender.earnMoney(field.getHousePrice());
|
||||||
@ -420,11 +425,11 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
} 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")) {
|
} 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())) {
|
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));
|
bp.setOwner(playerHandler.getPlayerById(0));
|
||||||
playerHandler.getPlayerById(0).addProperty(bp.getId());
|
playerHandler.getPlayerById(0).addProperty(bp.getId());
|
||||||
}
|
}
|
||||||
|
playerHandler.getPlayerAtIndex(0).earnMoney(20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAllPlayers();
|
updateAllPlayers();
|
||||||
|
@ -10,7 +10,7 @@ import pp.monopoly.game.server.Player;
|
|||||||
@Serializable
|
@Serializable
|
||||||
public class BuildingProperty extends PropertyField {
|
public class BuildingProperty extends PropertyField {
|
||||||
|
|
||||||
private int houses;
|
private int houses = 2;
|
||||||
private final int housePrice;
|
private final int housePrice;
|
||||||
private final FieldColor color;
|
private final FieldColor color;
|
||||||
private final int rentFactor1 = 5;
|
private final int rentFactor1 = 5;
|
||||||
|
Loading…
Reference in New Issue
Block a user