Card.elm 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. module Card exposing (CardData, CardDetails, CardPerformanceData, CardType(..), ManaColor(..), Power(..), pickRate)
  2. type ManaColor
  3. = Red
  4. | Blue
  5. | Green
  6. | White
  7. | Black
  8. | Colorless
  9. type CardType
  10. = Creature
  11. | Instant
  12. | Sorcery
  13. | Enchantment
  14. | Artifact
  15. | Planeswalker
  16. | Land
  17. | Other
  18. type Power
  19. = ConstantPower Int
  20. | VariablePower
  21. type alias CardData =
  22. { details : CardDetails
  23. , performance : CardPerformanceData
  24. }
  25. type alias CardDetails =
  26. { cmc : Int
  27. , cardType : CardType
  28. , typeLine : String
  29. , oracleText : String
  30. , power : Maybe Power
  31. , toughness : Maybe Power
  32. , colors : List ManaColor
  33. --, manaCost : List ManaColor
  34. }
  35. type alias CardPerformanceData =
  36. { totalTimesSeen : Int
  37. , totalTimesPicked : Int
  38. , averagePickPosition : Maybe Float
  39. , averageSeenPosition : Maybe Float
  40. , gameInHandWinRate : Maybe Float
  41. }
  42. pickRate : CardData -> Float
  43. pickRate card =
  44. if card.performance.totalTimesSeen == 0 then
  45. 0
  46. else
  47. toFloat card.performance.totalTimesPicked / toFloat card.performance.totalTimesSeen