feat(ui): add main menu navbar and join game functionality #35
@@ -111,7 +111,10 @@ class IngameController @Inject()(
|
|||||||
cardIdOpt match {
|
cardIdOpt match {
|
||||||
case Some(cardId) =>
|
case Some(cardId) =>
|
||||||
val result = Try {
|
val result = Try {
|
||||||
g.playCard(g.getUserSession(request.user.id), cardId.toInt)
|
val session = g.getUserSession(request.user.id)
|
||||||
|
session.lock.lock()
|
||||||
|
g.playCard(session, cardId.toInt)
|
||||||
|
session.lock.unlock()
|
||||||
}
|
}
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
NoContent
|
NoContent
|
||||||
@@ -146,9 +149,15 @@ class IngameController @Inject()(
|
|||||||
val result = Try {
|
val result = Try {
|
||||||
cardIdOpt match {
|
cardIdOpt match {
|
||||||
case Some(cardId) if cardId == "skip" =>
|
case Some(cardId) if cardId == "skip" =>
|
||||||
g.playDogCard(g.getUserSession(request.user.id), -1)
|
val session = g.getUserSession(request.user.id)
|
||||||
|
session.lock.lock()
|
||||||
|
g.playDogCard(session, -1)
|
||||||
|
session.lock.unlock()
|
||||||
case Some(cardId) =>
|
case Some(cardId) =>
|
||||||
g.playDogCard(g.getUserSession(request.user.id), cardId.toInt)
|
val session = g.getUserSession(request.user.id)
|
||||||
|
session.lock.lock()
|
||||||
|
g.playDogCard(session, cardId.toInt)
|
||||||
|
session.lock.unlock()
|
||||||
case None =>
|
case None =>
|
||||||
throw new IllegalArgumentException("cardId parameter is missing")
|
throw new IllegalArgumentException("cardId parameter is missing")
|
||||||
}
|
}
|
||||||
@@ -184,7 +193,10 @@ class IngameController @Inject()(
|
|||||||
trumpOpt match {
|
trumpOpt match {
|
||||||
case Some(trump) =>
|
case Some(trump) =>
|
||||||
val result = Try {
|
val result = Try {
|
||||||
g.selectTrump(g.getUserSession(request.user.id), trump.toInt)
|
val session = g.getUserSession(request.user.id)
|
||||||
|
session.lock.lock()
|
||||||
|
g.selectTrump(session, trump.toInt)
|
||||||
|
session.lock.unlock()
|
||||||
}
|
}
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
NoContent
|
NoContent
|
||||||
@@ -216,7 +228,10 @@ class IngameController @Inject()(
|
|||||||
tieOpt match {
|
tieOpt match {
|
||||||
case Some(tie) =>
|
case Some(tie) =>
|
||||||
val result = Try {
|
val result = Try {
|
||||||
|
val session = g.getUserSession(request.user.id)
|
||||||
|
session.lock.lock()
|
||||||
g.selectTie(g.getUserSession(request.user.id), tie.toInt)
|
g.selectTie(g.getUserSession(request.user.id), tie.toInt)
|
||||||
|
session.lock.unlock()
|
||||||
}
|
}
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
NoContent
|
NoContent
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ class GameLobby private(
|
|||||||
if (!PlayerUtil.canPlayCard(card, getRound, getTrick, player)) {
|
if (!PlayerUtil.canPlayCard(card, getRound, getTrick, player)) {
|
||||||
throw new CantPlayCardException("You can't play this card!")
|
throw new CantPlayCardException("You can't play this card!")
|
||||||
}
|
}
|
||||||
|
userSession.resetCanInteract()
|
||||||
logic.playerInputLogic.receivedCard(card)
|
logic.playerInputLogic.receivedCard(card)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +133,7 @@ class GameLobby private(
|
|||||||
}
|
}
|
||||||
val hand = getHand(player)
|
val hand = getHand(player)
|
||||||
val card = hand.cards(cardIndex)
|
val card = hand.cards(cardIndex)
|
||||||
|
userSession.resetCanInteract()
|
||||||
logic.playerInputLogic.receivedDog(Some(card))
|
logic.playerInputLogic.receivedDog(Some(card))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +146,7 @@ class GameLobby private(
|
|||||||
val player = getPlayerInteractable(userSession, InteractionType.TrumpSuit)
|
val player = getPlayerInteractable(userSession, InteractionType.TrumpSuit)
|
||||||
val trumpSuits = Suit.values.toList
|
val trumpSuits = Suit.values.toList
|
||||||
val selectedTrump = trumpSuits(trumpIndex)
|
val selectedTrump = trumpSuits(trumpIndex)
|
||||||
|
userSession.resetCanInteract()
|
||||||
logic.playerInputLogic.receivedTrumpSuit(selectedTrump)
|
logic.playerInputLogic.receivedTrumpSuit(selectedTrump)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +157,7 @@ class GameLobby private(
|
|||||||
*/
|
*/
|
||||||
def selectTie(userSession: UserSession, tieNumber: Int): Unit = {
|
def selectTie(userSession: UserSession, tieNumber: Int): Unit = {
|
||||||
val player = getPlayerInteractable(userSession, InteractionType.TieChoice)
|
val player = getPlayerInteractable(userSession, InteractionType.TieChoice)
|
||||||
|
userSession.resetCanInteract()
|
||||||
logic.playerTieLogic.receivedTieBreakerCard(tieNumber)
|
logic.playerTieLogic.receivedTieBreakerCard(tieNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,4 +28,8 @@ class UserSession(user: User, val host: Boolean) extends PlayerSession {
|
|||||||
|
|
||||||
override def name: String = user.name
|
override def name: String = user.name
|
||||||
|
|
||||||
|
def resetCanInteract(): Unit = {
|
||||||
|
canInteract = None
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user