mirror of
				https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
				synced 2025-11-01 00:49:02 +01:00 
			
		
		
		
	show popups
This commit is contained in:
		| @@ -61,6 +61,11 @@ public class BoardAppState extends MonopolyAppState { | ||||
|      */ | ||||
|     private BobTheBuilder bobTheBuilder; | ||||
|  | ||||
|     /** | ||||
|      * The pop-up manager for displaying messages and notifications. | ||||
|      */ | ||||
|     private PopUpManager popUpManager;; | ||||
|  | ||||
|     /** | ||||
|      * Initializes the state by setting up the sky, lights, and other visual components. | ||||
|      * This method is called when the state is first attached to the state manager. | ||||
| @@ -71,6 +76,7 @@ public class BoardAppState extends MonopolyAppState { | ||||
|     @Override | ||||
|     public void initialize(AppStateManager stateManager, Application application) { | ||||
|         super.initialize(stateManager, application); | ||||
|         popUpManager = new PopUpManager(getApp()); | ||||
|         viewNode.attachChild(sceneNode); | ||||
|         setupLights(); | ||||
|         setupSky(); | ||||
|   | ||||
| @@ -0,0 +1,97 @@ | ||||
| package pp.monopoly.client; | ||||
|  | ||||
| import java.util.Timer; | ||||
| import java.util.TimerTask; | ||||
|  | ||||
| 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; | ||||
| import pp.monopoly.client.gui.popups.FoodFieldCard; | ||||
| import pp.monopoly.client.gui.popups.GateFieldCard; | ||||
| 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.ReceivedRent; | ||||
| 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.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; | ||||
| import pp.monopoly.notification.EventCardEvent; | ||||
| import pp.monopoly.notification.GameEventListener; | ||||
| import pp.monopoly.notification.PopUpEvent; | ||||
|  | ||||
| public class PopUpManager implements GameEventListener { | ||||
|  | ||||
|     private final MonopolyApp app; | ||||
|  | ||||
|     public PopUpManager(MonopolyApp app) { | ||||
|         this.app = app; | ||||
|         app.getGameLogic().addListener(this); | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public void receivedEvent(PopUpEvent event) { | ||||
|         if (event.msg().equals("Buy")) { | ||||
|             Timer timer = new Timer(); | ||||
|             timer.schedule(new TimerTask() { | ||||
|                 @Override | ||||
|                 public void run() { | ||||
|                     app.enqueue(() -> { | ||||
|                         int field = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID(); | ||||
|                         Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field); | ||||
|  | ||||
|                         if (fieldObject instanceof BuildingProperty) { | ||||
|                             new BuildingPropertyCard(app).open(); | ||||
|                         } else if (fieldObject instanceof GateField) { | ||||
|                             new GateFieldCard(app).open(); | ||||
|                         } else if (fieldObject instanceof FoodField) { | ||||
|                             new FoodFieldCard(app).open(); | ||||
|                         } | ||||
|                     }); | ||||
|                 } | ||||
|             }, 2500); | ||||
|         } else if (event.msg().equals("Winner")) { | ||||
|             new WinnerPopUp(app).open(); | ||||
|         } else if (event.msg().equals("Looser")) { | ||||
|             new LooserPopUp(app).open(); | ||||
|         } else if (event.msg().equals("timeout")) { | ||||
|             new TimeOut(app).open(); | ||||
|         } else if (event.msg().equals("tradeRequest")) { | ||||
|             new ConfirmTrade(app).open(); | ||||
|         } else if (event.msg().equals("goingToJail")) { | ||||
|             new Gulag(app).open(); | ||||
|         } else if (event.msg().equals("NoMoneyWarning")) { | ||||
|             new NoMoneyWarning(app).open(); | ||||
|         } else if(event.msg().equals("rent")) { | ||||
|             new Rent(app, ( (NotificationMessage) event.message()).getRentOwner(), ( (NotificationMessage) event.message()).getRentAmount() ).open(); | ||||
|         } else if (event.msg().equals("jailtryagain")) { | ||||
|             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(); | ||||
|         } else if (event.msg().equals("ReceivedRent")) { | ||||
|             new ReceivedRent(app, ( (NotificationMessage) event.message()).getRentOwner(), ( (NotificationMessage) event.message()).getRentAmount() ).open(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void receivedEvent(EventCardEvent event) { | ||||
|         Timer timer = new Timer(); | ||||
|         timer.schedule(new TimerTask() { | ||||
|             @Override | ||||
|             public void run() { | ||||
|                 app.enqueue(() -> new EventCardPopup(app, event.description()).open()); | ||||
|             } | ||||
|         }, 2500); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user