Codacy Badge

For Deckmacia

A Scala implementation of Legends of Runeterra deck codes

// available for 2.12, 2.13, and ScalaJS 1.x
libraryDependencies += "com.github.billzabob" %% "fordeckmacia" % "version"

Example

import fordeckmacia._

val deckCode = "CIBAKAYJFEYDUR2RAYAQAFI2DUSSWLICAEBAAAICAMERGJABAEBQSVI"
// deckCode: String = "CIBAKAYJFEYDUR2RAYAQAFI2DUSSWLICAEBAAAICAMERGJABAEBQSVI"

val deck = Deck.decode(deckCode)
// deck: scodec.Attempt[Deck] = Successful(
//   value = Deck(
//     cards = HashMap(
//       Card(set = 1, faction = Demacia, cardNumber = 43) -> 3,
//       Card(set = 2, faction = Demacia, cardNumber = 1) -> 2,
//       Card(set = 1, faction = Demacia, cardNumber = 29) -> 3,
//       Card(set = 3, faction = MountTargon, cardNumber = 71) -> 3,
//       Card(set = 1, faction = Demacia, cardNumber = 45) -> 3,
//       Card(set = 1, faction = Demacia, cardNumber = 37) -> 3,
//       Card(set = 1, faction = Demacia, cardNumber = 21) -> 3,
//       Card(set = 3, faction = MountTargon, cardNumber = 81) -> 3,
//       Card(set = 3, faction = MountTargon, cardNumber = 36) -> 2,
//       Card(set = 3, faction = MountTargon, cardNumber = 48) -> 3,
//       Card(set = 3, faction = MountTargon, cardNumber = 41) -> 3,
//       Card(set = 3, faction = MountTargon, cardNumber = 19) -> 2,
//       Card(set = 3, faction = MountTargon, cardNumber = 85) -> 1,
//       Card(set = 1, faction = Demacia, cardNumber = 26) -> 3,
//       Card(set = 3, faction = MountTargon, cardNumber = 58) -> 3
//     )
//   )
// )

val cardCodes = deck.map(_.codes)
// cardCodes: scodec.Attempt[Map[String, Int]] = Successful(
//   value = HashMap(
//     "01DE026" -> 3,
//     "03MT019" -> 2,
//     "01DE045" -> 3,
//     "03MT081" -> 3,
//     "03MT036" -> 2,
//     "01DE029" -> 3,
//     "01DE021" -> 3,
//     "01DE043" -> 3,
//     "03MT058" -> 3,
//     "01DE037" -> 3,
//     "03MT041" -> 3,
//     "03MT071" -> 3,
//     "03MT048" -> 3,
//     "03MT085" -> 1,
//     "02DE001" -> 2
//   )
// )

val encoded = deck.flatMap(_.encode)
// encoded: scodec.Attempt[String] = Successful(
//   value = "CIBAKAYJFEYDUR2RAYAQAFI2DUSSWLICAEBAAAICAMERGJABAEBQSVI"
// )