From 7f4e5cc1cb37b99b734ab68b48caedfac30c7549 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Thu, 3 Jun 2021 23:40:17 +0200 Subject: [PATCH] refactor: used ParticipantType from Gamelib --- Gamelib | 2 +- .../uulm/teamname/marvelous/server/ParticipantType.java | 9 --------- .../java/uulm/teamname/marvelous/server/lobby/Lobby.java | 4 ++-- .../uulm/teamname/marvelous/server/lobby/RoundTimer.java | 3 ++- .../server/lobby/pipelining/DisconnectSegment.java | 2 +- .../marvelous/server/lobbymanager/LobbyConnection.java | 2 +- .../marvelous/server/lobbymanager/MessageRelay.java | 4 ++-- .../marvelous/server/lobbymanager/Participant.java | 2 +- 8 files changed, 10 insertions(+), 18 deletions(-) delete mode 100644 Server/src/main/java/uulm/teamname/marvelous/server/ParticipantType.java diff --git a/Gamelib b/Gamelib index d4e0ed2..78d3fb8 160000 --- a/Gamelib +++ b/Gamelib @@ -1 +1 @@ -Subproject commit d4e0ed23bcef8212b38050388afd907b9d50a7f1 +Subproject commit 78d3fb84d0d9cf34ce5d206df1b312a8f122246e diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/ParticipantType.java b/Server/src/main/java/uulm/teamname/marvelous/server/ParticipantType.java deleted file mode 100644 index 7d614e5..0000000 --- a/Server/src/main/java/uulm/teamname/marvelous/server/ParticipantType.java +++ /dev/null @@ -1,9 +0,0 @@ -package uulm.teamname.marvelous.server; - -/** Specifies a participant type. */ -public enum ParticipantType { - None, - Player1, - Player2, - Spectator -} 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 31cf498..0e1949e 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 @@ -5,7 +5,7 @@ import uulm.teamname.marvelous.gamelibrary.events.Event; import uulm.teamname.marvelous.gamelibrary.events.EventBuilder; import uulm.teamname.marvelous.gamelibrary.events.EventType; import uulm.teamname.marvelous.gamelibrary.gamelogic.GameInstance; -import uulm.teamname.marvelous.server.ParticipantType; +import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType; import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig; import uulm.teamname.marvelous.gamelibrary.config.PartyConfig; import uulm.teamname.marvelous.gamelibrary.config.ScenarioConfig; @@ -140,7 +140,7 @@ public class Lobby { public void generateWin(Participant winner){ connection.broadcastEvents( new EventBuilder(EventType.WinEvent) - .withPlayerWon(winner.type.equals(ParticipantType.Player1) ? 1 : 2) + .withPlayerWon(winner.type.equals(ParticipantType.PlayerOne) ? 1 : 2) .buildGameStateEvent(), new EventBuilder(EventType.DisconnectEvent) .buildGameStateEvent()); diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/RoundTimer.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/RoundTimer.java index 1eb9d83..232031a 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/RoundTimer.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/RoundTimer.java @@ -1,6 +1,7 @@ package uulm.teamname.marvelous.server.lobby; -import uulm.teamname.marvelous.server.ParticipantType; +import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType; +import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType; import uulm.teamname.marvelous.server.lobbymanager.Participant; import java.util.Timer; diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/DisconnectSegment.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/DisconnectSegment.java index 93f62a2..9a507f9 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/DisconnectSegment.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/DisconnectSegment.java @@ -2,7 +2,7 @@ package uulm.teamname.marvelous.server.lobby.pipelining; import org.tinylog.Logger; import uulm.teamname.marvelous.gamelibrary.events.Event; -import uulm.teamname.marvelous.server.ParticipantType; +import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType; import uulm.teamname.marvelous.gamelibrary.requests.RequestType; import uulm.teamname.marvelous.server.lobby.Lobby; 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 9c4d978..719faca 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 @@ -1,7 +1,7 @@ package uulm.teamname.marvelous.server.lobbymanager; import uulm.teamname.marvelous.gamelibrary.events.Event; -import uulm.teamname.marvelous.server.ParticipantType; +import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType; import uulm.teamname.marvelous.server.lobby.Lobby; import java.util.HashSet; 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 45d266c..e9e1703 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 @@ -30,10 +30,10 @@ public class MessageRelay { public void sendMessage (LobbyConnection origin, Participant recipient, Event[] events) { switch (recipient.type) { - case Player1 -> { + case PlayerOne -> { } - case Player2 -> { + case PlayerTwo -> { } case Spectator -> { diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/Participant.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/Participant.java index 6fed4de..bd25a11 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/Participant.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/Participant.java @@ -1,7 +1,7 @@ package uulm.teamname.marvelous.server.lobbymanager; import org.java_websocket.WebSocket; -import uulm.teamname.marvelous.server.ParticipantType; +import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType; import java.util.Objects;