miete erhalten popup

This commit is contained in:
Johannes Schmelz
2024-12-03 00:58:01 +01:00
parent 031ac52670
commit 831974cb63
4 changed files with 186 additions and 13 deletions

View File

@@ -352,6 +352,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
notifyListeners(new PopUpEvent("jailpay", msg));
} else if (msg.getKeyWord().equals("jailtryagain")) {
notifyListeners(new PopUpEvent("jailtryagain", msg));
} else if(msg.getKeyWord().equals("ReceivedRent")) {
notifyListeners(new PopUpEvent("ReceivedRent", msg));
}
}
}

View File

@@ -331,6 +331,13 @@ public class Player implements FieldVisitor<Void>{
state.useJailCard();
}
private void sendRentNotification(String keyword, Player player, int amount) {
NotificationMessage msg = new NotificationMessage(keyword);
msg.setRentAmount(amount);
msg.setRentOwnerId(player.getName());
getHandler().getLogic().send(player, msg);
}
@Override
public Void visit(BuildingProperty field) {
if(field.getOwner() == null) {
@@ -340,10 +347,8 @@ public class Player implements FieldVisitor<Void>{
int rent = field.calcRent();
field.getOwner().earnMoney(rent);
pay(rent);
NotificationMessage msg = new NotificationMessage("rent");
msg.setRentAmount(rent);
msg.setRentOwnerId(field.getOwner().getName());
getHandler().getLogic().send(this, msg);
sendRentNotification("rent", field.getOwner(), rent);
sendRentNotification("ReceivedRent", this, rent);
}
return null;
}
@@ -360,10 +365,8 @@ public class Player implements FieldVisitor<Void>{
int rent = rollResult.calcTotal()*factor;
field.getOwner().earnMoney(rent);
pay(rent);
NotificationMessage msg = new NotificationMessage("rent");
msg.setRentAmount(rent);
msg.setRentOwnerId(field.getOwner().getName());
getHandler().getLogic().send(this, msg);
sendRentNotification("rent", field.getOwner(), rent);
sendRentNotification("ReceivedRent", this, rent);
}
return null;
}
@@ -377,10 +380,8 @@ public class Player implements FieldVisitor<Void>{
field.getOwner().earnMoney(rent);
pay(rent);
NotificationMessage msg = new NotificationMessage("rent");
msg.setRentAmount(rent);
msg.setRentOwnerId(field.getOwner().getName());
getHandler().getLogic().send(this, msg);
sendRentNotification("rent", field.getOwner(), rent);
sendRentNotification("ReceivedRent", this, rent);
}
return null;
}