summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java b/src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java
index 3561161b..dce824ad 100644
--- a/src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java
+++ b/src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java
@@ -4,7 +4,6 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import org.luxons.sevenwonders.errors.UserInputException;
import org.luxons.sevenwonders.game.Lobby;
import org.luxons.sevenwonders.game.Player;
import org.luxons.sevenwonders.game.data.GameDefinitionLoader;
@@ -16,9 +15,7 @@ public class LobbyRepository {
private final GameDefinitionLoader gameDefinitionLoader;
- private Map<String, Lobby> lobbies = new HashMap<>();
-
- private Map<Long, Lobby> lobbiesById = new HashMap<>();
+ private Map<Long, Lobby> lobbies = new HashMap<>();
private long lastGameId = 0;
@@ -32,18 +29,14 @@ public class LobbyRepository {
}
public Lobby create(String gameName, Player owner) {
- if (lobbies.containsKey(gameName)) {
- throw new GameNameAlreadyUsedException(gameName);
- }
long id = lastGameId++;
Lobby lobby = new Lobby(id, gameName, owner, gameDefinitionLoader.getGameDefinition());
- lobbies.put(gameName, lobby);
- lobbiesById.put(id, lobby);
+ lobbies.put(id, lobby);
return lobby;
}
public Lobby find(long lobbyId) {
- Lobby lobby = lobbiesById.get(lobbyId);
+ Lobby lobby = lobbies.get(lobbyId);
if (lobby == null) {
throw new LobbyNotFoundException(String.valueOf(lobbyId));
}
@@ -55,10 +48,4 @@ public class LobbyRepository {
super("Lobby not found for game '" + name + "'");
}
}
-
- private static class GameNameAlreadyUsedException extends UserInputException {
- GameNameAlreadyUsedException(String name) {
- super("Game name '" + name + "' already exists");
- }
- }
}
bgstack15