added trigger for winner looser popup

This commit is contained in:
Johannes Schmelz 2024-11-29 06:23:08 +01:00
parent 2d9cd0e4e1
commit b0c21dfcb8
3 changed files with 12 additions and 8 deletions

View File

@ -7,6 +7,8 @@ import pp.monopoly.client.gui.popups.BuyCard;
import pp.monopoly.client.gui.popups.EventCard;
import pp.monopoly.client.gui.popups.FoodFieldCard;
import pp.monopoly.client.gui.popups.GateFieldCard;
import pp.monopoly.client.gui.popups.LooserPopUp;
import pp.monopoly.client.gui.popups.WinnerPopUp;
import pp.monopoly.game.server.Player;
import pp.monopoly.model.fields.BuildingProperty;
import pp.monopoly.model.fields.FoodField;
@ -130,8 +132,7 @@ public class TestWorld implements GameEventListener{
@Override
public void receivedEvent(PopUpEvent event) {
System.err.println("Trigger ?");
// if (event.desc() == "BuyCard") {
if(event.msg().equals("Buy")) {
int field = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();
Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field);
@ -142,6 +143,11 @@ public class TestWorld implements GameEventListener{
} else if (fieldObject instanceof FoodField) {
new FoodFieldCard(app).open();
}
} else if(event.msg().equals("Winner")) {
new WinnerPopUp(app).open();
} else if(event.msg().equals("Looser")) {
new LooserPopUp(app).open();
}
}
@Override

View File

@ -226,12 +226,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
@Override
public void received(GameOver msg) {
if (msg.isWinner()) {
//Winner popup
notifyListeners(new PopUpEvent("Winner"));
playSound(Sound.WINNER);
} else {
// Looser popup
notifyListeners(new PopUpEvent("Looser"));
playSound(Sound.LOSER);
}
}
@ -333,6 +331,6 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
@Override
public void received(BuyPropertyRequest msg) {
notifyListeners(new PopUpEvent());
notifyListeners(new PopUpEvent("Buy"));
}
}

View File

@ -1,6 +1,6 @@
package pp.monopoly.notification;
public record PopUpEvent() implements GameEvent{
public record PopUpEvent(String msg) implements GameEvent{
@Override
public void notifyListener(GameEventListener listener) {