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
*/
final case class RoomStateView(
roomName: String,
players: List[Player],
me: PlayerID,
allowedCards: List[String],
@ -26,6 +27,7 @@ object Models {
object RoomStateView {
val empty = RoomStateView(
"",
List.empty,
PlayerID(0),
List.empty,
@ -70,6 +72,7 @@ object Models {
.find(_.id == playerId)
.fold(ifEmpty = RoomStateView.empty)((me: Player) =>
RoomStateView(
id.name,
players,
me.id,
allowedCards,

View File

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

View File

@ -35,7 +35,11 @@ object RoomView {
val wsFinalDeathSignal = wsStream.closed.collect { case (_, false) => () }
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),
TableView.renderTable(roomStateSignal),
OwnHandControls.render(roomStateSignal),