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

@@ -8,6 +8,7 @@ import model.sessions.{PlayerSession, UserSession}
import play.api.*
import play.api.mvc.*
import java.util.UUID
import javax.inject.*
import scala.util.Try
@@ -28,11 +29,11 @@ class IngameController @Inject()(
game match {
case Some(g) =>
g.logic.getCurrentState match {
case Lobby => Ok("Lobby: " + gameId)
case Lobby => Ok(views.html.lobby.lobby(Some(request.user), g))
case InGame =>
Ok(views.html.ingame.ingame(
g.getPlayerByUser(request.user),
g.logic
g
))
case SelectTrump =>
Ok(views.html.ingame.selecttrump(
@@ -63,7 +64,7 @@ class IngameController @Inject()(
}
}
if (result.isSuccess) {
NoContent
Redirect(routes.IngameController.game(gameId))
} else {
val throwable = result.failed.get
throwable match {
@@ -78,6 +79,16 @@ class IngameController @Inject()(
}
}
}
def kickPlayer(gameId: String, playerToKick: UUID): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] =>
val game = podManager.getGame(gameId)
game.get.leaveGame(playerToKick)
Redirect(routes.IngameController.game(gameId))
}
def leaveGame(gameId: String): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] =>
val game = podManager.getGame(gameId)
game.get.leaveGame(request.user.id)
Redirect(routes.MainMenuController.mainMenu())
}
def joinGame(gameId: String): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] =>
val game = podManager.getGame(gameId)
val result = Try {