From ee3f65efd9209740c624fe8972f5dc3990259009 Mon Sep 17 00:00:00 2001 From: LQ63 Date: Wed, 5 Nov 2025 02:19:26 +0100 Subject: [PATCH] feat(ui): added working ingame ui Added ingame ui with bootstrap. There were problems with the lock procedure which are now fixed. --- .../app/controllers/IngameController.scala | 2 +- .../app/logic/game/GameLobby.scala | 4 + .../app/views/ingame/ingame.scala.html | 77 ++++++++++--------- .../app/views/mainmenu/creategame.scala.html | 3 +- .../app/views/render/card.scala.html | 2 +- 5 files changed, 47 insertions(+), 41 deletions(-) diff --git a/knockoutwhistweb/app/controllers/IngameController.scala b/knockoutwhistweb/app/controllers/IngameController.scala index c70aede..1f19c51 100644 --- a/knockoutwhistweb/app/controllers/IngameController.scala +++ b/knockoutwhistweb/app/controllers/IngameController.scala @@ -33,7 +33,7 @@ class IngameController @Inject()( case InGame => Ok(views.html.ingame.ingame( g.getPlayerByUser(request.user), - g.logic + g )) case SelectTrump => Ok(views.html.ingame.selecttrump( diff --git a/knockoutwhistweb/app/logic/game/GameLobby.scala b/knockoutwhistweb/app/logic/game/GameLobby.scala index eedbd58..e7b8edb 100644 --- a/knockoutwhistweb/app/logic/game/GameLobby.scala +++ b/knockoutwhistweb/app/logic/game/GameLobby.scala @@ -180,6 +180,10 @@ class GameLobby private( users.clone() } + def getLogic: GameLogic = { + logic + } + private def getPlayerBySession(userSession: UserSession): AbstractPlayer = { val playerOption = getMatch.totalplayers.find(_.id == userSession.id) if (playerOption.isEmpty) { diff --git a/knockoutwhistweb/app/views/ingame/ingame.scala.html b/knockoutwhistweb/app/views/ingame/ingame.scala.html index f587dbc..302d262 100644 --- a/knockoutwhistweb/app/views/ingame/ingame.scala.html +++ b/knockoutwhistweb/app/views/ingame/ingame.scala.html @@ -1,50 +1,51 @@ -@(player: de.knockoutwhist.player.AbstractPlayer, logic: de.knockoutwhist.control.GameLogic) +@(player: de.knockoutwhist.player.AbstractPlayer, gamelobby: logic.game.GameLobby) @main("Ingame") { -
-

Knockout Whist

-
-

Next Player:

-

@logic.getPlayerQueue.get.duplicate().nextPlayer()

-
-
-
-

Trumpsuit:

-

@logic.getCurrentRound.get.trumpSuit

+
+
+
+

Next Player

+

@gamelobby.getLogic.getPlayerQueue.get.duplicate().nextPlayer()

-
-

First Card

- @if(logic.getCurrentTrick.get.firstCard.isDefined) { - @util.WebUIUtils.cardtoImage(logic.getCurrentTrick.get.firstCard.get) +
+

Cards played

+
+
+

Trumpsuit:

+

@gamelobby.getLogic.getCurrentRound.get.trumpSuit

+

First Card:

+ @if(gamelobby.getLogic.getCurrentTrick.get.firstCard.isDefined) { + @util.WebUIUtils.cardtoImage(gamelobby.getLogic.getCurrentTrick.get.firstCard.get) width="30%"/> } else { - @views.html.render.card.apply("images/cards/1B.png")("Blank Card") + @views.html.render.card.apply("images/cards/1B.png")("Blank Card") width="30%"/> }
- -

@logic.getCurrentPlayer.get has to play a card!

- @if(logic.getCurrentTrick.get.cards.nonEmpty) { -

Cards played

- } else { -

Cards played

- } - -
- @for((cardplayed, player) <- logic.getCurrentTrick.get.cards) { -
-

@player

- @util.WebUIUtils.cardtoImage(cardplayed) +
+
+ @for((cardplayed, player) <- gamelobby.getLogic.getCurrentTrick.get.cards) { +
+
+ @util.WebUIUtils.cardtoImage(cardplayed) /> +
+
@player
+
+
+
+ }
- }
- -

Your cards

-
- @for(card <- player.currentHand().get.cards) { - @util.WebUIUtils.cardtoImage(card) - } +
+ @for(i <- 0 until player.currentHand().get.cards.size) { +
+
+ + +
+
+ }
- -
} \ No newline at end of file diff --git a/knockoutwhistweb/app/views/mainmenu/creategame.scala.html b/knockoutwhistweb/app/views/mainmenu/creategame.scala.html index 47dc09c..372449b 100644 --- a/knockoutwhistweb/app/views/mainmenu/creategame.scala.html +++ b/knockoutwhistweb/app/views/mainmenu/creategame.scala.html @@ -1,6 +1,7 @@ @(user: Option[model.users.User]) -@navbar(user) + @main("Create Game") { +@navbar(user)
diff --git a/knockoutwhistweb/app/views/render/card.scala.html b/knockoutwhistweb/app/views/render/card.scala.html index 788be74..a4fca9e 100644 --- a/knockoutwhistweb/app/views/render/card.scala.html +++ b/knockoutwhistweb/app/views/render/card.scala.html @@ -1,2 +1,2 @@ @(src: String)(alt: String) -@alt \ No newline at end of file +