TradeReplay popup

This commit is contained in:
Johannes Schmelz 2024-12-02 03:16:50 +01:00
parent 13754c843a
commit bcf4956d2d
4 changed files with 26 additions and 7 deletions

View File

@ -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,6 +388,10 @@ 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();
}
}

View File

@ -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

View File

@ -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

View File

@ -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));
}
}