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

View File

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

View File

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