feat(ui): add Lobby and Main Menu Body

Added main Menu body and a Lobby with Bootstrap
This commit is contained in:
LQ63
2025-11-04 19:11:19 +01:00
parent 44c88c8f60
commit 89d1626bb2
7 changed files with 154 additions and 17 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,7 +29,7 @@ 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),
@@ -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 {