56 lines
1.4 KiB
Scala
56 lines
1.4 KiB
Scala
package industries.sunshine.planningpoker
|
|
|
|
import java.util.UUID
|
|
|
|
/** 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
|
|
) {
|
|
def playersCount: Int = players.size
|
|
}
|
|
|
|
object RoomStateView {
|
|
val testRoom = {
|
|
val me = Player("wormy", PlayerID())
|
|
RoomStateView(
|
|
players = List(me, Player("birdy", PlayerID()), Player("pony", PlayerID())),
|
|
me = me.id,
|
|
allowedCards = List("xs", "s", "m", "l", "xl"),
|
|
round = OpenRound(myCard = Some("l"), alreadyVoted = List(me)),
|
|
canCloseRound = true
|
|
)
|
|
}
|
|
}
|
|
|
|
trait RoundState
|
|
|
|
/** view state for round before votes are open player can know their vote and
|
|
* who of the other players have voted
|
|
*/
|
|
final case class OpenRound(
|
|
myCard: Option[String],
|
|
alreadyVoted: List[Player]
|
|
) extends RoundState
|
|
|
|
/** view state for round after opening the votes
|
|
*/
|
|
final case class ClosedRound(
|
|
votes: Map[PlayerID, String]
|
|
) extends RoundState
|
|
|
|
final class PlayerID
|
|
final case class Player(name: String, id: PlayerID)
|