diff --git a/bruno/KnockOutWhist/Game/Get Game.bru b/bruno/KnockOutWhist/Game/Get Game.bru index 6b6d6af..8bc5076 100644 --- a/bruno/KnockOutWhist/Game/Get Game.bru +++ b/bruno/KnockOutWhist/Game/Get Game.bru @@ -11,7 +11,7 @@ get { } params:path { - id: uZDNZA + id: BZvtJ3 } settings { diff --git a/bruno/KnockOutWhist/Game/Start Game.bru b/bruno/KnockOutWhist/Game/Start Game.bru index cc231bf..fa798f6 100644 --- a/bruno/KnockOutWhist/Game/Start Game.bru +++ b/bruno/KnockOutWhist/Game/Start Game.bru @@ -11,7 +11,7 @@ post { } params:path { - id: uZDNZA + id: nR1o3n } settings { diff --git a/knockoutwhist b/knockoutwhist index e0e45c4..b9a7b0a 160000 --- a/knockoutwhist +++ b/knockoutwhist @@ -1 +1 @@ -Subproject commit e0e45c4b431fff6740e38a59906f5e217fcd801f +Subproject commit b9a7b0a2af7cef7225bf1a0388ebf58171a173f2 diff --git a/knockoutwhistweb/app/controllers/MainMenuController.scala b/knockoutwhistweb/app/controllers/MainMenuController.scala index a7a1637..7032b52 100644 --- a/knockoutwhistweb/app/controllers/MainMenuController.scala +++ b/knockoutwhistweb/app/controllers/MainMenuController.scala @@ -21,7 +21,7 @@ class MainMenuController @Inject()( // Pass the request-handling function directly to authAction (no nested Action) def mainMenu(): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] => - Ok("Main Menu for user: " + request.user.name) + Ok(views.html.mainmenu.navbar(Some(request.user))) } def index(): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] => @@ -36,6 +36,22 @@ class MainMenuController @Inject()( ) Redirect(routes.IngameController.game(gameLobby.id)) } + + def joinGame(): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] => + val postData = request.body.asFormUrlEncoded + if (postData.isDefined) { + val gameId = postData.get.get("gameId").flatMap(_.headOption).getOrElse("") + val game = podManager.getGame(gameId) + game match { + case Some(g) => + Redirect(routes.IngameController.joinGame(gameId)) + case None => + NotFound("Game not found") + } + } else { + BadRequest("Invalid form submission") + } + } def rules(): Action[AnyContent] = { Action { implicit request => diff --git a/knockoutwhistweb/app/controllers/UserController.scala b/knockoutwhistweb/app/controllers/UserController.scala index 361826f..d3e5ebf 100644 --- a/knockoutwhistweb/app/controllers/UserController.scala +++ b/knockoutwhistweb/app/controllers/UserController.scala @@ -64,7 +64,7 @@ class UserController @Inject()( if (sessionCookie.isDefined) { sessionManager.invalidateSession(sessionCookie.get.value) } - NoContent.discardingCookies(DiscardingCookie("sessionId")) + Redirect(routes.UserController.login()).discardingCookies(DiscardingCookie("sessionId")) } } \ No newline at end of file diff --git a/knockoutwhistweb/app/logic/game/GameLobby.scala b/knockoutwhistweb/app/logic/game/GameLobby.scala index 7dadf4a..6ee102d 100644 --- a/knockoutwhistweb/app/logic/game/GameLobby.scala +++ b/knockoutwhistweb/app/logic/game/GameLobby.scala @@ -70,6 +70,9 @@ class GameLobby private( if (!sessionOpt.get.host) { throw new NotHostException("Only the host can start the game!") } + if (logic.getCurrentState != Lobby) { + throw new IllegalStateException("The game has already started!") + } val playerNamesList = ListBuffer[AbstractPlayer]() users.values.foreach { player => playerNamesList += PlayerFactory.createPlayer(player.name, player.id, HUMAN) diff --git a/knockoutwhistweb/app/views/ingame/ingame.scala.html b/knockoutwhistweb/app/views/ingame/ingame.scala.html index cb24ac0..f587dbc 100644 --- a/knockoutwhistweb/app/views/ingame/ingame.scala.html +++ b/knockoutwhistweb/app/views/ingame/ingame.scala.html @@ -17,7 +17,7 @@ @if(logic.getCurrentTrick.get.firstCard.isDefined) { @util.WebUIUtils.cardtoImage(logic.getCurrentTrick.get.firstCard.get) } else { - @views.html.render.card.apply("../../../public/images/cards/1B.png")("Blank Card") + @views.html.render.card.apply("images/cards/1B.png")("Blank Card") } diff --git a/knockoutwhistweb/app/views/mainmenu/navbar.scala.html b/knockoutwhistweb/app/views/mainmenu/navbar.scala.html new file mode 100644 index 0000000..a5f9cc4 --- /dev/null +++ b/knockoutwhistweb/app/views/mainmenu/navbar.scala.html @@ -0,0 +1,56 @@ +@(user: Option[model.users.User]) +@main("Knockout Whist - Main Menu") { + +} diff --git a/knockoutwhistweb/app/views/mainmenu/rules.scala.html b/knockoutwhistweb/app/views/mainmenu/rules.scala.html index a6a1b90..08a968d 100644 --- a/knockoutwhistweb/app/views/mainmenu/rules.scala.html +++ b/knockoutwhistweb/app/views/mainmenu/rules.scala.html @@ -1,7 +1,7 @@ @() @main("Rules") { -
+
diff --git a/knockoutwhistweb/conf/routes b/knockoutwhistweb/conf/routes index c122c96..f1867c7 100644 --- a/knockoutwhistweb/conf/routes +++ b/knockoutwhistweb/conf/routes @@ -13,6 +13,7 @@ GET /mainmenu controllers.MainMenuController.mainMenu() GET /rules controllers.MainMenuController.rules() POST /createGame controllers.MainMenuController.createGame() +POST /joinGame controllers.MainMenuController.joinGame() # User authentication routes GET /login controllers.UserController.login() @@ -22,9 +23,7 @@ GET /logout controllers.UserController.logout() # In-game routes GET /game/:id controllers.IngameController.game(id: String) -POST /game/:id/join controllers.IngameController.joinGame(id: String) - +GET /game/:id/join controllers.IngameController.joinGame(id: String) POST /game/:id/start controllers.IngameController.startGame(id: String) - POST /game/:id/playCard controllers.IngameController.playCard(id: String) \ No newline at end of file diff --git a/knockoutwhistweb/public/images/profile.png b/knockoutwhistweb/public/images/profile.png new file mode 100644 index 0000000..941c0dc Binary files /dev/null and b/knockoutwhistweb/public/images/profile.png differ
Rules Overview and Equipment