diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java index f754eeb..8aff687 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TestWorld.java @@ -12,6 +12,7 @@ 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; @@ -21,12 +22,14 @@ 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; @@ -385,7 +388,11 @@ 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 diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java index fdbd22d..f2fb28f 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/AcceptTrade.java @@ -13,6 +13,8 @@ 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 @@ -25,7 +27,7 @@ public class AcceptTrade extends Dialog { - public AcceptTrade(MonopolyApp app) { + public AcceptTrade(MonopolyApp app, TradeReply msg) { super(app.getDialogManager()); this.app = app; @@ -55,7 +57,7 @@ public class AcceptTrade extends Dialog { // Text, der im Popup steht 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("Der Handel wurde angenommen", new ElementId("label-Text"))); 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 Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button"))); quitButton.setFontSize(32); - quitButton.addClickCommands(source -> close()); + quitButton.addClickCommands(source -> ifTopDialog(() -> { + app.getGameLogic().playSound(Sound.BUTTON); + close(); + })); // Zentriere das Popup diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java index 2caa095..4cd9c23 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java @@ -13,6 +13,8 @@ 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 @@ -25,7 +27,7 @@ public class RejectTrade extends Dialog { - public RejectTrade(MonopolyApp app) { + public RejectTrade(MonopolyApp app, TradeReply msg) { super(app.getDialogManager()); this.app = app; @@ -55,7 +57,7 @@ public class RejectTrade extends Dialog { // Text, der im Popup steht 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("Der Handel wurde abgelehnt", new ElementId("label-Text"))); 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 Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button"))); quitButton.setFontSize(32); - quitButton.addClickCommands(source -> close()); + quitButton.addClickCommands(source -> ifTopDialog(() -> { + app.getGameLogic().playSound(Sound.BUTTON); + close(); + })); // Zentriere das Popup diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index fb99bca..32725de 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -307,8 +307,10 @@ 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)); } }