bugfix: need to recognize owner after relogin

playerid is not stable right now, need to use nickname
This commit is contained in:
efim 2023-04-28 11:54:51 +04:00
parent 3158a75f5d
commit d7d4e2be9d
4 changed files with 18 additions and 18 deletions

View File

@ -82,6 +82,6 @@ object Auth {
def make[F[_]: Sync](): F[Auth[F]] = def make[F[_]: Sync](): F[Auth[F]] =
for { for {
sessionsMap <- Ref.of[F, SessionsMap](TestModels.testSessions) sessionsMap <- Ref.of[F, SessionsMap](Map.empty)
} yield new SimpleAuth(sessionsMap) } yield new SimpleAuth(sessionsMap)
} }

View File

@ -59,7 +59,7 @@ class InMemoryRoomService[F[_]: Concurrent](stateRef: Ref[F, Map[RoomID, (Room,
val newRoom = Room( val newRoom = Room(
roomId, roomId,
players = List(ownerPlayer), players = List(ownerPlayer),
owner = ownerPlayer.id, owner = ownerPlayer.name,
password = roomPassword, password = roomPassword,
allowedCards = List("XS", "S", "M", "L", "XL"), // TODO accept from front allowedCards = List("XS", "S", "M", "L", "XL"), // TODO accept from front
round = RoundState.Voting(Map.empty), round = RoundState.Voting(Map.empty),

View File

@ -59,7 +59,7 @@ object Models {
final case class Room( final case class Room(
id: RoomID, id: RoomID,
players: List[Player], players: List[Player],
owner: PlayerID, // TODO switch to nickname owner: String, // TODO switch to nickname
password: String, password: String,
allowedCards: List[String], allowedCards: List[String],
round: RoundState, round: RoundState,
@ -74,7 +74,7 @@ object Models {
me.id, me.id,
allowedCards, allowedCards,
round.toViewFor(playerId), round.toViewFor(playerId),
playerId == owner me.name == owner
) )
) )
} }

View File

@ -8,21 +8,21 @@ object TestModels {
val birdy = Player("birdy", PlayerID(11)) val birdy = Player("birdy", PlayerID(11))
val horsey = Player("horsey", PlayerID(12)) val horsey = Player("horsey", PlayerID(12))
val testRoomBackend = Room( // val testRoomBackend = Room(
id = RoomID("testroom"), // id = RoomID("testroom"),
players = List(me, birdy, pony, horsey), // players = List(me, birdy, pony, horsey),
owner = me.id, // owner = me.id,
password = "password", // password = "password",
allowedCards = List("xs", "s", "m", "l", "xl"), // allowedCards = List("xs", "s", "m", "l", "xl"),
round = RoundState.Viewing( // round = RoundState.Viewing(
Map(me.id -> "xs", pony.id -> "l", birdy.id -> "s", horsey.id -> "m") // Map(me.id -> "xs", pony.id -> "l", birdy.id -> "s", horsey.id -> "m")
), // ),
playersPasswords = Map("me" -> "nickpassword") // nickname into password // playersPasswords = Map("me" -> "nickpassword") // nickname into password
) // )
val testSessionId = 1L // val testSessionId = 1L
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(