Reviewed-on: #104 Co-authored-by: Janis <janis.e.20@gmx.de> Co-committed-by: Janis <janis.e.20@gmx.de>
32 lines
770 B
Scala
32 lines
770 B
Scala
package dto
|
|
|
|
import dto.subDTO.{HandDTO, PlayerDTO}
|
|
import logic.game.GameLobby
|
|
import model.users.User
|
|
|
|
import scala.util.Try
|
|
|
|
case class TrumpInfoDTO(
|
|
gameId: String,
|
|
chooser: Option[PlayerDTO],
|
|
self: Option[PlayerDTO],
|
|
selfHand: Option[HandDTO],
|
|
)
|
|
|
|
object TrumpInfoDTO {
|
|
|
|
def apply(lobby: GameLobby, user: User): TrumpInfoDTO = {
|
|
val selfPlayer = Try {
|
|
Some(lobby.getPlayerByUser(user))
|
|
}.getOrElse(None)
|
|
|
|
TrumpInfoDTO(
|
|
gameId = lobby.id,
|
|
chooser = lobby.logic.getTrumpPlayer.map(PlayerDTO(_)),
|
|
self = selfPlayer.map(PlayerDTO(_)),
|
|
selfHand = selfPlayer.flatMap(_.currentHand()).map(HandDTO(_))
|
|
)
|
|
}
|
|
|
|
}
|