53 lines
1.4 KiB
Scala
53 lines
1.4 KiB
Scala
package industries.sunshine.planningpoker.common
|
|
|
|
import java.util.UUID
|
|
import io.circe._
|
|
|
|
object Models {
|
|
|
|
/** view of the single planning poker round
|
|
* @param players - people who are currently playing
|
|
* @param allowedCards- the cards values that can be used by players
|
|
* @param round - state of the selected cards of the players
|
|
* @param canCloseRound - whether current player has access to button to finish the round
|
|
*/
|
|
final case class RoomStateView(
|
|
players: List[Player],
|
|
me: PlayerID,
|
|
allowedCards: List[String],
|
|
round: RoundState,
|
|
canCloseRound: Boolean = false
|
|
) derives Codec.AsObject {
|
|
def playersCount: Int = players.size
|
|
}
|
|
|
|
object RoomStateView {
|
|
val empty = RoomStateView(
|
|
List.empty, PlayerID(0), List.empty, RoundState.Voting(None, List.empty), false
|
|
)
|
|
}
|
|
|
|
|
|
enum RoundState derives Codec.AsObject:
|
|
|
|
/** view state for round before votes are open player can know their vote and
|
|
* who of the other players have voted
|
|
*/
|
|
case Voting(
|
|
myCard: Option[String],
|
|
alreadyVoted: List[Player]
|
|
)
|
|
|
|
/** view state for round after opening the votes
|
|
*/
|
|
case Viewing(
|
|
votes: List[(PlayerID, String)]
|
|
)
|
|
final case class PlayerID(id: Long) derives Codec.AsObject
|
|
|
|
final case class Player(name: String, id: PlayerID) derives Codec.AsObject
|
|
|
|
final case class RoomID(id: Long) derives Codec.AsObject
|
|
|
|
}
|