feat(game)!: Add winner display and return to lobby functionality
This commit is contained in:
@@ -6,7 +6,7 @@ import de.knockoutwhist.cards.Hand
|
||||
import de.knockoutwhist.player.AbstractPlayer
|
||||
import logic.PodManager
|
||||
import logic.game.{GameLobby, PollingEvents}
|
||||
import logic.game.PollingEvents.{CardPlayed, LobbyCreation, LobbyUpdate, NewRound, ReloadEvent}
|
||||
import logic.game.PollingEvents.{CardPlayed, LobbyCreation, LobbyUpdate, NewRound, NewTrick, ReloadEvent}
|
||||
import model.sessions.UserSession
|
||||
import model.users.User
|
||||
import play.api.libs.json.{JsArray, JsValue, Json}
|
||||
@@ -26,6 +26,7 @@ class PollingController @Inject() (
|
||||
val cc: ControllerComponents,
|
||||
val podManager: PodManager,
|
||||
val authAction: AuthAction,
|
||||
val ingameController: IngameController,
|
||||
implicit val ec: ExecutionContext
|
||||
) extends AbstractController(cc) {
|
||||
|
||||
@@ -64,7 +65,8 @@ class PollingController @Inject() (
|
||||
"trickCards" -> trickCardsJson,
|
||||
"scoreTable" -> scoreTableJson,
|
||||
"firstCardId" -> firstCardId,
|
||||
"nextPlayer" -> nextPlayer
|
||||
"nextPlayer" -> nextPlayer,
|
||||
"yourTurn" -> (game.logic.getCurrentPlayer.get == player)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -88,6 +90,11 @@ class PollingController @Inject() (
|
||||
val hand = player.currentHand()
|
||||
val jsonResponse = buildCardPlayResponse(game, hand, player, true)
|
||||
Ok(jsonResponse)
|
||||
case NewTrick =>
|
||||
val player = game.getPlayerByUser(userSession.user)
|
||||
val hand = player.currentHand()
|
||||
val jsonResponse = buildCardPlayResponse(game, hand, player, false)
|
||||
Ok(jsonResponse)
|
||||
case CardPlayed =>
|
||||
val player = game.getPlayerByUser(userSession.user)
|
||||
val hand = player.currentHand()
|
||||
@@ -98,7 +105,8 @@ class PollingController @Inject() (
|
||||
case ReloadEvent =>
|
||||
val jsonResponse = Json.obj(
|
||||
"status" -> "reloadEvent",
|
||||
"redirectUrl" -> routes.IngameController.game(game.id).url
|
||||
"redirectUrl" -> routes.IngameController.game(game.id).url,
|
||||
"content" -> ingameController.returnInnerHTML(game, userSession.user).toString
|
||||
)
|
||||
Ok(jsonResponse)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user