mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-12 04:21:08 +02:00
Compare commits
4 Commits
09e12fc610
...
a753017fcd
Author | SHA1 | Date | |
---|---|---|---|
|
a753017fcd | ||
|
5522be228b | ||
|
3b729c9a04 | ||
|
eda2fcd327 |
@ -279,7 +279,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
//logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen
|
||||
private void handleB(boolean isPressed) {
|
||||
if (isPressed) {
|
||||
Dialog tmp = new GulagInfo(this);
|
||||
Dialog tmp = new GulagInfo(this, 3);
|
||||
tmp.open();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import pp.monopoly.client.gui.popups.EventCardPopup;
|
||||
import pp.monopoly.client.gui.popups.FoodFieldCard;
|
||||
import pp.monopoly.client.gui.popups.GateFieldCard;
|
||||
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.Rent;
|
||||
@ -380,8 +381,11 @@ public class TestWorld implements GameEventListener {
|
||||
new NoMoneyWarning(app).open();
|
||||
} else if(event.msg().equals("rent")) {
|
||||
new Rent(app, ( (NotificationMessage) event.message()).getRentOwner(), ( (NotificationMessage) event.message()).getRentAmount() ).open();
|
||||
} else if (event.msg().equals("jailtryagain")) {
|
||||
new GulagInfo(app, 1).open();
|
||||
} else if (event.msg().equals("jailpay")) {
|
||||
new GulagInfo(app, 3).open();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,8 +6,8 @@ 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;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import com.simsilica.lemur.core.VersionedList;
|
||||
@ -19,9 +19,9 @@ import pp.monopoly.client.gui.SettingsMenu;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.model.fields.BoardManager;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.model.fields.PropertyField;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@ -36,6 +36,8 @@ public class BuyHouse extends Dialog {
|
||||
private VersionedReference<Set<Integer>> selectionRef;
|
||||
private Selector<String> propertySelector;
|
||||
private BuildingProperty selectedProperty;
|
||||
private TextField selectionDisplay; // TextField to display selections
|
||||
private final List<String> selectedProperties = new ArrayList<>();
|
||||
|
||||
public BuyHouse(MonopolyApp app) {
|
||||
super(app.getDialogManager());
|
||||
@ -134,22 +136,23 @@ public class BuyHouse extends Dialog {
|
||||
}
|
||||
|
||||
propertySelector = new Selector<>(propertyOptions, "glass");
|
||||
dropdownContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Orange));
|
||||
dropdownContainer.addChild(propertySelector);
|
||||
// Track selection changes
|
||||
|
||||
selectionRef = propertySelector.getSelectionModel().createReference();
|
||||
|
||||
// Initialize the selection display here
|
||||
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(propertyOptions.get(0), playerProperties);
|
||||
}
|
||||
|
||||
// Track selection changes
|
||||
selectionRef = propertySelector.getSelectionModel().createReference();
|
||||
|
||||
|
||||
|
||||
return dropdownContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of properties owned by the current player.
|
||||
*
|
||||
@ -184,10 +187,37 @@ public class BuyHouse extends Dialog {
|
||||
.orElse(null);
|
||||
|
||||
if (selectedProperty != null) {
|
||||
System.out.println("Selected property: " + selectedProperty.getName());
|
||||
// Add property to the selected list if not already added
|
||||
if (!selectedProperties.contains(selectedProperty.getName())) {
|
||||
selectedProperties.add(selectedProperty.getName());
|
||||
}
|
||||
|
||||
// Update the selection display text field
|
||||
updateSelectionDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the selection display text field with the selected properties.
|
||||
*/
|
||||
private void updateSelectionDisplay() {
|
||||
if (selectionDisplay != null) {
|
||||
String selections = String.join("|", selectedProperties);
|
||||
selectionDisplay.setText(selections);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
if (selectionRef.update()) {
|
||||
String selected = propertySelector.getSelectionModel().getObject().toString();
|
||||
if (selected != null) {
|
||||
onDropdownSelectionChanged(selected, getPlayerProperties());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
app.getGuiNode().detachChild(buyHouseContainer);
|
||||
|
@ -9,6 +9,7 @@ import com.simsilica.lemur.style.ElementId;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.client.gui.SettingsMenu;
|
||||
import pp.monopoly.message.client.NotificationAnswer;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
/**
|
||||
@ -20,7 +21,7 @@ public class GulagInfo extends Dialog {
|
||||
private final Container backgroundContainer;
|
||||
|
||||
|
||||
public GulagInfo(MonopolyApp app) {
|
||||
public GulagInfo(MonopolyApp app, int trys) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
|
||||
@ -50,12 +51,6 @@ public class GulagInfo extends Dialog {
|
||||
propertyValuesContainer.addChild(new Label("- löst eine Gulag-Frei-Karte ein", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("- wartest 3 Runden und bezahlst dann", new ElementId("label-Text")));// Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("- oder du würfelst einen Pasch", new ElementId("label-Text")));
|
||||
/*propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("- ", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("- EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("- Sonderkaten", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));// Leerzeile
|
||||
propertyValuesContainer.addChild(new Label("tauschen, willst du das Angebot annehmen?", new ElementId("label-Text")));*/
|
||||
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
|
||||
@ -64,6 +59,7 @@ public class GulagInfo extends Dialog {
|
||||
payButton.setFontSize(32);
|
||||
payButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
app.getGameLogic().send(new NotificationAnswer("PayJail"));
|
||||
close();
|
||||
}));
|
||||
// Ereigniskarte-Button
|
||||
@ -71,6 +67,7 @@ public class GulagInfo extends Dialog {
|
||||
eventCardButton.setFontSize(32);
|
||||
eventCardButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
app.getGameLogic().send(new NotificationAnswer("UseJailCard"));
|
||||
close();
|
||||
}));
|
||||
// Schließen-Button
|
||||
@ -95,6 +92,14 @@ public class GulagInfo extends Dialog {
|
||||
7
|
||||
);
|
||||
|
||||
if(app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getNumJailCard() == 0) {
|
||||
eventCardButton.setEnabled(false);
|
||||
}
|
||||
|
||||
if(trys == 3) {
|
||||
closeButton.setEnabled(false);
|
||||
}
|
||||
|
||||
app.getGuiNode().attachChild(gulagInfoContainer);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class Rent extends Dialog {
|
||||
container.setPreferredSize(new Vector3f(550, 250, 10));
|
||||
|
||||
// Title
|
||||
Label title = container.addChild(new Label("Miete!", new ElementId("label-Bold")));
|
||||
Label title = container.addChild(new Label("Miete!", new ElementId("warning-title")));
|
||||
title.setFontSize(48);
|
||||
title.setColor(ColorRGBA.Black);
|
||||
|
||||
|
@ -347,6 +347,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
notifyListeners(new PopUpEvent(msg.getKeyWord(), msg));
|
||||
} else if(msg.getKeyWord().equals("NoMoneyWarning")) {
|
||||
notifyListeners(new PopUpEvent("NoMoneyWarning", msg));
|
||||
} else if (msg.getKeyWord().equals("jailpay")) {
|
||||
notifyListeners(new PopUpEvent("jailpay", msg));
|
||||
} else if (msg.getKeyWord().equals("jailtryagain")) {
|
||||
notifyListeners(new PopUpEvent("jailtryagain", msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,9 @@ public class Player implements FieldVisitor<Void>{
|
||||
System.out.println("State: "+state.getClass().getName());
|
||||
if(!(state instanceof JailState)) {
|
||||
state = new ActiveState();
|
||||
} else {
|
||||
String message = (((JailState)state).remainingAttempts <= 0) ? "jailpay" : "jailtryagain";
|
||||
handler.getLogic().send(this, new NotificationMessage(message));
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,7 +442,6 @@ public class Player implements FieldVisitor<Void>{
|
||||
public void moveToJail() {
|
||||
setPosition(10); // Jail position on the board
|
||||
state = new JailState();
|
||||
System.out.println("JAIL EVENT");
|
||||
handler.getLogic().send(this, new JailEvent(true));
|
||||
}
|
||||
|
||||
@ -481,6 +483,7 @@ public class Player implements FieldVisitor<Void>{
|
||||
return total;
|
||||
}
|
||||
|
||||
// private static int c = 0;
|
||||
/**
|
||||
* Inner class for dice functionality in the game.
|
||||
* Rolls random dice values.
|
||||
@ -495,7 +498,13 @@ public class Player implements FieldVisitor<Void>{
|
||||
*/
|
||||
private static int rollDice() {
|
||||
return random.nextInt(6) + 1;
|
||||
// return 3;
|
||||
|
||||
// c++;
|
||||
// if(c < 7) {
|
||||
// return 3;
|
||||
// } else {
|
||||
// return (c%4)+1;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -612,12 +621,6 @@ public class Player implements FieldVisitor<Void>{
|
||||
state = new ActiveState();
|
||||
} else {
|
||||
remainingAttempts--;
|
||||
if (remainingAttempts <= 0) {
|
||||
handler.getLogic().send(Player.this, new NotificationMessage("jailpay"));
|
||||
if(getOutOfJailCard == 0) payBail();
|
||||
} else {
|
||||
handler.getLogic().send(Player.this, new NotificationMessage("jailtryagain"));
|
||||
}
|
||||
}
|
||||
System.out.println("Feld:"+fieldID);
|
||||
return rollResult;
|
||||
|
@ -234,10 +234,10 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
@Override
|
||||
public void received(RollDice msg, int from) {
|
||||
Player player = playerHandler.getPlayerById(from);
|
||||
if (player != null) {
|
||||
if (player != null && player == playerHandler.getPlayerAtIndex(0)) {
|
||||
send(player, player.rollDice());
|
||||
updateAllPlayers();
|
||||
}
|
||||
updateAllPlayers();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -414,12 +414,11 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
|
||||
@Override
|
||||
public void received(NotificationAnswer msg, int from) {
|
||||
if(msg.getKeyword().equals("UseJailCard")) {
|
||||
if(msg.getA().equals("UseJailCard")) {
|
||||
playerHandler.getPlayerById(from).useJailCard();
|
||||
} else if (msg.getKeyword().equals("PayJail")) {
|
||||
} else if (msg.getA().equals("PayJail")) {
|
||||
playerHandler.getPlayerById(from).payBail();
|
||||
}
|
||||
|
||||
updateAllPlayers();
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,16 @@ import com.jme3.network.serializing.Serializable;
|
||||
@Serializable
|
||||
public class NotificationAnswer extends ClientMessage{
|
||||
|
||||
private String keyword;
|
||||
private String A;
|
||||
|
||||
private NotificationAnswer() {}
|
||||
|
||||
public NotificationAnswer(String keyword) {
|
||||
this.keyword = keyword;
|
||||
public NotificationAnswer(String A) {
|
||||
this.A = A;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
public String getA() {
|
||||
return A;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,7 @@ import pp.monopoly.message.client.AlterProperty;
|
||||
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||
import pp.monopoly.message.client.ClientMessage;
|
||||
import pp.monopoly.message.client.EndTurn;
|
||||
import pp.monopoly.message.client.NotificationAnswer;
|
||||
import pp.monopoly.message.client.PlayerReady;
|
||||
import pp.monopoly.message.client.RollDice;
|
||||
import pp.monopoly.message.client.TradeOffer;
|
||||
@ -175,6 +176,7 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
||||
Serializer.registerClass(TradeReply.class);
|
||||
Serializer.registerClass(TradeHandler.class);
|
||||
Serializer.registerClass(NotificationMessage.class);
|
||||
Serializer.registerClass(NotificationAnswer.class);
|
||||
Serializer.registerClass(JailEvent.class);
|
||||
Serializer.registerClass(AlterProperty.class);
|
||||
Serializer.registerClass(GameOver.class);
|
||||
@ -188,6 +190,8 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
||||
myServer.addMessageListener(this, TradeOffer.class);
|
||||
myServer.addMessageListener(this, TradeResponse.class);
|
||||
myServer.addMessageListener(this, ViewAssetsRequest.class);
|
||||
myServer.addMessageListener(this, AlterProperty.class);
|
||||
myServer.addMessageListener(this, NotificationAnswer.class);
|
||||
myServer.addConnectionListener(this);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user