feat!: display room name

BREAKING CHANGE: protocol now expects room name attribute
This commit is contained in:
efim 2023-04-30 09:55:49 +04:00
parent e2795edbe6
commit db65777780
3 changed files with 83 additions and 76 deletions

View File

@ -17,6 +17,7 @@ object Models {
* \- whether current player has access to button to finish the round * \- whether current player has access to button to finish the round
*/ */
final case class RoomStateView( final case class RoomStateView(
roomName: String,
players: List[Player], players: List[Player],
me: PlayerID, me: PlayerID,
allowedCards: List[String], allowedCards: List[String],
@ -26,6 +27,7 @@ object Models {
object RoomStateView { object RoomStateView {
val empty = RoomStateView( val empty = RoomStateView(
"",
List.empty, List.empty,
PlayerID(0), PlayerID(0),
List.empty, List.empty,
@ -70,6 +72,7 @@ object Models {
.find(_.id == playerId) .find(_.id == playerId)
.fold(ifEmpty = RoomStateView.empty)((me: Player) => .fold(ifEmpty = RoomStateView.empty)((me: Player) =>
RoomStateView( RoomStateView(
id.name,
players, players,
me.id, me.id,
allowedCards, allowedCards,

View File

@ -24,79 +24,79 @@ object TestModels {
// val testSessions = Map(testSessionId -> (testRoomBackend.id, me.id)) // val testSessions = Map(testSessionId -> (testRoomBackend.id, me.id))
// val testRooms = Map(testRoomBackend.id -> testRoomBackend) // val testRooms = Map(testRoomBackend.id -> testRoomBackend)
val testChangesList = List( // val testChangesList = List(
RoomStateView( // RoomStateView(
players = List(me), // players = List(me),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Voting(myCard = None, alreadyVoted = List.empty), // round = RoundStateView.Voting(myCard = None, alreadyVoted = List.empty),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, pony), // players = List(me, pony),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Voting(myCard = None, alreadyVoted = List.empty), // round = RoundStateView.Voting(myCard = None, alreadyVoted = List.empty),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, birdy, pony), // players = List(me, birdy, pony),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Voting(myCard = None, alreadyVoted = List.empty), // round = RoundStateView.Voting(myCard = None, alreadyVoted = List.empty),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, birdy, pony), // players = List(me, birdy, pony),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Voting(myCard = None, alreadyVoted = List(birdy.id)), // round = RoundStateView.Voting(myCard = None, alreadyVoted = List(birdy.id)),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, birdy, pony), // players = List(me, birdy, pony),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id)), // round = RoundStateView.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id)),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, birdy, pony), // players = List(me, birdy, pony),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id)), // round = RoundStateView.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id)),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, birdy, pony, horsey), // players = List(me, birdy, pony, horsey),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id)), // round = RoundStateView.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id)),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, birdy, pony, horsey), // players = List(me, birdy, pony, horsey),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id, horsey.id)), // round = RoundStateView.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id, horsey.id)),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, birdy, pony, horsey), // players = List(me, birdy, pony, horsey),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView // round = RoundStateView
.Voting(myCard = Some("m"), alreadyVoted = List(birdy.id, horsey.id, pony.id)), // .Voting(myCard = Some("m"), alreadyVoted = List(birdy.id, horsey.id, pony.id)),
canCloseRound = true // canCloseRound = true
), // ),
RoomStateView( // RoomStateView(
players = List(me, birdy, pony, horsey), // players = List(me, birdy, pony, horsey),
me = me.id, // me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundStateView.Viewing( // round = RoundStateView.Viewing(
List(me.id -> "m", pony.id -> "l", birdy.id -> "s", horsey.id -> "m") // List(me.id -> "m", pony.id -> "l", birdy.id -> "s", horsey.id -> "m")
), // ),
canCloseRound = true // canCloseRound = true
) // )
) // )
} }

View File

@ -35,7 +35,11 @@ object RoomView {
val wsFinalDeathSignal = wsStream.closed.collect { case (_, false) => () } val wsFinalDeathSignal = wsStream.closed.collect { case (_, false) => () }
div( div(
className := "w-full h-full border-4 border-amber-900 flex flex-col", className := "w-full h-full border-4 border-amber-900 flex flex-col relative",
div(
className := "absolute top-2 right-2",
child.text <-- roomStateSignal.map(st => s"Room name: '${st.roomName}'"),
),
OtherPlayers.render(roomStateSignal), OtherPlayers.render(roomStateSignal),
TableView.renderTable(roomStateSignal), TableView.renderTable(roomStateSignal),
OwnHandControls.render(roomStateSignal), OwnHandControls.render(roomStateSignal),