feat(ui): add main menu navbar and join game functionality (#35)

Reviewed-on: #35
Reviewed-by: lq64 <lq@blackhole.local>
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-04 12:43:08 +01:00
committed by lq64
parent 5c1a5a661b
commit 32d4f9c6ce
13 changed files with 111 additions and 14 deletions

View File

@@ -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)
@@ -108,6 +111,7 @@ class GameLobby private(
if (!PlayerUtil.canPlayCard(card, getRound, getTrick, player)) {
throw new CantPlayCardException("You can't play this card!")
}
userSession.resetCanInteract()
logic.playerInputLogic.receivedCard(card)
}
@@ -129,6 +133,7 @@ class GameLobby private(
}
val hand = getHand(player)
val card = hand.cards(cardIndex)
userSession.resetCanInteract()
logic.playerInputLogic.receivedDog(Some(card))
}
@@ -141,6 +146,7 @@ class GameLobby private(
val player = getPlayerInteractable(userSession, InteractionType.TrumpSuit)
val trumpSuits = Suit.values.toList
val selectedTrump = trumpSuits(trumpIndex)
userSession.resetCanInteract()
logic.playerInputLogic.receivedTrumpSuit(selectedTrump)
}
@@ -151,6 +157,7 @@ class GameLobby private(
*/
def selectTie(userSession: UserSession, tieNumber: Int): Unit = {
val player = getPlayerInteractable(userSession, InteractionType.TieChoice)
userSession.resetCanInteract()
logic.playerTieLogic.receivedTieBreakerCard(tieNumber)
}