fix: replace duplicate class with ParticipantType
This commit is contained in:
		
							
								
								
									
										2
									
								
								Gamelib
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								Gamelib
									
									
									
									
									
								
							 Submodule Gamelib updated: 1348e342d6...588633fe46
									
								
							@ -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<Request> 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 -> {
 | 
			
		||||
 | 
			
		||||
@ -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) {
 | 
			
		||||
 | 
			
		||||
@ -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 -> {
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,7 +0,0 @@
 | 
			
		||||
package uulm.teamname.marvelous.server.LobbyManager;
 | 
			
		||||
 | 
			
		||||
public enum MessageSource {
 | 
			
		||||
    Player1,
 | 
			
		||||
    Player2,
 | 
			
		||||
    Spectator,
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user