adding backend project

will try to do rest & websocket api with http4s
This commit is contained in:
efim
2023-04-23 11:12:08 +04:00
parent 7e488b7e62
commit d8af92787d
6 changed files with 70 additions and 4 deletions

View File

@@ -0,0 +1,72 @@
package industries.sunshine.planningpoker.common
import java.util.UUID
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
) {
def playersCount: Int = players.size
}
object RoomStateView {
val me = Player("wormy", PlayerID())
val testRoom = {
val pony = Player("pony", PlayerID())
RoomStateView(
players = List(me, Player("birdy", PlayerID()), pony),
me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"),
round = VotingRound(myCard = Some("s"), alreadyVoted = List(me, pony)),
canCloseRound = true
)
}
val testOpenedRoom = {
val pony = Player("pony", PlayerID())
val birdy = Player("birdy", PlayerID())
val horsey = Player("horsey", PlayerID())
RoomStateView(
players = List(me, birdy, pony, horsey),
me = me.id,
allowedCards = List("xs", "s", "m", "l", "xl"),
round = ViewingRound(Map( me.id -> "xs", pony.id -> "l", birdy.id -> "s", horsey.id -> "m" )),
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 VotingRound(
myCard: Option[String],
alreadyVoted: List[Player]
) extends RoundState
/** view state for round after opening the votes
*/
final case class ViewingRound(
votes: Map[PlayerID, String]
) extends RoundState
final class PlayerID
final case class Player(name: String, id: PlayerID)
}