fix: BAC-29 Implement Mappers for Common Classes (#101)
Reviewed-on: #101 Co-authored-by: Janis <janis.e.20@gmx.de> Co-committed-by: Janis <janis.e.20@gmx.de>
This commit is contained in:
18
knockoutwhistweb/app/dto/HandDTO.scala
Normal file
18
knockoutwhistweb/app/dto/HandDTO.scala
Normal file
@@ -0,0 +1,18 @@
|
||||
package dto
|
||||
|
||||
import de.knockoutwhist.cards.Hand
|
||||
import play.api.libs.json.{Json, OFormat}
|
||||
|
||||
case class HandDTO(card: List[CardDTO])
|
||||
|
||||
object HandDTO {
|
||||
|
||||
implicit val handFormat: OFormat[HandDTO] = Json.format[HandDTO]
|
||||
|
||||
def apply(hand: Hand): HandDTO = {
|
||||
HandDTO(
|
||||
card = hand.cards.zipWithIndex.map { case (card, idx) => CardDTO(card, idx) }
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user