du kommst ins Gulag Popup

This commit is contained in:
Johannes Schmelz 2024-12-01 20:31:29 +01:00
parent b702e3a14d
commit 11f4560745
6 changed files with 52 additions and 9 deletions

View File

@ -292,6 +292,8 @@ public class TestWorld implements GameEventListener {
new TimeOut(app).open(); new TimeOut(app).open();
} else if(event.msg().equals("tradeRequest")) { } else if(event.msg().equals("tradeRequest")) {
new ConfirmTrade(app).open(); new ConfirmTrade(app).open();
} else if (event.msg().equals("goingToJail")) {
new Gulag(app).open();
} }
} }

View File

@ -261,10 +261,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
@Override @Override
public void received(JailEvent msg) { public void received(JailEvent msg) {
if (msg.isGoingToJail()) { if (msg.isGoingToJail()) {
playSound(Sound.GULAG); playSound(Sound.GULAG);
} else { notifyListeners(new PopUpEvent("goingToJail", msg));
System.out.println("NO MORE JAIL");
} }
} }
@ -345,6 +343,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
public void received(NotificationMessage msg) { public void received(NotificationMessage msg) {
if (msg.getKeyWord().equals("rent")) { if (msg.getKeyWord().equals("rent")) {
notifyListeners(new PopUpEvent("rent", msg)); notifyListeners(new PopUpEvent("rent", msg));
} else if (msg.getKeyWord().equals("jailpay")) {
notifyListeners(new PopUpEvent(msg.getKeyWord(), msg));
} }
} }
} }

View File

@ -624,10 +624,7 @@ public class Player implements FieldVisitor<Void>{
public void payBail() { public void payBail() {
if (accountBalance >= 500) { if (accountBalance >= 500) {
pay(500); pay(500);
handler.getLogic().send(Player.this, new NotificationMessage(""));
state = new ActiveState(); state = new ActiveState();
} else {
handler.getLogic().send(Player.this, new NotificationMessage(""));
} }
} }
@ -635,10 +632,7 @@ public class Player implements FieldVisitor<Void>{
public void useJailCard() { public void useJailCard() {
if (getOutOfJailCard > 0) { if (getOutOfJailCard > 0) {
removeJailCard(); removeJailCard();
handler.getLogic().send(Player.this, new NotificationMessage(""));
state = new ActiveState(); state = new ActiveState();
} else {
handler.getLogic().send(Player.this, new NotificationMessage(""));
} }
} }
} }

View File

@ -14,6 +14,7 @@ import pp.monopoly.message.client.AlterProperty;
import pp.monopoly.message.client.BuyPropertyResponse; import pp.monopoly.message.client.BuyPropertyResponse;
import pp.monopoly.message.client.ClientInterpreter; import pp.monopoly.message.client.ClientInterpreter;
import pp.monopoly.message.client.EndTurn; import pp.monopoly.message.client.EndTurn;
import pp.monopoly.message.client.NotificationAnswer;
import pp.monopoly.message.client.PlayerReady; import pp.monopoly.message.client.PlayerReady;
import pp.monopoly.message.client.RollDice; import pp.monopoly.message.client.RollDice;
import pp.monopoly.message.client.TradeOffer; import pp.monopoly.message.client.TradeOffer;
@ -400,5 +401,18 @@ public class ServerGameLogic implements ClientInterpreter {
} }
} }
} }
updateAllPlayers();
}
@Override
public void received(NotificationAnswer msg, int from) {
if(msg.getKeyword().equals("UseJailCard")) {
playerHandler.getPlayerById(from).useJailCard();
} else if (msg.getKeyword().equals("PayJail")) {
playerHandler.getPlayerById(from).payBail();
}
updateAllPlayers();
} }
} }

View File

@ -74,4 +74,12 @@ public interface ClientInterpreter {
* @param from the connection ID from which the message was received * @param from the connection ID from which the message was received
*/ */
void received(AlterProperty msg, int from); void received(AlterProperty msg, int from);
/**
* Processes a received NotificationAnswer.
*
* @param msg the NotificationAnswer to be processed
* @param from the connection ID from which the message was received
*/
void received(NotificationAnswer msg, int from);
} }

View File

@ -0,0 +1,25 @@
package pp.monopoly.message.client;
import com.jme3.network.serializing.Serializable;
@Serializable
public class NotificationAnswer extends ClientMessage{
private String keyword;
private NotificationAnswer() {}
public NotificationAnswer(String keyword) {
this.keyword = keyword;
}
public String getKeyword() {
return keyword;
}
@Override
public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from);
}
}