diff --git a/Gamelib b/Gamelib index 1348e34..588633f 160000 --- a/Gamelib +++ b/Gamelib @@ -1 +1 @@ -Subproject commit 1348e342d6ec3685424244ceae6d920652239555 +Subproject commit 588633fe4627e274dd9b4b1f69b2fe5da17d976f diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/Lobby/Lobby.java b/Server/src/main/java/uulm/teamname/marvelous/server/Lobby/Lobby.java index a5be839..6edac7e 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/Lobby/Lobby.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/Lobby/Lobby.java @@ -6,9 +6,9 @@ import uulm.teamname.marvelous.gamelibrary.events.EventBuilder; import uulm.teamname.marvelous.gamelibrary.events.EventType; import uulm.teamname.marvelous.gamelibrary.gamelogic.EventObserver; import uulm.teamname.marvelous.gamelibrary.gamelogic.GameInstance; +import uulm.teamname.marvelous.gamelibrary.gamelogic.ParticipantType; import uulm.teamname.marvelous.gamelibrary.requests.Request; import uulm.teamname.marvelous.server.LobbyManager.LobbyConnection; -import uulm.teamname.marvelous.server.LobbyManager.MessageSource; import java.util.*; @@ -30,7 +30,7 @@ public class Lobby extends EventObserver { connection.broadcastEvents(events); } - public void receiveRequests(MessageSource source, Request[] requests) { + public void receiveRequests(ParticipantType source, Request[] requests) { ArrayList stateRelevant = new ArrayList<>(); for(Request request: requests) { @@ -39,7 +39,7 @@ public class Lobby extends EventObserver { stateRelevant.add(request); // these need to be checked all together by the game instance itself } case PauseStopRequest, PauseStartRequest, EndRoundRequest, DisconnectRequest, Req -> { - processRequest(request); + processRequest(source, request); return; // only one of these will ever be sent at once, and if that is the case, we wont have any other state relevant events } } @@ -51,7 +51,7 @@ public class Lobby extends EventObserver { } } - private void processRequest(Request request) { + private void processRequest(ParticipantType source, Request request) { //TODO: handle the rest of the requests switch(request.type) { case PauseStopRequest -> { diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/LobbyConnection.java b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/LobbyConnection.java index c4fba19..0768ff4 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/LobbyConnection.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/LobbyConnection.java @@ -2,6 +2,7 @@ package uulm.teamname.marvelous.server.LobbyManager; import org.java_websocket.WebSocket; import uulm.teamname.marvelous.gamelibrary.events.Event; +import uulm.teamname.marvelous.gamelibrary.gamelogic.ParticipantType; import uulm.teamname.marvelous.server.Lobby.Lobby; import java.util.HashSet; @@ -100,8 +101,8 @@ public class LobbyConnection { // Methods to send events - public void sendEvents(MessageSource target, Event... events) { - MessageRelay.getInstance().sendMessage(this, events, target); + public void sendEvents(ParticipantType target, Event... events) { + MessageRelay.getInstance().sendMessage(this, target, events); } public void broadcastEvents(Event... events) { diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageRelay.java b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageRelay.java index 9b0fd25..d55c6e1 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageRelay.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageRelay.java @@ -2,6 +2,7 @@ package uulm.teamname.marvelous.server.LobbyManager; import org.java_websocket.WebSocket; import uulm.teamname.marvelous.gamelibrary.events.Event; +import uulm.teamname.marvelous.gamelibrary.gamelogic.ParticipantType; import uulm.teamname.marvelous.server.Lobby.Lobby; import java.util.HashMap; @@ -29,14 +30,16 @@ public class MessageRelay { // TODO: send to target lobby } - public void sendMessage (LobbyConnection origin, Event[] events, MessageSource target) { + public void sendMessage (LobbyConnection origin, ParticipantType target, Event[] events) { switch (target) { - case Player1 -> { + } case Player2 -> { + } case Spectator -> { + } } } diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageSource.java b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageSource.java deleted file mode 100644 index f3a88ff..0000000 --- a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageSource.java +++ /dev/null @@ -1,7 +0,0 @@ -package uulm.teamname.marvelous.server.LobbyManager; - -public enum MessageSource { - Player1, - Player2, - Spectator, -}