feat(ui): add Lobby and Main Menu Body (#38)

Co-authored-by: LQ63 <lkhermann@web.de>
Reviewed-on: #38
Co-authored-by: Janis <janis.e.20@gmx.de>
Co-committed-by: Janis <janis.e.20@gmx.de>
This commit is contained in:
2025-11-06 09:03:09 +01:00
committed by Janis
parent 44c88c8f60
commit 051e7406e3
16 changed files with 474 additions and 145 deletions

View File

@@ -88,12 +88,12 @@ class GameLobby private(
* Remove the user from the game lobby.
* @param user the user who wants to leave the game.
*/
def leaveGame(user: User): Unit = {
val sessionOpt = users.get(user.id)
def leaveGame(userId: UUID): Unit = {
val sessionOpt = users.get(userId)
if (sessionOpt.isEmpty) {
throw new NotInThisGameException("You are not in this game!")
}
users.remove(user.id)
users.remove(userId)
}
/**
@@ -176,6 +176,14 @@ class GameLobby private(
getPlayerBySession(getUserSession(user.id))
}
def getPlayers: mutable.Map[UUID, UserSession] = {
users.clone()
}
def getLogic: GameLogic = {
logic
}
private def getPlayerBySession(userSession: UserSession): AbstractPlayer = {
val playerOption = getMatch.totalplayers.find(_.id == userSession.id)
if (playerOption.isEmpty) {